Tuesday, 15 April 2014

c++ - cudaMalloc setting errno despite returning cudaSuccess -



c++ - cudaMalloc setting errno despite returning cudaSuccess -

currently reason cudamalloc setting errno 17, despite returning cudasuccess. have been scouring net google foo has not brought enlightenment me, have decided inquire stack overflow people.

here output

error: not going down, errstr: success, errno 0 error: going on here?, errstr: file exists, errno 17

and here code (some of @ least)

//headers #define checkerror(message) { fprintf(stderr,"error: %s, errstr: %s, errno %i\n",message,strerror(errno),errno); } while(0); #define cudasafecall( err ) __cudasafecall( err, __file__, __line__ ) #define array_length ( 1000000 ) #define array_element_size ( sizeof(int) ) #define array_size ( (size_t)array_element_size * array_length ) inline void __cudasafecall( cudaerror err, const char *file, const int line ) { if ( cudasuccess != err ) { fprintf( stderr, "cudasafecall() failed @ %s:%i : %s\n", file, line, cudageterrorstring( err ) ); exit( -1 ); } return; } int main(int argc,char* argv[]) { ..... other code ...... int *device_array; checkerror("what not going on here."); cudasafecall(cudamalloc((void**)&device_array,array_size)); checkerror("what going on here?"); ..... other code ...... }

does have anyidea might going on here? right array_size set 4 million, same issue shows when 400.

you seem assuming errno must 0 if previous function returned no error.

this not case.

errno not required set 0 if previous function successful.

from linux man page:

its value important when homecoming value of phone call indicated error

and

a function succeeds allowed alter errno.

in case, previous function (whatever was, in case cudamalloc or scheme function called cudamalloc library routine) successful. hence contents of errno variable not significant.

c++ cuda runtime-error gpu-programming

No comments:

Post a Comment