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); } }
void sine_mod_amp(QSP_ARG_DECL int nframes,float *phases,int period,float *envelope,const char *lutstem) { float amps[MAX_COMPS]; float arginc; float factor; char str[32]; int i,j; arginc = (float)(8*atan(1)/period); for(i=0;i<nframes;i++){ sprintf(str,"%s%d",lutstem,i); if( new_colormap(QSP_ARG str) == NO_OBJ ) NERROR1("error creating LUT buffer"); if( envelope != ((float *)NULL) ) factor=envelope[i]; else factor=1; for(j=0;j<n_comps;j++){ #ifdef SINE_TBL amps[j]=(float)(factor*t_sin(phases[j])); #else /* ! SINE_TBL */ amps[j]=(float)(factor*sin(phases[j])); #endif /* ! SINE_TBL */ phases[j]+=arginc; } set_comp_amps(QSP_ARG amps); index_alpha(i,0,255); } }
void get_camera_features( PGR_Cam *pgcp ) { Node *np; int i; if ( /*dc1394_get_camera_feature_set*/ dc1394_feature_get_all( pgcp->pc_cam_p, &pgcp->pc_features ) != DC1394_SUCCESS ) { NERROR1("get_camera_features: unable to get camera feature set"); } /* Now can the table and build the linked list */ /* We may call this again after we have diddled the controls... */ /* releasing and rebuilding the list is wasteful, but should work... */ if( pgcp->pc_feat_lp != NULL ){ while( (np=remHead(pgcp->pc_feat_lp)) != NULL ) rls_node(np); } else { pgcp->pc_feat_lp = new_list(); } for(i=0;i<DC1394_FEATURE_NUM;i++){ dc1394feature_info_t * f; f = &pgcp->pc_features.feature[i]; assert( f->id >= DC1394_FEATURE_MIN && f->id <= DC1394_FEATURE_MAX ); if(f->available){ np = mk_node(f); addTail(pgcp->pc_feat_lp,np); } } }
Dictionary *create_dictionary(const char *name) { Dictionary *dict_p; dict_p=(Dictionary *) getbuf(sizeof(*dict_p)); if( dict_p==NULL ) { NERROR1("create_dictionary: out of memory"); IOS_RETURN_VAL(NULL) }
static void prepare_image_for_mapping(Data_Obj *dp) { #ifdef HAVE_OPENGL int t; cudaError_t e; // unmap buffer before using w/ GL if( BUF_IS_MAPPED(dp) ){ e = cudaGLUnmapBufferObject( OBJ_BUF_ID(dp) ); if( e != cudaSuccess ){ describe_cuda_driver_error2("update_cuda_viewer", "cudaGLUnmapBufferObject",e); NERROR1("failed to unmap buffer object"); } CLEAR_OBJ_FLAG_BITS(dp, DT_BUF_MAPPED); // propagate change to children and parents propagate_flag(dp,DT_BUF_MAPPED); } // //bind_texture(OBJ_DATA_PTR(dp)); glClear(GL_COLOR_BUFFER_BIT); /* sprintf(ERROR_STRING,"update_cuda_viewer: tex_id = %d, buf_id = %d", OBJ_TEX_ID(dp),OBJ_BUF_ID(dp)); advise(ERROR_STRING); */ glBindTexture(GL_TEXTURE_2D, OBJ_TEX_ID(dp)); #ifdef HAVE_LIBGLEW glBindBuffer(GL_PIXEL_UNPACK_BUFFER, OBJ_BUF_ID(dp)); #endif // HAVE_LIBGLEW #ifdef FOOBAR switch(OBJ_COMPS(dp)){ /* what used to be here??? */ } #endif /* FOOBAR */ t=gl_pixel_type(dp); glTexSubImage2D(GL_TEXTURE_2D, 0, // target, level 0, 0, // x0, y0 OBJ_COLS(dp), OBJ_ROWS(dp), // dx, dy t, GL_UNSIGNED_BYTE, // type OFFSET(0)); // offset into PIXEL_UNPACK_BUFFER #ifdef HAVE_LIBGLEW glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); #endif // HAVE_LIBGLEW }
void show_panel(QSP_ARG_DECL Panel_Obj *po) { #ifdef HAVE_MOTIF if( PANEL_MAPPED(po) ){ sprintf(ERROR_STRING,"show_panel: panel %s is already mapped!?",PO_NAME(po)); WARN(ERROR_STRING); return; } // On the mac (and linux???), when we unshow, and re-show a panel, // it moves down by the thickness of the top of the window??? posn_panel(po); /* if widget has already been realized, then just map it; otherwise realize it and set the flag */ if (!(po->po_realized)) { XtRealizeWidget(po->po_frame_obj); po->po_realized = 1; #ifdef FOOBAR /* This must be the first time we see this thing - lets * reset the positions of all the screen objects... */ lp=po->po_children; np=lp->l_head; while(np!=NO_NODE){ sop=np->n_data; if( sop != NULL ){ reposition(sop); } np=np->n_next; } #endif /* FOOBAR */ } else { XtMapWidget(po->po_frame_obj); } /* Now wait until it really is mapped */ #ifdef CAUTIOUS if( ! XtIsRealized(po->po_frame_obj) ) NERROR1("CAUTIOUS: show_panel: object not realized!?"); #endif /* CAUTIOUS */ /* get the window id */ while( ! panel_mapped(po) ) ; po->po_flags |= PANEL_SHOWN; #endif /* HAVE_MOTIF */ } /* end show_panel */
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 freeinit(FreeList *list, count_t n_elts, u_long ntotal) /* list = pointer to the list to be initialized */ /* n_elts = number of elements in the list */ /* ntotal = number of free blocks that the list represents */ { count_t i; FreeBlk *blkp; list->fl_n_blocks = n_elts; list->fl_blockp = (FreeBlk *) malloc( n_elts * sizeof(FreeBlk) ); if( list->fl_blockp == NULL ){ NERROR1("freeinit: can't malloc FreeBlk list"); IOS_RETURN }
void sort_table(void) { int i; qsort(&polh_cmds[0],N_PH_CMD_CODES,sizeof(polh_cmds[0]),phc_cmp); /* now verify */ for(i=0;i<N_PH_CMD_CODES;i++){ if( polh_cmds[i].pc_code != i ){ sprintf(DEFAULT_ERROR_STRING,"Polhemus command table entry %d has code %d!?", i,polh_cmds[i].pc_code); NERROR1(DEFAULT_ERROR_STRING); } } }
static int gl_pixel_type(Data_Obj *dp) { int t; switch(OBJ_COMPS(dp)){ case 1: t = GL_LUMINANCE; break; /* 2 is allowable, but what do we do with it? */ case 3: t = GL_BGR; break; case 4: t = GL_BGRA; break; default: t=0; // quiet compiler NERROR1("bad pixel depth!?"); break; } return(t); }
void float_init_rowlist(float **list, Data_Obj *dp) { unsigned i; float *fbase; fbase = ((float *)OBJ_DATA_PTR(dp)); fbase --; /* for numrec fortran indices */ if( OBJ_ROWS(dp) > MAX_DIM ){ sprintf(DEFAULT_ERROR_STRING,"Sorry, object %s has %d rows but MAX_DIM is %d", OBJ_NAME(dp),OBJ_ROWS(dp),MAX_DIM); NERROR1(DEFAULT_ERROR_STRING); } for(i=0;i<OBJ_ROWS(dp);i++) *list++ = fbase + i*OBJ_ROW_INC(dp); /* ??? *dp->dt_pinc; */ }
void freeinit(FreeList *list, count_t n_elts, u_long ntotal) /* list = pointer to the list to be initialized */ /* n_elts = number of elements in the list */ /* ntotal = number of free blocks that the list represents */ { count_t i; FreeBlk *blkp; list->fl_n_blocks = n_elts; // We don't use getbuf here, because our private implementation of getbuf // uses freelists... list->fl_blockp = (FreeBlk *) malloc( n_elts * sizeof(FreeBlk) ); if( list->fl_blockp == NULL ){ NERROR1("freeinit: can't malloc FreeBlk list"); IOS_RETURN }
void show_gpu_vector(QSP_ARG_DECL Platform_Device *pdp, void *ptr, int len ) { // BUG we assume float type!? float *buf; size_t siz; int i; siz= len*sizeof(float); buf=malloc(siz); if( buf==NULL ) NERROR1("show_gpu_vector: error allocating buffer!?"); fprintf(stderr,"show_gpu_vector: src = 0x%lx\n",(long)ptr); // now do the memory transfer (*PF_MEM_DNLOAD_FN(PFDEV_PLATFORM(pdp)))(QSP_ARG buf, ptr, siz, 0, pdp ); for(i=0;i<len;i++){ fprintf(stderr,"%d\t%g\n",i,buf[i]); } free(buf); }
void _set_container_type(QSP_ARG_DECL Container *cnt_p, int type) { assert(type!=0); // This code used to be add_type_to_container switch(type){ case LIST_CONTAINER: cnt_p->cnt_lp = new_list(); break; case HASH_TBL_CONTAINER: cnt_p->cnt_htp = ht_init(NULL); break; case RB_TREE_CONTAINER: cnt_p->cnt_tree_p = create_rb_tree(); break; default: // could be assertion? sprintf(DEFAULT_ERROR_STRING,"add_type_to_container: Invalid container type code %d",type); NERROR1(DEFAULT_ERROR_STRING); break; } }
// This is the normal display path static void update_pf_viewer(QSP_ARG_DECL Platform_Viewer *pvp, Data_Obj *dp) { #ifdef HAVE_OPENGL int t; //cudaError_t e; // unmap buffer before using w/ GL if( BUF_IS_MAPPED(dp) ){ if( (*PF_UNMAPBUF_FN(PFDEV_PLATFORM(OBJ_PFDEV(dp)))) (QSP_ARG dp) < 0 ) { WARN("update_pf_viewer: buffer unmap error!?"); } #ifdef FOOBAR e = cudaGLUnmapBufferObject( OBJ_BUF_ID(dp) ); if( e != cudaSuccess ){ describe_cuda_driver_error2("update_pf_viewer", "cudaGLUnmapBufferObject",e); NERROR1("failed to unmap buffer object"); } #endif // FOOBAR CLEAR_OBJ_FLAG_BITS(dp, DT_BUF_MAPPED); // propagate change to children and parents propagate_flag(dp,DT_BUF_MAPPED); } // //bind_texture(OBJ_DATA_PTR(dp)); glClear(GL_COLOR_BUFFER_BIT); /* sprintf(ERROR_STRING,"update_pf_viewer: tex_id = %d, buf_id = %d", OBJ_TEX_ID(dp),OBJ_BUF_ID(dp)); advise(ERROR_STRING); */ glBindTexture(GL_TEXTURE_2D, OBJ_TEX_ID(dp)); // is glBindBuffer REALLY part of libGLEW??? //#ifdef HAVE_LIBGLEW glBindBuffer(GL_PIXEL_UNPACK_BUFFER, OBJ_BUF_ID(dp)); //#endif // HAVE_LIBGLEW #ifdef FOOBAR switch(OBJ_COMPS(dp)){ /* what used to be here??? */ } #endif /* FOOBAR */ t=gl_pixel_type(dp); glTexSubImage2D(GL_TEXTURE_2D, 0, // target, level 0, 0, // x0, y0 OBJ_COLS(dp), OBJ_ROWS(dp), // dx, dy t, GL_UNSIGNED_BYTE, // type OFFSET(0)); // offset into PIXEL_UNPACK_BUFFER //#ifdef HAVE_LIBGLEW glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); //#endif // HAVE_LIBGLEW glBegin(GL_QUADS); glTexCoord2f(0, 1); glVertex2f(-1.0, -1.0); glTexCoord2f(0, 0); glVertex2f(-1.0, 1.0); glTexCoord2f(1, 0); glVertex2f(1.0, 1.0); glTexCoord2f(1, 1); glVertex2f(1.0, -1.0); glEnd(); glBindTexture(GL_TEXTURE_2D, 0); #ifdef FOOBAR e = cudaGLMapBufferObject( &OBJ_DATA_PTR(dp), OBJ_BUF_ID(dp) ); if( e != cudaSuccess ){ WARN("Error mapping buffer object!?"); // should we return now, with possibly other cleanup??? } #endif // FOOBAR if( (*PF_MAPBUF_FN(PFDEV_PLATFORM(OBJ_PFDEV(dp))))(QSP_ARG dp) < 0 ){ WARN("update_pf_viewer: Error mapping buffer!?"); } SET_OBJ_FLAG_BITS(dp, DT_BUF_MAPPED); // propagate change to children and parents propagate_flag(dp,DT_BUF_MAPPED); #else // ! HAVE_OPENGL NO_OGL_MSG #endif // ! HAVE_OPENGL }
void h_cu2_iftrows( HOST_CALL_ARG_DECLS ) { NERROR1("Sorry, h_cu2_iftrows not implemented!?"); }
void h_cu2_fft2d( HOST_CALL_ARG_DECLS ) { NERROR1("Sorry, h_cu2_fft2d not implemented!?"); }
static void _init_gcrypt_subsystem(SINGLE_QSP_ARG_DECL) { const char *s; gcry_error_t status; void *key; int key_len; s=gcry_check_version(GCRYPT_VERSION); if( !s ){ // mismatch means wrong dynamic library sprintf(ERROR_STRING, "Expected libgcrypt version %s!?", GCRYPT_VERSION); warn(ERROR_STRING); NERROR1("libgcrypt version mismatch!?"); } if( verbose ){ sprintf(ERROR_STRING,"libgcrypt version %s",s); advise(ERROR_STRING); } #ifdef USE_SECURE_MEMORY /* We don't want to see any warnings, e.g. because we have not yet * parsed program options which might be used to suppress such * warnings. */ advise("libgcrypt will use secure memory..."); gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN); /* ... If required, other initialization goes here. Note that the * process might still be running with increased privileges and that * the secure memory has not been intialized. */ /* Allocate a pool of 16k secure memory. This make the secure memory * available and also drops privileges where needed. */ gcry_control (GCRYCTL_INIT_SECMEM, 16384, 0); /* It is now okay to let Libgcrypt complain when there was/is * a problem with the secure memory. */ gcry_control (GCRYCTL_RESUME_SECMEM_WARN); /* ... If required, other initialization goes here. */ /* Tell Libgcrypt that initialization has completed. */ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #else /* ! USE_SECURE_MEMORY */ //advise("libgcrypt will NOT use secure memory..."); // This initialization assumes that the environment // is secure, so that secure memory does not need to // be used for key storage... /* Disable secure memory. */ gcry_control (GCRYCTL_DISABLE_SECMEM, 0); /* ... If required, other initialization goes here. */ /* Tell Libgcrypt that initialization has completed. */ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); #endif /* ! USE_SECURE_MEMORY */ /* self-test fails on euler!? */ status = gcry_control (GCRYCTL_SELFTEST); CHECK_STATUS(init_gcrypt_subsystem,GCRYCTL_SELFTEST) status = gcry_md_open(&my_hash_hdl,the_hash_algo, the_hash_flags); CHECK_STATUS(init_gcrypt_subsystem,gcry_md_open) /* Now initialize for encryption */ status = gcry_cipher_open( &my_cipher_handle, the_crypt_algo,the_crypt_mode,the_crypt_flags); CHECK_STATUS(init_gcrypt_subsystem,gcry_cipher_open) // to release: // gcry_cipher_close(my_cipher_handle); /* get the key */ init_my_symm_key(&key); key_len = encryption_key_size(); status = gcry_cipher_setkey(my_cipher_handle,key,key_len); CHECK_STATUS(init_gcrypt_subsystem,gcry_cipher_setkey) // status = gcry_cipher_setiv(my_cipher_handle,iv,iv_len); // status = gcry_cipher_reset(my_cipher_handle); }
int start_firewire_transmission(QSP_ARG_DECL PGR_Cam * pgcp, int _ring_buffer_size ) { int i; dc1394error_t err; Data_Obj *dp; //advise("start_firewire_transmission BEGIN"); /* older version had third flags arg... */ //advise("calling dc1394_capture_setup"); if( (err=dc1394_capture_setup(pgcp->pc_cam_p,_ring_buffer_size ,DC1394_CAPTURE_FLAGS_DEFAULT )) != DC1394_SUCCESS ) { WARN("dc1394_capture_setup failed!?"); describe_dc1394_error( QSP_ARG err ); if( err == DC1394_IOCTL_FAILURE ){ advise("Try decreasing the number of ring buffer frames requested?"); return -1; } fprintf( stderr,"unable to setup camera-\n" "check line %d of %s to make sure\n" "that the video mode and framerate are\n" "supported by your camera\n", __LINE__,__FILE__ ); /* fprintf( stderr, "video_mode = %d, framerate = %d\n" "Check dc1394_control.h for the meanings of these values\n", pgcp->pc_video_mode, pgcp->pc_framerate ); */ fprintf( stderr, "video_mode = %s (%d), framerate = %s (%d)\n", name_for_video_mode(pgcp->pc_video_mode), pgcp->pc_video_mode, name_for_framerate(pgcp->pc_framerate), pgcp->pc_framerate ); NERROR1("error starting capture"); return(-1); } pgcp->pc_ring_buffer_size = _ring_buffer_size; pgcp->pc_n_avail = _ring_buffer_size; pgcp->pc_flags |= PGR_CAM_IS_CAPTURING; #ifdef FOOBAR // we set this in the script already!? sprintf(msg_str,"%d",ring_buffer_size); /* tell the scripting language */ assign_var("ring_buffer_size",msg_str); #endif // FOOBAR // have the camera start sending us data //advise("calling dc1394_video_set_transmission"); if( (err=dc1394_video_set_transmission( pgcp->pc_cam_p, DC1394_ON )) != DC1394_SUCCESS ) { WARN("Unable to start camera iso transmission"); describe_dc1394_error( QSP_ARG err ); // do we need to undo capture_setup? dc1394_capture_stop( pgcp->pc_cam_p ); pgcp->pc_flags &= ~PGR_CAM_IS_CAPTURING; return(-1); } pgcp->pc_flags |= PGR_CAM_IS_TRANSMITTING; // Sleep untill the camera has a transmission dc1394switch_t status = DC1394_OFF; for ( i = 0; i <= 5; i++ ) { usleep(50000); //advise("calling dc1394_video_get_transmission"); if ( dc1394_video_get_transmission( pgcp->pc_cam_p, &status ) != DC1394_SUCCESS ) { fprintf( stderr, "Unable to get transmision status\n" ); return(-1); } if ( status != DC1394_OFF ) break; if( i == 5 ) { fprintf(stderr,"Camera doesn't seem to want to turn on!\n"); return(-1); } } //advise("start_firewire_transmission DONE"); // Now make sure that we have the frame objects... dp = dobj_of("_frame1"); if( dp == NULL ) init_buffer_objects(QSP_ARG pgcp); return(0); }
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 */ }
void push_parent(Screen_Obj *mp) { parent_index++; if( parent_index >= MAX_STACK ) NERROR1("parent stack full"); curr_parent=parent_stack[parent_index]=mp; }
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 }