void _insure_cuda_device(QSP_ARG_DECL Data_Obj *dp ) { Cuda_Device *cdp; if( AREA_FLAGS(OBJ_AREA(dp)) & DA_RAM ){ sprintf(ERROR_STRING, "insure_cuda_device: Object %s is a host RAM object!?",OBJ_NAME(dp)); warn(ERROR_STRING); return; } cdp = (Cuda_Device *) AREA_CUDA_DEV(OBJ_AREA(dp)); assert( cdp != NULL ); if( curr_cdp != cdp ){ sprintf(ERROR_STRING,"insure_cuda_device: curr_cdp = 0x%"PRIxPTR" cdp = 0x%"PRIxPTR, (uintptr_t)curr_cdp,(uintptr_t)cdp); advise(ERROR_STRING); sprintf(ERROR_STRING,"insure_cuda_device: current device is %s, want %s", curr_cdp->cudev_name,cdp->cudev_name); advise(ERROR_STRING); set_cuda_device(cdp); } }
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 COMMAND_FUNC( do_match_area ) { Data_Obj *dp; dp = pick_obj("object"); if( dp == NULL ) return; curr_ap=OBJ_AREA(dp); }
static Data_Obj *insure_ram_obj(QSP_ARG_DECL Data_Obj *dp) { Data_Obj *tmp_dp; char *tname; Data_Area *save_ap; Data_Obj *c_dp=NULL; if( OBJ_IS_RAM(dp) ) return dp; // This object lives on a different platform. // We create a copy in RAM, and download the data // using the platform download function. save_ap = curr_ap; curr_ap = ram_area_p; tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(DNAME_PREFIX) + 1 ); sprintf(tname,"%s%s",DNAME_PREFIX,OBJ_NAME(dp)); tmp_dp = dup_obj(QSP_ARG dp, tname); givbuf(tname); if( tmp_dp == NO_OBJ ){ // This can happen if the object is subscripted, // as the bracket characters are illegal in names return NO_OBJ; } curr_ap = save_ap; // We can't download if the source data is not contiguous... // // We have a problem with bit precision, because the bits can // be non-contiguous when the long words are - any time the number of columns // is not evenly divided by the bits-per-word if( (! IS_CONTIGUOUS(dp)) && ! HAS_CONTIGUOUS_DATA(dp) ){ Vec_Obj_Args oa1, *oap=&oa1; advise("object is not contiguous, and does not have contiguous data..."); longlist(QSP_ARG dp); save_ap = curr_ap; curr_ap = OBJ_AREA( dp ); tname = getbuf( strlen(OBJ_NAME(dp)) + strlen(CNAME_PREFIX) + 1 ); sprintf(tname,"%s%s",CNAME_PREFIX,OBJ_NAME(dp)); c_dp = dup_obj(QSP_ARG dp, tname ); givbuf(tname); curr_ap = save_ap; // Now do the move... setvarg2(oap,c_dp,dp); if( IS_BITMAP(dp) ){ SET_OA_SBM(oap,dp); SET_OA_SRC1(oap,NO_OBJ); } if( IS_REAL(dp) ) /* BUG case for QUAT too? */ OA_ARGSTYPE(oap) = REAL_ARGS; else if( IS_COMPLEX(dp) ) /* BUG case for QUAT too? */ OA_ARGSTYPE(oap) = COMPLEX_ARGS; else if( IS_QUAT(dp) ) /* BUG case for QUAT too? */ OA_ARGSTYPE(oap) = QUATERNION_ARGS; else //ERROR1("CAUTIOUS: insure_ram_obj: bad argset type!?"); assert( AERROR("insure_ram_obj: bad argset type!?") ); //fprintf(stderr,"insure_ram_obj: moving remote data to a contiguous object\n"); call_vfunc( QSP_ARG FIND_VEC_FUNC(FVMOV), oap ); //fprintf(stderr,"insure_ram_obj: DONE moving remote data to a contiguous object\n"); dp = c_dp; } gen_obj_dnload(QSP_ARG tmp_dp, dp); if( c_dp != NO_OBJ ) delvec(QSP_ARG c_dp); // BUG - when to delete? // We try using the VOLATILE flag. This will work as long as // the input object is not VOLATILE!? SET_OBJ_FLAG_BITS(tmp_dp, DT_VOLATILE ) ; return tmp_dp; }