当前位置: 首页>>代码示例>>C++>>正文


C++ errcheck函数代码示例

本文整理汇总了C++中errcheck函数的典型用法代码示例。如果您正苦于以下问题:C++ errcheck函数的具体用法?C++ errcheck怎么用?C++ errcheck使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了errcheck函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的errcheck函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。