Is it possible to easily setup you grid or blocks so they can work with uneven datasets? The thing is that I have a 3D CT dataset which is not always a multiple of 16. If this is the case so lets say the dataset is 524 x 340 x 1 I now calculate how much blocks of 16x16x1 fit into the dataset.
And if I’m out of blocks that fit i change the blocksize for the last block. so that it will fit into the the dataset.
Is there another solution to do this, or is this the only way to do it.
litte code example:
if((dimx % 16) == 0 && (dimy % 16) == 0) {
dim3 dimBlock(blockSize_x_, blockSize_y_);
dim3 dimGrid((dimx_)*(dimz_)/ dimBlock.x, (dimy_) / dimBlock.y);
gpu_raytracer(d_radiologicalDepth_, d_CT_dataset_,
(dimGrid.x / dimz_), blockSize_x_, blockSize_y_,
offset_x_, offset_y_);
std::cout << "DoTrace..." << std::endl;
} else {
unsigned int a = blockSize_x_ * (dimx_ / 16);
unsigned int b = dimx_ - a;
dim3 dimBlock(blockSize_x_, blockSize_y_);
dim3 dimGrid(a*(nz-1) / dimBlock.x, a / dimBlock.y);
gpu_raytracer(d_radiologicalDepth_, d_CT_dataset_,
(dimGrid.x / dimz), blockSize_x_, blockSize_y_,
offset_x_, offset_y_);
blockSize_x_ = b; blockSize_y_ = b;
offset_x_ = a; offset_y_ = a;
dimBlock(blockSize_x_, blockSize_y_);
dimGrid((b*dimz_) / dimBlock.x, b / dimBlock.y);
gpu_raytracer(d_radiologicalDepth_, d_CT_dataset_,
(dimGrid.x / dimz), blockSize_x_, blockSize_y_,
offset_x_, offset_y_);
blockSize_x_ = b; blockSize_y_ = a;
offset_x_ = a; offset_y_ = 0;
dimBlock(blockSize_x_, blockSize_y_);
dimGrid(1*dimz / dimBlock.x, a / dimBlock.y);
gpu_raytracer(d_radiologicalDepth_, d_CT_dataset_,
(dimGrid.x / dimz), blockSize_x_, blockSize_y_,
offset_x_, offset_y_);
blockSize_x_ = a; blockSize_y_ = b;
offset_x_ = 0; offset_y_ = a;
dimBlock(blockSize_x_, blockSize_y_);
dimGrid(a*dimz / dimblock.x, 1);
gpu_raytracer(d_radiologicalDepth_, d_CT_dataset_,
(dimGrid.x / dimz), blockSize_x_, blockSize_y_,
offset_x_, offset_y_);
}
thanks
Jordy