Pattern Matching using brute force in openCL -
I've stored the text [textLength] in an array, and pattern in the array [pattern length]
cl_char * a = (cl_char *) mlok (text langam * clamp (cl_char)); For (int i = 0; i & lt; textLength; i ++) {a [i] = text [i]; } // A buffer object memory is a handle for an area of cl_mem a_buffer = clCreateBuffer (reference, CL_MEM_READ_ONLY | // buffer object read only for the kernel dropdown CL_MEM_COPY_HOST_PTR, // copy host indicator textLength * sizeof referenced by // memory Data (cl_char), // size buffer object bytes, // host pointer tap); // An error code // text and pattern kernel arguments cl_char * b = (cl_char *) for malloc returned (Patternally * size (cl_char)); For (int i = 0; i & lt; pattern length; i ++) {b [ii] = pattern [i]; } // A buffer object has a handle for an area of memory / * cl_mem b_buffer = clCreateBuffer (reference, CL_MEM_READ_ONLY | // buffer object referenced only for readable kernel CL_MEM_COPY_HOST_PTR, // host indicator refers data from memory copied by patternLength // * sizeof (Cl_char), // size buffer object bytes, // host pointer tap); // No error code found * / cl_mem b_buffer = NULL; ClSetKernelArg (kernel, 0, size (a_buffer), (zeros *) and e_buffer); ClSetKernelArg (kernel, 1, size (cl_mem), NULL); ClSetKernelArg (kernel, n, size (cl_mem), and amp; b_buffer); Size_t global_work_size = numberofWorkItem; Cl_int error = clEnqueueNDRangeKernel (line, kernel, 1, zero, // global work item dimensions and offset & amp; global_work_size, // global number of work items; patternLength, // local work 0 items, number of zero, Do not wait for & amp; timeEvent to complete any event;); // No Event Object Returned I have read that in clSetKernelArg, for __local indentifiers, arg_value must be NULL. I have done that b_buffer = null; But by doing this, the b_buffer must be prevented from accumulating the value of B [] (pattern) how do I do it?
Also, if I am not mistaken, Sthaniy_vrk_akar can not exceed the value given by CL_DEVICE_MAX_WORK_ITEM_SIZES since it is constrained by Sthaniy_vrk_akar underlying device / hardware may be on the other hand, Global_work_size, bigger may be bigger Is this a valuable local_work_ shape to be ??? If yes, then why?
itemprop = "text"> Your error is in the clSetKernelArg queue:
// wrong clSetKernelArg (Kernel, n, size (cl_mem), and amp; b_buffer); // right clSetKernelArg (kernel, n, size (cl_char) * pattern lang, null); Local memory is approved after the kernel execution, so you will not be able to use a copy of B_buffer your method. In addition, the local memory is not assigned by the host. You need to copy the global parameter to bring it into the LDS.
To get a copy of the local data, you must also provide the global cl_mem as well as the local parameter. The copy can be dropped at the end of red and for the hosting with ClEnqueueReadBuffer back.
update Here is a typical example of how to use a dynamic local buffer, and it specifies the content of a global buffer.
__ kernel zero copyBufferExample (__ global int * srcBuff, __local int * localBuff, constant integer copyCount) {int lid = get_local_id (0); Int ls = get_local_size (0); Int i; For (i = lid; i & lt; Copikount; i + = ls) {local ice [i] = src buff [i]; } // Use local Bof need // Copy the back of the global memory if necessary}
Comments
Post a Comment