view paper/src/cuLaunchKernel.cbc @ 19:046b2b20d6c7 default tip

fix
author ryokka
date Mon, 09 Mar 2020 11:25:49 +0900
parents c7acb9211784
children
line wrap: on
line source

int computeblockDim(int count, int maxThreadPerBlock) {
    return count < maxThreadPerBlock ? count : maxThreadPerBlock;
}

__code execCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) {
    // check data parallelism task
    if (task->iterate) {
        struct MultiDimIterator* iterator = &task->iterator->iterator->MultiDimIterator;

        // compute block thread size 
        int blockDimX = computeblockDim(iterator->x, executor->maxThreadPerBlock);
        int blockDimY = computeblockDim(iterator->y, executor->maxThreadPerBlock);
        int blockDimZ = computeblockDim(iterator->z, executor->maxThreadPerBlock);

        checkCudaErrors(cuLaunchKernel(task->function,
                    iterator->x/blockDimX, iterator->y/blockDimY, iterator->z/blockDimZ,
                    blockDimX, blockDimY, blockDimZ,
                    0, NULL, (void**)executor->kernelParams, NULL));
    }
    ...
}