11 #include <thrust\device_vector.h>
12 #include <thrust\host_vector.h>
13 #include "cuda_runtime.h"
14 #include "device_launch_parameters.h"
16 #define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164062
18 #pragma warning (disable : 4267)
21 #if defined (__APPLE__) || defined(MACOSX)
22 #include <OpenGL/gl.h>
23 #include <OpenGL/glu.h>
27 # define WINDOWS_LEAN_AND_MEAN
37 #define CUDA_ERROR_CHECK
41 #define printf mexPrintf
44 #define BLOCK_SIZE 512
46 #define CudaSafeCall( err ) __cudaSafeCall( err, FILE, __LINE__ )
47 #define CudaCheckError() __cudaCheckError( FILE, __LINE__ )
48 #define SdkCheckErrorGL() __sdkCheckErrorGL( FILE, __LINE__)
50 #define FILE (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
52 __inline
size_t gridSize(
size_t num){
53 return (
size_t)ceil(((
float)(num))/((
float)(BLOCK_SIZE)));
56 inline void __cudaSafeCall( cudaError err,
const char *file,
const int line )
58 #ifdef CUDA_ERROR_CHECK
59 if ( cudaSuccess != err )
61 printf(
"CUDA Function Error at %s:%i : %s\n",
62 file, line, cudaGetErrorString( err ) );
70 inline void __cudaCheckError(
const char *file,
const int line )
72 #ifdef CUDA_ERROR_CHECK
73 cudaError errCuda = cudaGetLastError();
74 if ( cudaSuccess != errCuda ){
75 std::ostringstream err; err <<
"CUDA Kernel Error at " << file <<
":" << line <<
" : " << cudaGetErrorString(errCuda);
76 mexErrMsgTxt(err.str().c_str());
93 inline void __sdkCheckErrorGL(
const char *file,
const int line){
96 GLenum gl_error = glGetError();
98 if (gl_error != GL_NO_ERROR)
101 printf(
"GL Error at %s:%i : %s\n", file, line, gluErrorString(gl_error));