annotate paper/src/cuLaunchKernel.cbc @ 14:a63df15c9afc default tip

DONE
author soto <soto@cr.ie.u-ryukyu.ac.jp>
date Mon, 15 Feb 2021 23:36:39 +0900
parents 959f4b34d6f4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
1 int computeblockDim(int count, int maxThreadPerBlock) {
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
2 return count < maxThreadPerBlock ? count : maxThreadPerBlock;
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
3 }
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
4
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
5 __code execCUDAExecutor(struct CUDAExecutor* executor, struct Context* task, __code next(...)) {
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
6 // check data parallelism task
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
7 if (task->iterate) {
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
8 struct MultiDimIterator* iterator = &task->iterator->iterator->MultiDimIterator;
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
9
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
10 // compute block thread size
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
11 int blockDimX = computeblockDim(iterator->x, executor->maxThreadPerBlock);
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
12 int blockDimY = computeblockDim(iterator->y, executor->maxThreadPerBlock);
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
13 int blockDimZ = computeblockDim(iterator->z, executor->maxThreadPerBlock);
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
14
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
15 checkCudaErrors(cuLaunchKernel(task->function,
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
16 iterator->x/blockDimX, iterator->y/blockDimY, iterator->z/blockDimZ,
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
17 blockDimX, blockDimY, blockDimZ,
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
18 0, NULL, (void**)executor->kernelParams, NULL));
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
19 }
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
20 ...
959f4b34d6f4 add final thesis
soto
parents:
diff changeset
21 }