Skip to content
Snippets Groups Projects
Commit 3df5aea3 authored by Stephan Seitz's avatar Stephan Seitz
Browse files

Only perform error check if wrapping CUDA functions

parent 67d7f4ae
No related branches found
No related tags found
No related merge requests found
Pipeline #19332 failed
...@@ -156,10 +156,12 @@ def generate_kernel_call(kernel_function): ...@@ -156,10 +156,12 @@ def generate_kernel_call(kernel_function):
KernelFunctionCall(kernel_function), KernelFunctionCall(kernel_function),
CudaErrorCheck(), CudaErrorCheck(),
]) ])
else: elif kernel_function.backend == 'gpucuda':
return pystencils.astnodes.Block([CudaErrorCheck(), return pystencils.astnodes.Block([CudaErrorCheck(),
KernelFunctionCall(kernel_function), KernelFunctionCall(kernel_function),
CudaErrorCheck()]) CudaErrorCheck()])
else:
return pystencils.astnodes.Block([KernelFunctionCall(kernel_function)])
return block return block
...@@ -236,8 +238,8 @@ class CudaErrorCheckDefinition(CustomCodeNode): ...@@ -236,8 +238,8 @@ class CudaErrorCheckDefinition(CustomCodeNode):
function_name = 'gpuErrchk' function_name = 'gpuErrchk'
code = """ code = """
# ifdef __GNUC__ #ifdef __GNUC__
# define gpuErrchk(ans) { gpuAssert((ans), __PRETTY_FUNCTION__, __FILE__, __LINE__); } #define gpuErrchk(ans) { gpuAssert((ans), __PRETTY_FUNCTION__, __FILE__, __LINE__); }
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true) inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
{ {
if (code != cudaSuccess) if (code != cudaSuccess)
...@@ -246,8 +248,8 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char ...@@ -246,8 +248,8 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
if (abort) exit(code); if (abort) exit(code);
} }
} }
# else #else
# define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); } #define gpuErrchk(ans) { gpuAssert((ans), __FILE__, __LINE__); }
inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true) inline static void gpuAssert(cudaError_t code, const char* function, const char *file, int line, bool abort=true)
{ {
if (code != cudaSuccess) if (code != cudaSuccess)
...@@ -256,9 +258,9 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char ...@@ -256,9 +258,9 @@ inline static void gpuAssert(cudaError_t code, const char* function, const char
if (abort) exit(code); if (abort) exit(code);
} }
} }
# endif #endif
""" """
headers = '<cuda.h>' headers = ['<cuda.h>']
class CudaErrorCheck(CustomCodeNode): class CudaErrorCheck(CustomCodeNode):
...@@ -288,3 +290,4 @@ class CudaErrorCheck(CustomCodeNode): ...@@ -288,3 +290,4 @@ class CudaErrorCheck(CustomCodeNode):
err_check_function = CudaErrorCheckDefinition() err_check_function = CudaErrorCheckDefinition()
required_global_declarations = [err_check_function] required_global_declarations = [err_check_function]
headers = ['<cuda.h>']
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment