Changeset 1688 in CLRX


Ignore:
Timestamp:
Nov 10, 2015, 1:55:48 PM (5 years ago)
Author:
matszpk
Message:

CLRadeonExtender: Samples: Move enqueueNDRangeKernel call into separate routine.

Location:
CLRadeonExtender/trunk/samples
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • CLRadeonExtender/trunk/samples/CLUtils.cpp

    r1683 r1688  
    240240        workGroupSizeMultiple = 64; // fix for GalliumCompute
    241241}
     242
     243void CLFacade::callNDRangeKernel(cl_kernel kernel, cl_uint workDim, const size_t* offset,
     244               const size_t* workSize, const size_t* localSize)
     245{
     246    cl_event event;
     247    cl_int error = clEnqueueNDRangeKernel(queue, kernel, workDim, offset, workSize,
     248                                   localSize, 0, nullptr, &event);
     249    if (error != CL_SUCCESS)
     250        throw CLError(error, "clEnqueueNDRangeKernel");
     251    error = clWaitForEvents(1, &event); // waiting for finish kernel
     252    if (error != CL_SUCCESS)
     253    {
     254        clReleaseEvent(event);
     255        throw CLError(error, "clWaitForEvents");
     256    }
     257    clReleaseEvent(event);
     258}
  • CLRadeonExtender/trunk/samples/CLUtils.h

    r1680 r1688  
    7272               size_t& workGroupSizeMultiple);
    7373   
     74    void callNDRangeKernel(cl_kernel kernel, cl_uint workDim, const size_t* offset,
     75               const size_t* workSize, const size_t* localSize);
    7476public:
    7577    explicit CLFacade(cl_uint deviceIndex, const char* sourceCode,
  • CLRadeonExtender/trunk/samples/ImageMix.cpp

    r1684 r1688  
    238238    clSetKernelArg(kernels[0], 2, sizeof(cl_mem), &outImage);
    239239   
    240     cl_event event = nullptr;
    241240    size_t workGroupSize, workGroupSizeMul;
    242241    getKernelInfo(kernels[0], workGroupSize, workGroupSizeMul);
     
    253252    std::cout << "WorkSize: " << workSize[0] << "x" << workSize[1] <<
    254253            ", LocalSize: " << localSize[0] << "x" << localSize[1] << std::endl;
    255     error = clEnqueueNDRangeKernel(queue, kernels[0], 2, nullptr, workSize, localSize,
    256                        0, nullptr, &event);
    257     if (error != CL_SUCCESS)
    258         throw CLError(error, "clEnqueueNDRangeKernel");
    259     error = clWaitForEvents(1, &event); // waiting for finish kernel
    260     if (error != CL_SUCCESS)
    261     {
    262         clReleaseEvent(event);
    263         throw CLError(error, "clWaitForEvents");
    264     }
    265     clReleaseEvent(event);
     254    callNDRangeKernel(kernels[0], 2, nullptr, workSize, localSize);
    266255   
    267256    /* write image to output */
  • CLRadeonExtender/trunk/samples/ReverseBits.cpp

    r1685 r1688  
    154154   
    155155    /// execute kernel
    156     cl_event event = nullptr;
    157156    size_t workGroupSize, workGroupSizeMul;
    158157    getKernelInfo(kernels[0], workGroupSize, workGroupSizeMul);
     
    160159    size_t workSize = (size+workGroupSize-1)/workGroupSize*workGroupSize;
    161160    std::cout << "WorkSize: " << workSize << ", LocalSize: " << workGroupSize << std::endl;
    162    
    163     error = clEnqueueNDRangeKernel(queue, kernels[0], 1, nullptr, &workSize,
    164                                    &workGroupSize, 0, nullptr, &event);
    165     if (error != CL_SUCCESS)
    166         throw CLError(error, "clEnqueueNDRangeKernel");
    167     error = clWaitForEvents(1, &event); // waiting for finish kernel
    168     if (error != CL_SUCCESS)
    169     {
    170         clReleaseEvent(event);
    171         throw CLError(error, "clWaitForEvents");
    172     }
    173     clReleaseEvent(event);
     161    callNDRangeKernel(kernels[0], 1, nullptr, &workSize, &workGroupSize);
    174162   
    175163    std::unique_ptr<cxbyte[]> outData(new cxbyte[size]);
  • CLRadeonExtender/trunk/samples/VectorAdd.cpp

    r1684 r1688  
    219219    clSetKernelArg(kernels[0], 3, sizeof(cl_mem), &cBuffer);
    220220    /// execute kernel
    221     cl_event event = nullptr;
    222221    size_t workGroupSize, workGroupSizeMul;
    223222    getKernelInfo(kernels[0], workGroupSize, workGroupSizeMul);
     
    225224    size_t workSize = (elemsNum+workGroupSize-1)/workGroupSize*workGroupSize;
    226225    std::cout << "WorkSize: " << workSize << ", LocalSize: " << workGroupSize << std::endl;
    227    
    228     error = clEnqueueNDRangeKernel(queue, kernels[0], 1, nullptr, &workSize,
    229                                    &workGroupSize, 0, nullptr, &event);
    230     if (error != CL_SUCCESS)
    231         throw CLError(error, "clEnqueueNDRangeKernel");
    232     error = clWaitForEvents(1, &event); // waiting for finish kernel
    233     if (error != CL_SUCCESS)
    234     {
    235         clReleaseEvent(event);
    236         throw CLError(error, "clWaitForEvents");
    237     }
    238     clReleaseEvent(event);
     226    callNDRangeKernel(kernels[0], 1, nullptr, &workSize, &workGroupSize);
    239227   
    240228    /// read output buffer
Note: See TracChangeset for help on using the changeset viewer.