Use "CUDA_SAFE_CALL" and not use

I have a wonder that how different if we use “CUDA_SAFE_CALL(…)”; and not use that
Does anybody knows, please tell me.
thank you very much.

CUDA_SAFE_CALL() is a preprocessor macro that is defined in header file. You should be able to find it and see what it actually expands to. Then you will know the difference.

I’ve had a look at it, and there is also another called CUT_SAFE_CALL, which seems to be used whenever a function call starts with “cut” instead of “cuda”. For example:

CUDA_SAFE_CALL ( cudaGetDevice (&device) );

CUT_SAFE_CALL ( cutStartTimer (*timer) );

If you look in the header ./NVIDIA_CUDA_SDK/common/inc/cutil.h for these two, then you’ll see that one is used with functions that return cudaError values and the other with CUTBoolean. Both of these are defined in the cutil.h file.

#  define CUDA_SAFE_CALL_NO_SYNC( call) do {                                \

    cudaError err = call;                                                    \

    if( cudaSuccess != err) {                                                \

        fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",        \

                __FILE__, __LINE__, cudaGetErrorString( err) );              \

        exit(EXIT_FAILURE);                                                  \

    } } while (0)

#  define CUDA_SAFE_CALL( call) do {                                        \

    CUDA_SAFE_CALL_NO_SYNC(call);                                            \

    cudaError err = cudaThreadSynchronize();                                 \

    if( cudaSuccess != err) {                                                \

        fprintf(stderr, "Cuda error in file '%s' in line %i : %s.\n",        \

                __FILE__, __LINE__, cudaGetErrorString( err) );              \

        exit(EXIT_FAILURE);                                                  \

    } } while (0)

and

#  define CUT_SAFE_CALL( call)                                              \

    if( CUTTrue != call) {                                                   \

        fprintf(stderr, "Cut error in file '%s' in line %i.\n",              \

                __FILE__, __LINE__);                                         \

        exit(EXIT_FAILURE);                                                  \

    }

Assuming that they use the same naming convention, then you should use the functions accordingly (i.e. cut with CUT and cuda with CUDA). Of course, I don’t know that this is the case, but it seems like a logical assumption. You’d have to look through the cutil.h header file to see what the functions return.

It would be nice if NVIDIA made an API for this library so you don’t have to go digging through the source code. Hope that helps.

Craig