本文整理汇总了C++中errcheck函数的典型用法代码示例。如果您正苦于以下问题:C++ errcheck函数的具体用法?C++ errcheck怎么用?C++ errcheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了errcheck函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: room_goto_previous
int room_goto_previous()
{
enigma::roomstruct *rit = enigma::roomdata[(int)room.rval.d];
errcheck((int)room.rval.d,"Going to next room from invalid room. wat");
rit = enigma::roomorder[rit->order - 1];
errcheck(rit->order-1,"Going to next room after last");
rit->gotome();
return 0;
}
开发者ID:tyrovc,项目名称:enigma-dev,代码行数:11,代码来源:roomsystem.cpp
示例2: room_goto_previous
int room_goto_previous()
{
enigma::roomstruct *rit = enigma::roomdata[(int)room.rval.d];
errcheck((int)room.rval.d,"Going to next room from invalid room. wat", 0);
rit = enigma::roomorder[rit->order - 1];
errcheck(rit->order-1,"Going to next room after last", 0);
enigma::room_switching_id = rit->id;
enigma::room_switching_restartgame = false;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:12,代码来源:roomsystem.cpp
示例3: cuda_over_map
Object cuda_over_map(Object self, int nparts, int *argcv,
Object *argv, int flags) {
CUresult error;
cuInit(0);
int deviceCount = 0;
error = cuDeviceGetCount(&deviceCount);
if (deviceCount == 0) {
raiseError("No CUDA devices found");
}
CUdevice cuDevice;
CUcontext cuContext;
CUmodule cuModule;
CUfunction cuFunc;
error = cuDeviceGet(&cuDevice, 0);
error = cuCtxCreate(&cuContext, 0, cuDevice);
CUdeviceptr d_A;
CUdeviceptr d_B;
CUdeviceptr d_res;
errcheck(cuModuleLoad(&cuModule, grcstring(argv[argcv[0]])));
CUdeviceptr dps[argcv[0]];
void *args[argcv[0]+2];
int size = INT_MAX;
for (int i=0; i<argcv[0]; i++) {
struct CudaFloatArray *a = (struct CudaFloatArray *)argv[i];
if (a->size < size)
size = a->size;
errcheck(cuMemAlloc(&dps[i], size * sizeof(float)));
errcheck(cuMemcpyHtoD(dps[i], &a->data, size * sizeof(float)));
args[i+1] = &dps[i];
}
struct CudaFloatArray *r =
(struct CudaFloatArray *)(alloc_CudaFloatArray(size));
int fsize = sizeof(float) * size;
errcheck(cuMemAlloc(&d_res, fsize));
errcheck(cuMemcpyHtoD(d_res, &r->data, fsize));
args[0] = &d_res;
args[argcv[0]+1] = &size;
int threadsPerBlock = 256;
int blocksPerGrid = (size + threadsPerBlock - 1) / threadsPerBlock;
char name[256];
strcpy(name, "block");
strcat(name, grcstring(argv[argcv[0]]) + strlen("_cuda/"));
for (int i=0; name[i] != 0; i++)
if (name[i] == '.') {
name[i] = 0;
break;
}
errcheck(cuModuleGetFunction(&cuFunc, cuModule, name));
errcheck(cuLaunchKernel(cuFunc, blocksPerGrid, 1, 1,
threadsPerBlock, 1, 1,
0,
NULL, args, NULL));
errcheck(cuMemcpyDtoH(&r->data, d_res, fsize));
cuMemFree(d_res);
for (int i=0; i<argcv[0]; i++)
cuMemFree(dps[i]);
return (Object)r;
}
开发者ID:mwh,项目名称:grace-cuda,代码行数:59,代码来源:cuda.c
示例4: room_goto
int room_goto(int indx)
{
errcheck(indx,"Attempting to go to nonexisting room", 0);
enigma::room_switching_id = indx;
enigma::room_switching_restartgame = false;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:7,代码来源:roomsystem.cpp
示例5: THInit
void THInit()
{
static int init;
if(init)
return;
init_yuv2rgb();
#ifndef USEBLAS
blas_init();
#endif
init = 1;
#if defined CUDNN && defined USECUDAHOSTALLOC
// cuda_maphostmem = 1 requires that memory was allocated with cudaHostAlloc
// cuda_maphostmem = 2 will work with malloc, but Tegra TX1 does not support cudaHostRegister with cudaHostRegisterMapped
struct cudaDeviceProp prop;
cudaGetDeviceProperties(&prop, 0);
if(prop.canMapHostMemory)
{
errcheck(cudaSetDeviceFlags(cudaDeviceMapHost));
cuda_maphostmem = 1;
}
#endif
#ifdef OPENCL
thopencl_init();
#endif
}
开发者ID:Aerobota,项目名称:thnets,代码行数:27,代码来源:thapi.c
示例6: room_restart
int room_restart()
{
int indx=(int)room.rval.d;
errcheck(indx,"Is this some kind of joke?");
enigma::roomdata[indx]->gotome();
return 0;
}
开发者ID:tyrovc,项目名称:enigma-dev,代码行数:7,代码来源:roomsystem.cpp
示例7: room_tile_add_ext
int room_tile_add_ext(int indx, int bck, int left, int top, int width, int height, int x, int y, int depth, int xscale, int yscale, double alpha, int color)
{
errcheck(indx,"Nonexistent room", 0);
enigma::roomstruct *rm = enigma::roomdata[indx];
const int tcount = rm->tilecount++;
enigma::tile *ti = rm->tiles;
enigma::tile *newtiles = new enigma::tile[tcount + 1];
for (int tilei = 0; tilei < tcount; tilei++)
newtiles[tilei] = ti[tilei];
newtiles[tcount].id = enigma::maxtileid++;
newtiles[tcount].bckid = bck;
newtiles[tcount].bgx = left;
newtiles[tcount].bgy = top;
newtiles[tcount].depth = depth;
newtiles[tcount].height = height;
newtiles[tcount].width = width;
newtiles[tcount].roomX = x;
newtiles[tcount].roomY = y;
newtiles[tcount].xscale = xscale;
newtiles[tcount].yscale = yscale;
newtiles[tcount].alpha = alpha;
newtiles[tcount].color = color;
if (enigma::tile_alter) delete[] rm->tiles;
rm->tiles = newtiles;
enigma::tile_alter = true;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:29,代码来源:roomsystem.cpp
示例8: room_set_background_color
int room_set_background_color(int indx, int col, bool show)
{
errcheck(indx,"Nonexistent room", 0);
enigma::roomdata[indx]->backcolor = col;
enigma::roomdata[indx]->drawbackcolor = show;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:7,代码来源:roomsystem.cpp
示例9: room_restart
int room_restart()
{
int indx=(int)room.rval.d;
errcheck(indx, "Is this some kind of joke?", 0);
enigma::room_switching_id = indx;
enigma::room_switching_restartgame = false;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:8,代码来源:roomsystem.cpp
示例10: errcheck
THFloatTensor *cudnn_Threshold_updateOutput(struct module *module, THFloatTensor *input)
{
THFloatTensor *output = module->output;
cudnnTensorDescriptor_t dinput, doutput;
int inplace = module->Threshold.inplace;
float one = 1, zero = 0;
errcheck(THcudnn_TensorDescriptor(&dinput, input));
if(inplace)
THFloatTensor_set(output, input);
else THCudaTensor_resize4d(output, input->size[0], input->size[1], input->size[2], input->size[3]);
errcheck(THcudnn_TensorDescriptor(&doutput, output));
errcheck(cudnnActivationForward(THcudnn_getHandle(), CUDNN_ACTIVATION_RELU, &one, dinput, THFloatTensor_data(input), &zero,
doutput, THFloatTensor_data(output)));
cudnnDestroyTensorDescriptor(dinput);
cudnnDestroyTensorDescriptor(doutput);
return output;
}
开发者ID:Aerobota,项目名称:thnets,代码行数:20,代码来源:cudnn_Threshold.c
示例11: room_instance_clear
int room_instance_clear(int indx)
{
errcheck(indx,"Nonexistent room", 0);
enigma::roomstruct *rm = enigma::roomdata[indx];
enigma::inst *newinst = new enigma::inst[1];
rm->instancecount = 0;
if (enigma::instance_alter) delete[] rm->instances;
rm->instances = newinst;
enigma::instance_alter = true;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:12,代码来源:roomsystem.cpp
示例12: room_tile_clear
int room_tile_clear(int indx)
{
errcheck(indx,"Nonexistent room", 0);
enigma::roomstruct *rm = enigma::roomdata[indx];
enigma::tile *newtiles = new enigma::tile[1];
rm->tilecount = 0;
if (enigma::tile_alter) delete[] rm->tiles;
rm->tiles = newtiles;
enigma::tile_alter = true;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:12,代码来源:roomsystem.cpp
示例13: errcheck
THFloatTensor *cudnn_SpatialMaxPooling_updateOutput(struct module *module, THFloatTensor *input)
{
int kW = module->SpatialMaxPooling.kW;
int kH = module->SpatialMaxPooling.kH;
int dW = module->SpatialMaxPooling.dW;
int dH = module->SpatialMaxPooling.dH;
int padW = module->SpatialMaxPooling.padW;
int padH = module->SpatialMaxPooling.padH;
THFloatTensor *output = module->output;
cudnnTensorDescriptor_t dinput, doutput;
cudnnPoolingDescriptor_t dpool;
float one = 1, zero = 0;
int sizes[4];
errcheck(THcudnn_TensorDescriptor(&dinput, input));
errcheck(cudnnCreatePoolingDescriptor(&dpool));
errcheck(cudnnSetPooling2dDescriptor(dpool, CUDNN_POOLING_MAX, kH, kW, padH, padW, dH, dW));
errcheck(cudnnGetPoolingNdForwardOutputDim(dpool, dinput, 4, sizes));
THCudaTensor_resize4d(output, sizes[0], sizes[1], sizes[2], sizes[3]);
errcheck(THcudnn_TensorDescriptor(&doutput, output));
errcheck(cudnnPoolingForward(THcudnn_getHandle(), dpool, &one, dinput, THFloatTensor_data(input), &zero,
doutput, THFloatTensor_data(output)));
cudnnDestroyTensorDescriptor(dinput);
cudnnDestroyTensorDescriptor(doutput);
cudnnDestroyPoolingDescriptor(dpool);
return output;
}
开发者ID:Aerobota,项目名称:thnets,代码行数:30,代码来源:cudnn_SpatialMaxPooling.c
示例14: main
int main(int argc, char* argv[])
{
if (argc !=4)
usage();
string hostsFile=argv[1];
ifstream diff(argv[2]);
port = (unsigned short)atoi(argv[3]);
if (diff.fail()) {
cerr << "error: open diff file" << endl;
usage();
}
if (verbose) cout << "Reading diff..." << endl;
assert(readChanges(diff));
if (verbose) cout << "Reading core info..." << endl;
assert(getCores(hostsFile));
diff.close();
if (verbose) cout << "Getting addresses..."<<endl;
errcheck(getAddrs());
if (verbose) cout << "Constructing stage data..."<<endl;
errcheck(makeStages());
if (verbose) cout << "Opening connections..." << endl;
errcheck(initConnections());
if (verbose) cout << "Transferring stage data..." << endl;
errcheck(sendStages());
int i;
for (i=0;i<3;i++) {
if (verbose) cout << "Doing stage " << i << "..."<<endl;
errcheck(doStage(i));
}
if (verbose) cout << "Closing connections..." <<endl;
errcheck(finishConnections());
if (verbose) cout<<"Reassign complete."<<endl;
}
开发者ID:arjunroy,项目名称:modelnet-core,代码行数:34,代码来源:reassign.cpp
示例15: execute
Cell *arith(Node **a, int n) /* a[0] + a[1], etc. also -a[0] */
{
Awkfloat i, j = 0;
double v;
Cell *x, *y, *z;
x = execute(a[0]);
i = getfval(x);
tempfree(x);
if (n != UMINUS) {
y = execute(a[1]);
j = getfval(y);
tempfree(y);
}
z = gettemp();
switch (n) {
case ADD:
i += j;
break;
case MINUS:
i -= j;
break;
case MULT:
i *= j;
break;
case DIVIDE:
if (j == 0)
ERROR "division by zero" FATAL;
i /= j;
break;
case MOD:
if (j == 0)
ERROR "division by zero in mod" FATAL;
modf(i/j, &v);
i = i - j * v;
break;
case UMINUS:
i = -i;
break;
case POWER:
if (j >= 0 && modf(j, &v) == 0.0) /* pos integer exponent */
i = ipow(i, (int) j);
else
i = errcheck(pow(i, j), "pow");
break;
default: /* can't happen */
ERROR "illegal arithmetic operator %d", n FATAL;
}
setfval(z, i);
return(z);
}
开发者ID:ajallooeian,项目名称:libawkcpp,代码行数:51,代码来源:run.c
示例16: room_set_background
int room_set_background(int indx, int bind, bool vis, bool fore, bool back, double x, double y, bool htiled, bool vtiled, double hspeed, double vspeed, double alpha, int color)
{
errcheck(indx,"Nonexistent room", 0);
enigma::backstruct &bk = enigma::roomdata[indx]->backs[bind];
bk.visible = vis;
bk.foreground = fore;
bk.background = back;
bk.area_x = x;
bk.area_y = y;
bk.tileHor = htiled;
bk.tileVert = vtiled;
bk.horSpeed = hspeed;
bk.verSpeed = vspeed;
bk.alpha = alpha;
bk.color = color;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:17,代码来源:roomsystem.cpp
示例17: assert
real rnk3ccrdata::updatecrt(direction dir,vind varind,partialdata* newdtpnt,bool& reliable,const double tol,const double rqbound) const
{
partialrnk3ccrdata *newdata = static_cast<partialrnk3ccrdata *>(newdtpnt);
/* Attention: newdtpnt MUST point to partialrnk3ccrdata object !!!
For safety, in debug mode use the alternative code with dynamic_cast and assert */
/* partialrnk3ccrdata *newdata = dynamic_cast<partialrnk3ccrdata *>(pdt);
assert(newdata); */
real newwilksst,newbartpist,newccr12;
real e1 = (*emat)(varind,varind);
real *tv = newdata->getlhtmpv(),hei1,*rpl[4];
real newlawhotst = lawhotst;
updatest(newwilksst,newbartpist,varind,newdata,reliable,tol);
for (vind i=0;i<3;i++) {
hei1 = heinv[i][varind];
rpl[i] = &(tv[i] = hei1 / e1);
newlawhotst += tv[i]*hei1;
}
#ifdef COUNTING
fpcnt1 += 6;
#endif
if (reliable) {
rpl[3] = &newlawhotst;
reliable = errcheck(rpl,tol,4);
}
if (dir==forward) newdata->nvar=nvar+1 ;
else newdata->nvar=nvar-1;
if (newdata->nvar == 1) newccr12 = newbartpist;
else if (newdata->nvar == 2)
newccr12 = 0.5 * ( newbartpist + std::sqrt(static_cast<real>(newbartpist*newbartpist -4.*(newbartpist+newwilksst-1.))) );
else newccr12 = findccr12(newwilksst,newbartpist,newlawhotst,rqbound);
newdata->setlawhot(newlawhotst);
newdata->setcrt(newccr12);
return newccr12;
}
开发者ID:cran,项目名称:subselect,代码行数:43,代码来源:Rnk3CCRcrt.cpp
示例18: room_set_view
int room_set_view(int indx, int vind, int vis, int xview, int yview, int wview, int hview, int xport, int yport, int wport, int hport, int hborder, int vborder, int hspeed, int vspeed, int obj)
{
errcheck(indx,"Nonexistent room", 0);
enigma::viewstruct &vw = enigma::roomdata[indx]->views[vind];
vw.start_vis = vis;
vw.area_x = xview;
vw.area_y = yview;
vw.area_w = wview;
vw.area_h = hview;
vw.port_x = xport;
vw.port_y = yport;
vw.port_w = wport;
vw.port_h = hport;
vw.hborder = hborder;
vw.vborder = vborder;
vw.hspd = hspeed;
vw.vspd = vspeed;
vw.object2follow = obj;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:20,代码来源:roomsystem.cpp
示例19: room_instance_add
int room_instance_add(int indx, int x, int y, int obj)
{
errcheck(indx,"Nonexistent room", 0);
enigma::roomstruct *rm = enigma::roomdata[indx];
const int icount = rm->instancecount++;
enigma::inst *in = rm->instances;
enigma::inst *newinst = new enigma::inst[icount + 1];
for (int insti = 0; insti < icount; insti++)
newinst[insti] = in[insti];
newinst[icount].id = enigma::maxid++;
newinst[icount].x = x;
newinst[icount].y = y;
newinst[icount].obj = obj;
if (enigma::instance_alter) delete[] rm->instances;
rm->instances = newinst;
enigma::instance_alter = true;
return 1;
}
开发者ID:Heathtech,项目名称:enigma-dev,代码行数:20,代码来源:roomsystem.cpp
示例20: BDAddDirectory
tBitmapDirectory* BDAddDirectory(
Widget w,
String directory,
tBitmapDirectory *bd) {
DIR *dir;
struct dirent *dp;
struct stat statbuf;
char fullfilename[BUFSIZE];
dir = (DIR *)errcheck_ptr(opendir(directory), NULL, directory);
for(dp = readdir(dir); dp; dp = readdir(dir))
if(dp->d_name[0] != '.') { /* Ignore files starting with '.' */
sprintf(fullfilename, "%s/%s", directory, dp->d_name);
stat(fullfilename, &statbuf);
if(statbuf.st_mode & S_IFDIR)
/* Subdirectory, so add it... */
bd = BDAddDirectory(w, fullfilename, bd);
else
bd = AddFile(w, fullfilename, dp->d_name, bd);
}
(void)errcheck((int)closedir(dir), -1, directory);
return(bd);
}
开发者ID:adacapo21,项目名称:TPTrains,代码行数:23,代码来源:BitmapDirectory.c
注:本文中的errcheck函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论