void insure_cu2_device( QSP_ARG_DECL Data_Obj *dp ) { Platform_Device *pdp; if( AREA_FLAGS(OBJ_AREA(dp)) & DA_RAM ){ sprintf(DEFAULT_ERROR_STRING, "insure_cu2_device: Object %s is a host RAM object!?",OBJ_NAME(dp)); NWARN(DEFAULT_ERROR_STRING); return; } pdp = AREA_PFDEV(OBJ_AREA(dp)); #ifdef CAUTIOUS if( pdp == NULL ) NERROR1("CAUTIOUS: null cuda device ptr in data area!?"); #endif /* CAUTIOUS */ if( curr_pdp != pdp ){ sprintf(DEFAULT_ERROR_STRING,"insure_cu2_device: curr_pdp = 0x%lx pdp = 0x%lx", (int_for_addr)curr_pdp,(int_for_addr)pdp); NADVISE(DEFAULT_ERROR_STRING); sprintf(DEFAULT_ERROR_STRING,"insure_cu2_device: current device is %s, want %s", PFDEV_NAME(curr_pdp),PFDEV_NAME(pdp)); NADVISE(DEFAULT_ERROR_STRING); PF_FUNC_NAME(set_device)(QSP_ARG pdp); } }
static Visual *GetEightBitVisual( Disp_Obj * dop) { int visualsMatched=0; Visual *vis; XVisualInfo *vip; int i; vip = get_depth_list(dop,8,&visualsMatched); if( visualsMatched == 0 ) return(NULL); i=find_visual(vip,visualsMatched,PseudoColor,8); if( i < 0 ){ NWARN("no pseudocolor visual found!?"); return(vip[0].visual); } #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(DEFAULT_ERROR_STRING,"using visual %ld",vip[i].visualid); NADVISE(DEFAULT_ERROR_STRING); vis=DefaultVisual(dop->do_dpy,dop->do_screen); sprintf(DEFAULT_ERROR_STRING,"default visual is %ld",vis->visualid); NADVISE(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ return(vip[i].visual); }
void cmap_setup(Viewer *vp) { int i; #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(DEFAULT_ERROR_STRING,"cmap_setup: viewer %s", vp->vw_name); NADVISE(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ /* only create colormap if visual is psuedocolor */ if( VW_DEPTH(vp) == 8 ){ /* NADVISE("xld_setup: creating colormap..."); */ /* we need to create a colormap to be able to write color table entries... * But we might like to initialize to the system's default map, not * our own peculiar map... */ vp->vw_cmap = XCreateColormap(VW_DPY(vp), VW_ROOTW(vp), VW_VISUAL(vp), AllocAll ); } else { if( verbose ) NADVISE("cmap_setup: not creating X colormap for non-pseudocolor display"); return; } SET_VW_XCTBL(vp, (XColor *) getbuf( N_COLORS * sizeof(XColor) ) ); for(i=0;i<N_COLORS;i++) SET_VW_XCTBL_PIXEL(vp,i, (u_long)i ); vp->vw_n_protected_colors = n_to_protect; }
static Visual *GetSpecifiedVisual( Disp_Obj * dop, int depth ) { XVisualInfo * vip; int visualsMatched; int i; const char * name; vip = get_depth_list(dop,depth,&visualsMatched); if( visualsMatched == 0 ) return(NULL); /* We need something more here, for openGL we have multiple visuals w/ 24 bit truecolor, * but not all have a Z buffer... * As a hack, we pass the desired visualID through the environment... */ { char *s; s=getenv("PREFERRED_VISUAL_ID"); if( s != NULL ){ int preferred_id; sprintf(DEFAULT_ERROR_STRING,"Checking for PREFERRED_VISUAL_ID %s",s); NADVISE(DEFAULT_ERROR_STRING); preferred_id = atoi(s); /* BUG decimal only, should parse hex too */ i=find_visual_by_id(vip,visualsMatched,preferred_id); if( i >= 0 ){ sprintf(DEFAULT_ERROR_STRING,"preferred visual id %d FOUND at index %d",preferred_id,i); NADVISE(DEFAULT_ERROR_STRING); return(vip[i].visual); } sprintf(DEFAULT_ERROR_STRING,"Unable to find requested visual id %d",preferred_id); NWARN(DEFAULT_ERROR_STRING); } } i=find_visual(vip,visualsMatched,PREFERRED_MODE,depth); if( i < 0 ){ sprintf(DEFAULT_ERROR_STRING,"no %s visual found with depth %d!?", PREFERRED_NAME,depth); NWARN(DEFAULT_ERROR_STRING); i=find_visual(vip,visualsMatched,ALTERNATE_MODE,depth); if( i < 0 ){ sprintf(DEFAULT_ERROR_STRING,"no %s visual found with depth %d!?", ALTERNATE_NAME,depth); NWARN(DEFAULT_ERROR_STRING); return(vip[0].visual); } else { name = ALTERNATE_NAME; } } else { name = PREFERRED_NAME; } if( verbose ){ sprintf(DEFAULT_ERROR_STRING,"i=%d, using visual %ld (%s, depth = %d)", i, vip[i].visualid,name,depth); NADVISE(DEFAULT_ERROR_STRING); } return(vip[i].visual); }
static float get_start_val(Data_Obj *source,Data_Obj *control,dimension_t index) { float *f,*c,sum; int i=0; f = (float *)OBJ_DATA_PTR(source); f += index*OBJ_PXL_INC(source); c = (float *)OBJ_DATA_PTR(control); c += index*OBJ_PXL_INC(control); sum = 0.0; while( (((int)index)-i) >= 0 && *c == 1.0 && i < max_avg ){ sum += *f; f -= OBJ_PXL_INC(source); c -= OBJ_PXL_INC(control); i++; } #ifdef DEBUG if( debug ){ sprintf(DEFAULT_ERROR_STRING,"get_start_val: index = %d n = %d sum = %f",index,i,sum); NADVISE(DEFAULT_ERROR_STRING); } #endif sum /= i; return(sum); }
static void text_func2(Widget textID, XtPointer app_data, XtPointer widget_data ) { Screen_Obj *sop; const char *s; QSP_DECL INIT_MOTIF_QSP sop=find_object(DEFAULT_QSP_ARG textID); #ifdef CAUTIOUS if( sop == NO_SCREEN_OBJ ){ WARN("CAUTIOUS: text_func: couldn't locate text widget"); return; } #endif /* CAUTIOUS */ s = get_text(sop); if( s == NULL ) ASSIGN_RESERVED_VAR("input_string","(null)"); else { ASSIGN_RESERVED_VAR("input_string",s); free((void *)s); } NADVISE("text_func2 calling chew_text..."); chew_text(DEFAULT_QSP_ARG sop->so_action_text,"(text2 event)"); } // text_func2
static void text_func(Widget textID, XtPointer app_data, XtPointer widget_data ) { Screen_Obj *sop; const char *s; sop=find_object(DEFAULT_QSP_ARG textID); #ifdef CAUTIOUS if( sop == NO_SCREEN_OBJ ){ NWARN("CAUTIOUS: text_func: couldn't locate text widget"); return; } #endif /* CAUTIOUS */ s = get_text(sop); if( s == NULL ) assign_reserved_var( SOB_QSP_ARG "input_string","(null)"); else { assign_reserved_var( SOB_QSP_ARG "input_string",s); free((void *)s); } /* We should chew the text when a return is typed, or something? */ NADVISE("text_func calling chew_text..."); chew_text(DEFAULT_QSP_ARG sop->so_action_text,"(text event)"); } // text_func
static XVisualInfo *get_depth_list( Disp_Obj * dop, int depth, int *np ) { XVisualInfo vTemplate; /* try to get an 8 bit psuedocolor visual */ /* taken from Xlib prog manual p. 215 */ vTemplate.depth=depth; vTemplate.screen=dop->do_screen; if( visualList != NULL ) XFree(visualList); visualList = XGetVisualInfo(dop->do_dpy,VisualScreenMask|VisualDepthMask, &vTemplate,np); if( visualList == NULL ){ sprintf(DEFAULT_ERROR_STRING, "get_depth_list(%d) got NULL from XGetVisualInfo!?",depth); NWARN(DEFAULT_ERROR_STRING); } #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(DEFAULT_ERROR_STRING,"%d visuals found with depth %d",*np,depth); NADVISE(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ return(visualList); }
void set_curr_win(Window win) { #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(DEFAULT_ERROR_STRING,"set_curr_win: setting current window to 0x%lx",(u_long)win); NADVISE(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ curr_window = win; }
void w_set_error_rate(double er) { if( er < 0 ){ NWARN("error rate must be non-negative"); return; } else if( er >= 1 ){ NWARN("error rate cannot be >= 1"); return; } else if( er < MIN_DELTA ){ if( verbose ){ sprintf(DEFAULT_ERROR_STRING, "Setting error rate to minimum permissable value: %g", MIN_DELTA); NADVISE(DEFAULT_ERROR_STRING); } er = MIN_DELTA; } error_rate=er; }
void dp_choldc(Data_Obj *a_dp, Data_Obj *p_dp) { unsigned m, n; void *a_rowlist[MAX_DIM]; /* n=OBJ_ROWS(a_dp); if( n > MAX_DIM ){ NWARN("Sorry, MAX dimension exceeded in dp_choldc"); sprintf(DEFAULT_ERROR_STRING,"dp_choldc: MAX_DIM = %d, n = %d", MAX_DIM,n); NADVISE(DEFAULT_ERROR_STRING); return; } */ n=OBJ_COLS(a_dp); m=OBJ_ROWS(a_dp); if( n > MAX_DIM || m > MAX_DIM ){ NWARN("Sorry, MAX dimension exceeded in dp_choldc"); sprintf(DEFAULT_ERROR_STRING,"dp_choldc: MAX_DIM = %d, n = %d, m = %d", MAX_DIM,n,m); NADVISE(DEFAULT_ERROR_STRING); return; } printf("nrmenu:numrec.c data %f\n", *((float *)OBJ_DATA_PTR(a_dp))); if( OBJ_MACH_PREC(a_dp) == PREC_SP ){ float_init_rowlist((float **)(void *)a_rowlist,a_dp); float_choldc(((float **)(void *)a_rowlist)-1,n,((float *)OBJ_DATA_PTR(p_dp))-1); } else if( OBJ_MACH_PREC(a_dp) == PREC_DP ){ double_init_rowlist((double **)(void *)a_rowlist,a_dp); double_choldc(((double **)(void *)a_rowlist)-1,n,((double *)OBJ_DATA_PTR(p_dp))-1); } else { NWARN("bad machine precision in dp_choldc"); } }
static XVisualInfo *get_vis_list( Disp_Obj * dop, int *np ) { XVisualInfo vTemplate; vTemplate.screen=dop->do_screen; if( visualList != NULL ) XFree(visualList); visualList = XGetVisualInfo(dop->do_dpy,VisualScreenMask, &vTemplate,np); #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(DEFAULT_ERROR_STRING,"%d visuals found",*np); NADVISE(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ return(visualList); }
static void glew_check() { #ifdef HAVE_LIBGLEW static int glew_checked=0; if( glew_checked ){ if( verbose ) NADVISE("glew_check: glew already checked."); return; } // BUG glewInit will core dump if GL is not already initialized!? // We try to fix this by making sure that the cuda viewer is already // specified for GL before calling this... glewInit(); if (!glewIsSupported( "GL_VERSION_1_5 GL_ARB_vertex_buffer_object GL_ARB_pixel_buffer_object" )) { /* fprintf(stderr, "Error: failed to get minimal extensions for demo\n"); fprintf(stderr, "This sample requires:\n"); fprintf(stderr, " OpenGL version 1.5\n"); fprintf(stderr, " GL_ARB_vertex_buffer_object\n"); fprintf(stderr, " GL_ARB_pixel_buffer_object\n"); */ /* cudaThreadExit(); exit(-1); */ NERROR1("glew_check: Please create a GL window before specifying a cuda viewer."); } glew_checked=1; #else // ! HAVE_LIBGLEW NERROR1("glew_check: libglew not present!?."); #endif // ! HAVE_LIBGLEW }
void dp_svd(Data_Obj *a_dp, Data_Obj *w_dp, Data_Obj *v_dp) { unsigned m,n; void *a_rowlist[MAX_DIM], *v_rowlist[MAX_DIM]; n=OBJ_COLS(a_dp); m=OBJ_ROWS(a_dp); if( n > MAX_DIM || m > MAX_DIM ){ NWARN("Sorry, MAX dimension exceeded in dp_svd"); sprintf(DEFAULT_ERROR_STRING,"dp_svdcmp: MAX_DIM = %d, n = %d, m = %d", MAX_DIM,n,m); NADVISE(DEFAULT_ERROR_STRING); return; } /* if( m < n ){ sprintf(DEFAULT_ERROR_STRING,"dp_svdcmp: input matrix %s (%d x %d) cannot be wider than tall!?", OBJ_NAME(a_dp),m,n); NWARN(DEFAULT_ERROR_STRING); return; } */ if( OBJ_COLS(w_dp) != n ){ sprintf(DEFAULT_ERROR_STRING,"dp_svdcmp: weight vector %s should have %d columns, to match input matrix %s!?", OBJ_NAME(w_dp),n,OBJ_NAME(a_dp)); NWARN(DEFAULT_ERROR_STRING); return; } if(OBJ_ROWS(w_dp) != 1 ){ sprintf(DEFAULT_ERROR_STRING,"dp_svdcmp: weight vector %s should be a vector, (rows = %d)!?", OBJ_NAME(w_dp),OBJ_ROWS(w_dp)); NWARN(DEFAULT_ERROR_STRING); return; } if( OBJ_COLS(v_dp) != n || OBJ_ROWS(v_dp) != n ){ sprintf(DEFAULT_ERROR_STRING, "V matrix %s should be square with dimension %d, to match # columns of input %s", OBJ_NAME(v_dp),n,OBJ_NAME(a_dp)); NWARN(DEFAULT_ERROR_STRING); return; } /* BUG make sure all vectors have same precision */ if( OBJ_MACH_PREC(a_dp) == PREC_SP ){ float_init_rowlist((float **)(void *)a_rowlist,a_dp); float_init_rowlist((float **)(void *)v_rowlist,v_dp); //advise("calling float_svdcmp"); float_svdcmp(((float **)(void *)a_rowlist)-1,m,n,((float *)OBJ_DATA_PTR(w_dp))-1,((float **)(void *)v_rowlist)-1); //advise("back from float_svdcmp"); /* The eigenvectors aren't sorted by numerical recipes... */ //float_sort_svd_eigenvectors(a_dp,w_dp,v_dp); } else if( OBJ_MACH_PREC(a_dp) == PREC_DP ){ double_init_rowlist((double **)(void *)a_rowlist,a_dp); double_init_rowlist((double **)(void *)v_rowlist,v_dp); //advise("calling double_svdcmp"); double_svdcmp(((double **)(void *)a_rowlist)-1,m,n,((double *)OBJ_DATA_PTR(w_dp))-1,((double **)(void *)v_rowlist)-1); //advise("back from double_svdcmp"); /* The eigenvectors aren't sorted by numerical recipes... */ //double_sort_svd_eigenvectors(a_dp,w_dp,v_dp); } else { NWARN("bad machine precision in dp_svd"); } }
static int dop_setup( QSP_ARG_DECL Disp_Obj *dop, int desired_depth) { XVisualInfo vinfo, *list; int n; dop->do_screen = DefaultScreen(dop->do_dpy); dop->do_rootw = RootWindow(dop->do_dpy,dop->do_screen); dop->do_currw = RootWindow(dop->do_dpy,dop->do_screen); #ifdef HAVE_OPENGL dop->do_ctx = NULL; #endif /* HAVE_OPENGL */ #ifdef QUIP_DEBUG if( debug & xdebug ){ XWindowAttributes wa; XGetWindowAttributes(dop->do_dpy,dop->do_rootw,&wa); sprintf(DEFAULT_ERROR_STRING,"depth of root window = %d", wa.depth); prt_msg(DEFAULT_ERROR_STRING); } #endif /* QUIP_DEBUG */ dop->do_gc = DefaultGC(dop->do_dpy,dop->do_screen); if( verbose ){ sprintf(DEFAULT_ERROR_STRING,"desired depth is %d",desired_depth); NADVISE(DEFAULT_ERROR_STRING); } if( desired_depth == 8 ){ dop->do_visual = GetEightBitVisual(dop); } else if( desired_depth == 24 ){ dop->do_visual = Get24BitVisual(dop); } else if( desired_depth == 16 ){ dop->do_visual = Get16BitVisual(dop); } else { dop->do_visual = DefaultVisual(dop->do_dpy,dop->do_screen); } if( dop->do_visual == 0 ){ if( verbose ) NADVISE("initial attempt to get a visual failed"); } /* BUG? can't we do something better here? */ if( dop->do_visual == 0 && desired_depth == 8 ){ /* this works on powerbook */ dop->do_visual = Get15BitVisual(dop); } if( dop->do_visual == 0 && desired_depth == 8 ){ /* this works on durer... */ dop->do_visual = Get16BitVisual(dop); } if( dop->do_visual == 0 ){ /* couldn't find anything !? */ if( verbose ){ int nvis,i; XVisualInfo * vlp; vlp=get_vis_list(dop,&nvis); sprintf(DEFAULT_ERROR_STRING,"%d visuals found:",nvis); NADVISE(DEFAULT_ERROR_STRING); for(i=0;i<nvis;i++){ sprintf(DEFAULT_ERROR_STRING,"class %d depth %d", vlp[i].xvi_class,vlp[i].depth); NADVISE(DEFAULT_ERROR_STRING); } } return(-1); } /* remember the depth of this visual - do we still need to do this? */ vinfo.visualid = XVisualIDFromVisual(dop->do_visual); list = XGetVisualInfo(dop->do_dpy,VisualIDMask,&vinfo,&n); if( n != 1 ){ NWARN("more than one visual with specified ID!?"); dop->do_depth = 8; } else { dop->do_depth = list[0].depth; } XFree(list); dop->do_width = DisplayWidth(dop->do_dpy,dop->do_screen); dop->do_height = DisplayHeight(dop->do_dpy,dop->do_screen); #ifdef QUIP_DEBUG if( debug & xdebug ){ sprintf(msg_str,"display %s, %d by %d, %d bits deep", dop->do_name,dop->do_width,dop->do_height,dop->do_depth); prt_msg(msg_str); } #endif /* QUIP_DEBUG */ return(0); }
void describe_cuda_error(const char *whence, CUresult e) { // CUresult e2; switch(e){ case CUDA_SUCCESS: sprintf(DEFAULT_ERROR_STRING,"%s: No errors.",whence); NADVISE(DEFAULT_ERROR_STRING); break; #if CUDA_VERSION >= 6050 RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_GRAPHICS_CONTEXT,"Invalid graphics context") #endif #if CUDA_VERSION > 4000 RUNTIME_ERROR_CASE(CUDA_ERROR_PEER_ACCESS_UNSUPPORTED,"Peer access unsupported") RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_PTX,"Invalid PTX") RUNTIME_ERROR_CASE(CUDA_ERROR_ILLEGAL_ADDRESS,"Illegal address") RUNTIME_ERROR_CASE(CUDA_ERROR_ASSERT,"Assertion error") RUNTIME_ERROR_CASE(CUDA_ERROR_TOO_MANY_PEERS,"Too many peers") RUNTIME_ERROR_CASE(CUDA_ERROR_HOST_MEMORY_ALREADY_REGISTERED,"Host mem already registered") RUNTIME_ERROR_CASE(CUDA_ERROR_HOST_MEMORY_NOT_REGISTERED,"Host mem not registered") RUNTIME_ERROR_CASE(CUDA_ERROR_HARDWARE_STACK_ERROR,"H/W stack error") RUNTIME_ERROR_CASE(CUDA_ERROR_ILLEGAL_INSTRUCTION,"Illegal instruction"); RUNTIME_ERROR_CASE(CUDA_ERROR_MISALIGNED_ADDRESS,"Misaligned address") RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_ADDRESS_SPACE,"Invalid address space") RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_PC,"Invalid PC") RUNTIME_ERROR_CASE(CUDA_ERROR_NOT_PERMITTED,"Not permitted") RUNTIME_ERROR_CASE(CUDA_ERROR_NOT_SUPPORTED,"Not supported") #endif // CUDA_VERSION > 4000 RUNTIME_ERROR_CASE(CUDA_ERROR_LAUNCH_FAILED,"Launch failed") RUNTIME_ERROR_CASE(CUDA_ERROR_UNKNOWN,"Unknown error") RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_DEVICE , "Invalid device." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NO_DEVICE , "No device" ) RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_VALUE , "Invalid value." ) RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_IMAGE,"Invalid Image") RUNTIME_ERROR_CASE(CUDA_ERROR_INVALID_CONTEXT,"Invalid context") #ifdef CUDA_ERROR_NVLINK_UNCORRECTABLE RUNTIME_ERROR_CASE(CUDA_ERROR_NVLINK_UNCORRECTABLE,"uncorrectable NVLink error") #endif // CUDA_ERROR_NVLINK_UNCORRECTABLE //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_PITCH_VALUE , "Invalid pitch value." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_SYMBOL , "Invalid symbol." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_MAP_OBJECT_FAILED , "Map buffer object failed." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_UNMAP_OBJECT_FAILED , "Unmap buffer object failed." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_HOST_POINTER , "Invalid host pointer." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_DEVICE_POINTER , "Invalid device pointer." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_TEXTURE , "Invalid texture." ) //RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_TEXTURE_BINDING , "Invalid texture binding." ) RUNTIME_ERROR_CASE( CUDA_ERROR_OUT_OF_MEMORY , "out of memory." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_INITIALIZED , "not initialized." ) RUNTIME_ERROR_CASE( CUDA_ERROR_DEINITIALIZED , "de-initialized." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PROFILER_DISABLED , "profiler is disabled." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PROFILER_NOT_INITIALIZED , "profiler not initialized." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PROFILER_ALREADY_STARTED , "profiler already started." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PROFILER_ALREADY_STOPPED , "profiler already stopped." ) RUNTIME_ERROR_CASE( CUDA_ERROR_CONTEXT_ALREADY_CURRENT , "context already current." ) RUNTIME_ERROR_CASE( CUDA_ERROR_MAP_FAILED , "mapping failure." ) RUNTIME_ERROR_CASE( CUDA_ERROR_UNMAP_FAILED , "unmapping failure." ) RUNTIME_ERROR_CASE( CUDA_ERROR_ARRAY_IS_MAPPED , "array is mapped and cannot be destroyed." ) RUNTIME_ERROR_CASE( CUDA_ERROR_ALREADY_MAPPED , "already mapped." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NO_BINARY_FOR_GPU , "no binary for GPU." ) RUNTIME_ERROR_CASE( CUDA_ERROR_ALREADY_ACQUIRED , "resource already acquired." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_MAPPED , "resource not mapped." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_MAPPED_AS_ARRAY , "not mapped as array." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_MAPPED_AS_POINTER , "not mapped as pointer." ) RUNTIME_ERROR_CASE( CUDA_ERROR_ECC_UNCORRECTABLE , "uncorrectable ECC error." ) RUNTIME_ERROR_CASE( CUDA_ERROR_UNSUPPORTED_LIMIT , "unsupported limit." ) RUNTIME_ERROR_CASE( CUDA_ERROR_CONTEXT_ALREADY_IN_USE , "context already in use." ) RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_SOURCE , "invalide device kernel source." ) RUNTIME_ERROR_CASE( CUDA_ERROR_FILE_NOT_FOUND , "file not found." ) RUNTIME_ERROR_CASE( CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND , "shared object symbol not found." ) RUNTIME_ERROR_CASE( CUDA_ERROR_SHARED_OBJECT_INIT_FAILED , "shared object init failed." ) RUNTIME_ERROR_CASE( CUDA_ERROR_OPERATING_SYSTEM , "OS call failed." ) RUNTIME_ERROR_CASE( CUDA_ERROR_INVALID_HANDLE , "invalid handle." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_FOUND , "named symbol not found." ) RUNTIME_ERROR_CASE( CUDA_ERROR_NOT_READY , "async operation not completed (not an error)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES , "launch out of resources)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_LAUNCH_TIMEOUT , "launch timeout)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING , "incompatible texturing)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED , "peer access already enabled)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PEER_ACCESS_NOT_ENABLED , "peer access not enabled)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_CONTEXT_IS_DESTROYED , "current context has been destroyed)." ) RUNTIME_ERROR_CASE( CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE , "primary context already initialized)." ) #ifdef FOOBAR //CUDA_RUNTIME_ERROR( cudaErrorECCUncorrectable , "Uncorrectable ECC error detected." ) CUDA_RUNTIME_ERROR( cudaErrorStartupFailure , "Startup failure." ) #endif // FOOBAR default: sprintf(DEFAULT_ERROR_STRING, "%s: unrecognized cuda error code %d",whence,e); NWARN(DEFAULT_ERROR_STRING); break; } #ifdef FOOBAR e2 = cudaGetLastError(); // clear error #ifdef CAUTIOUS if( e2 != e ){ NERROR1("CAUTIOUS: describe_cuda_error: errors do not match!?"); } #endif /* CAUTIOUS */ #endif // FOOBAR }
void describe_cuda_driver_error(const char *whence, cudaError_t e) { cudaError_t e2; switch(e){ DRIVER_ERROR_CASE(cudaSuccess,"No driver errors") #if CUDA_VERSION >= 6050 DRIVER_ERROR_CASE(cudaErrorInvalidGraphicsContext,"Invalid graphics context") DRIVER_ERROR_CASE( cudaErrorInvalidPtx , "Invalid PTX." ) #endif DRIVER_ERROR_CASE( cudaErrorInvalidDevice , "Invalid device." ) DRIVER_ERROR_CASE( cudaErrorInvalidValue , "Invalid value." ) DRIVER_ERROR_CASE( cudaErrorInvalidPitchValue , "Invalid pitch value." ) DRIVER_ERROR_CASE( cudaErrorInvalidSymbol , "Invalid symbol." ) DRIVER_ERROR_CASE( cudaErrorMapBufferObjectFailed , "Map buffer object failed." ) DRIVER_ERROR_CASE( cudaErrorUnmapBufferObjectFailed , "Unmap buffer object failed." ) DRIVER_ERROR_CASE( cudaErrorInvalidHostPointer , "Invalid host pointer." ) DRIVER_ERROR_CASE( cudaErrorInvalidDevicePointer , "Invalid device pointer." ) DRIVER_ERROR_CASE( cudaErrorInvalidTexture , "Invalid texture." ) DRIVER_ERROR_CASE( cudaErrorInvalidTextureBinding , "Invalid texture binding." ) DRIVER_ERROR_CASE( cudaErrorInvalidChannelDescriptor , "Invalid channel descriptor." ) DRIVER_ERROR_CASE( cudaErrorInvalidMemcpyDirection , "Invalid memcpy direction." ) DRIVER_ERROR_CASE( cudaErrorAddressOfConstant , "Address of constant error." ) DRIVER_ERROR_CASE( cudaErrorTextureFetchFailed , "Texture fetch failed." ) DRIVER_ERROR_CASE( cudaErrorTextureNotBound , "Texture not bound error." ) DRIVER_ERROR_CASE( cudaErrorSynchronizationError , "Synchronization error." ) DRIVER_ERROR_CASE( cudaErrorInvalidResourceHandle , "Invalid resource handle." ) DRIVER_ERROR_CASE( cudaErrorNotReady , "Not ready error." ) DRIVER_ERROR_CASE( cudaErrorInsufficientDriver , "CUDA runtime is newer than driver." ) DRIVER_ERROR_CASE( cudaErrorSetOnActiveProcess , "Set on active process error." ) DRIVER_ERROR_CASE( cudaErrorNoDevice , "No available CUDA device." ) DRIVER_ERROR_CASE( cudaErrorMissingConfiguration , "Missing configuration error." ) DRIVER_ERROR_CASE( cudaErrorMemoryAllocation, "Memory allocation error." ) DRIVER_ERROR_CASE( cudaErrorInitializationError , "Initialization error." ) DRIVER_ERROR_CASE( cudaErrorLaunchFailure , "Launch failure." ) DRIVER_ERROR_CASE( cudaErrorPriorLaunchFailure , "Prior launch failure." ) DRIVER_ERROR_CASE( cudaErrorLaunchTimeout , "Launch timeout error." ) DRIVER_ERROR_CASE( cudaErrorLaunchOutOfResources , "Launch out of resources error." ) DRIVER_ERROR_CASE( cudaErrorInvalidDeviceFunction , "Invalid device function." ) DRIVER_ERROR_CASE( cudaErrorInvalidConfiguration , "Invalid configuration." ) DRIVER_ERROR_CASE( cudaErrorInvalidFilterSetting , "Invalid filter setting." ) DRIVER_ERROR_CASE( cudaErrorInvalidNormSetting , "Invalid norm setting." ) DRIVER_ERROR_CASE(cudaErrorMixedDeviceExecution,"Mixed device execution") DRIVER_ERROR_CASE(cudaErrorCudartUnloading,"CUDA runtime unloading") DRIVER_ERROR_CASE(cudaErrorUnknown,"Unknown error condition") DRIVER_ERROR_CASE(cudaErrorNotYetImplemented,"Function not yet implemented") DRIVER_ERROR_CASE(cudaErrorMemoryValueTooLarge,"Memory value too large") DRIVER_ERROR_CASE(cudaErrorInvalidSurface,"Invalid surface") DRIVER_ERROR_CASE(cudaErrorECCUncorrectable,"ECC uncorrectable") DRIVER_ERROR_CASE(cudaErrorSharedObjectSymbolNotFound,"Shared object symbol not found") DRIVER_ERROR_CASE(cudaErrorSharedObjectInitFailed,"Shared object init failed") DRIVER_ERROR_CASE(cudaErrorUnsupportedLimit,"Unsupported limit") DRIVER_ERROR_CASE(cudaErrorDuplicateVariableName,"Duplicate variable name") DRIVER_ERROR_CASE(cudaErrorDuplicateTextureName,"Duplicate texture name") DRIVER_ERROR_CASE(cudaErrorDuplicateSurfaceName,"Duplicate surface name") DRIVER_ERROR_CASE(cudaErrorDevicesUnavailable,"Devices unavailable") DRIVER_ERROR_CASE(cudaErrorInvalidKernelImage,"Invalid kernel image") DRIVER_ERROR_CASE(cudaErrorNoKernelImageForDevice,"No kernel image for device") DRIVER_ERROR_CASE(cudaErrorIncompatibleDriverContext,"Incompatible driver context") DRIVER_ERROR_CASE(cudaErrorPeerAccessAlreadyEnabled,"Peer access already enabled") DRIVER_ERROR_CASE(cudaErrorPeerAccessNotEnabled,"Peer access not enabled") DRIVER_ERROR_CASE(cudaErrorDeviceAlreadyInUse,"Device already in use") DRIVER_ERROR_CASE(cudaErrorProfilerDisabled,"Profiler disabled") DRIVER_ERROR_CASE(cudaErrorProfilerNotInitialized,"Profiler not intialized") DRIVER_ERROR_CASE(cudaErrorProfilerAlreadyStarted,"Profiler already started") DRIVER_ERROR_CASE(cudaErrorProfilerAlreadyStopped,"Profiler already stopped") #if CUDA_VERSION > 4000 DRIVER_ERROR_CASE(cudaErrorAssert,"Assertion error") DRIVER_ERROR_CASE(cudaErrorTooManyPeers,"Too many peers") DRIVER_ERROR_CASE(cudaErrorHostMemoryAlreadyRegistered,"Host mem already registered") DRIVER_ERROR_CASE(cudaErrorHostMemoryNotRegistered,"Host memory not registered") DRIVER_ERROR_CASE(cudaErrorOperatingSystem,"OS error") DRIVER_ERROR_CASE(cudaErrorPeerAccessUnsupported,"Peer access unsupported") DRIVER_ERROR_CASE(cudaErrorLaunchMaxDepthExceeded,"Launch max depth exceeded") DRIVER_ERROR_CASE(cudaErrorLaunchFileScopedTex,"Launch file scoped tex") DRIVER_ERROR_CASE(cudaErrorLaunchFileScopedSurf,"Launch file scoped surf") DRIVER_ERROR_CASE(cudaErrorSyncDepthExceeded,"Sync depth exceeded") DRIVER_ERROR_CASE(cudaErrorLaunchPendingCountExceeded,"Launch pending count exceeded") DRIVER_ERROR_CASE(cudaErrorNotPermitted,"Not permitted") DRIVER_ERROR_CASE(cudaErrorNotSupported,"Not supported") DRIVER_ERROR_CASE(cudaErrorHardwareStackError,"H/W Stack Error") DRIVER_ERROR_CASE(cudaErrorIllegalInstruction,"Illegal instruction") DRIVER_ERROR_CASE(cudaErrorMisalignedAddress,"Mis-aligned address") DRIVER_ERROR_CASE(cudaErrorInvalidAddressSpace,"Invalid address space") DRIVER_ERROR_CASE(cudaErrorInvalidPc,"Invalid PC") DRIVER_ERROR_CASE(cudaErrorIllegalAddress,"Illegal address") #endif // CUDA_VERSION > 4000 DRIVER_ERROR_CASE(cudaErrorStartupFailure,"Startup failure") DRIVER_ERROR_CASE(cudaErrorApiFailureBase,"Unexpected driver error") #ifdef WHAT_CUDA_VERSION // need to fix for cuda 6? // not in cuda 6? CUDA_DRIVER_ERROR( CUDA_ERROR_LAUNCH_FAILED , "launch failed)." ) // not in cuda 6? CUDA_DRIVER_ERROR( CUDA_ERROR_UNKNOWN , "unknown error)." ) #endif // WHAT_CUDA_VERSION default: sprintf(DEFAULT_ERROR_STRING, "%s: unrecognized cuda error code %d",whence,e); NWARN(DEFAULT_ERROR_STRING); break; } e2 = cudaGetLastError(); // clear error #ifdef CAUTIOUS if( e2 != e ){ sprintf(DEFAULT_ERROR_STRING, "e = %d (0x%x), cudaGetLastError() = %d (0x%x)",e,e,e2,e2); NADVISE(DEFAULT_ERROR_STRING); NERROR1("CAUTIOUS: describe_cuda_driver_error: errors do not match!?"); } #endif /* CAUTIOUS */ }