Skip to content

Commit 5534860

Browse files
committed
added error handling for bspline z-dir
1 parent 005a4ba commit 5534860

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/algorithm/bsplineZdir.cuh

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,15 @@ __global__ void bsplineZdir(T *image, PixelDataDim dim, BsplineParamsCuda p, boo
129129
* Function for launching a kernel
130130
*/
131131
template<typename T>
132-
void runBsplineZdir(T *cudaImage, PixelDataDim dim, BsplineParamsCuda &p, cudaStream_t aStream) {
132+
void runBsplineZdir(T *cudaImage, PixelDataDim dim, BsplineParamsCuda &p, bool *error, cudaStream_t aStream) {
133133
constexpr int numOfWorkersYdir = 128;
134134
dim3 threadsPerBlockZ(1, numOfWorkersYdir, 1);
135135
dim3 numBlocksZ(1,
136136
(dim.y + threadsPerBlockZ.y - 1) / threadsPerBlockZ.y,
137137
(dim.x + threadsPerBlockZ.x - 1) / threadsPerBlockZ.x);
138138
// In case of error this will be set to true by one of the kernels (CUDA does not guarantee which kernel will set global variable if more then one kernel
139139
// access it but this is enough for us to know that somewhere in one on more kernels overflow was detected.
140-
bool isErrorDetected = false;
141-
{
142-
ScopedCudaMemHandler<bool*, H2D | D2H> error(&isErrorDetected, 1, aStream);
143-
bsplineZdir<T> <<<numBlocksZ, threadsPerBlockZ, 0, aStream>>> (cudaImage, dim, p, error.get());
144-
}
145-
146-
if (isErrorDetected) {
147-
throw std::invalid_argument("integer under-/overflow encountered in CUDA bsplineZdir - "
148-
"try squashing the input image to a narrower range or use APRConverter<float>");
149-
}
140+
bsplineZdir<T> <<<numBlocksZ, threadsPerBlockZ, 0, aStream>>> (cudaImage, dim, p, error);
150141
}
151142

152143
#endif

0 commit comments

Comments
 (0)