本文整理汇总了C++中CHECK_ERR函数的典型用法代码示例。如果您正苦于以下问题:C++ CHECK_ERR函数的具体用法?C++ CHECK_ERR怎么用?C++ CHECK_ERR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CHECK_ERR函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConvertBack
//convert tensor in MKL layout back to Numpy NCHW layout
//if layout diff, do conversion, else, copy memory directly
void ConvertBack(unsigned long long tensor_, int N, int C, int H, int W)
{
long long * tensor = (long long *)tensor_;
if (tensor[CPUPtr] == 0 )
{
printf("error to converback tensor!\n");
return;
}
if (tensor[MKLLayout] == 0) return;//do not need convert
dnnError_t err;
size_t inSize[DIM4] = { W, H, C, N};
size_t inStride[DIM4] = { 1, W, W*H, W*H*C};
dnnLayout_t lt_NCHW = NULL, lt_CHWN = NULL;
float* newPtr = NULL;
CHECK_ERR( dnnLayoutCreate_F32(<_NCHW, DIM4, inSize, inStride), err );
if (!dnnLayoutCompare_F32((dnnLayout_t)tensor[MKLLayout], (dnnLayout_t)tensor[CPULayout]))
{
float* cpuPtr = (float *)tensor[CPUPtr];
float* mklPtr = (float *)tensor[MKLPtr];
if (!dnnLayoutCompare_F32((dnnLayout_t)tensor[MKLLayout], lt_NCHW))
{
dnnPrimitive_t cv;
CHECK_ERR( dnnConversionCreate_F32(&cv, (dnnLayout_t)tensor[MKLLayout],lt_NCHW), err );
newPtr = (float*)malloc(N*C*H*W*sizeof(float));
CHECK_ERR( dnnConversionExecute_F32(cv, mklPtr, newPtr), err );
mklPtr = newPtr;
}
mkl_somatcopy('r', 't', N, C*H*W, 1.0, mklPtr, C*H*W, cpuPtr, N);
}
else
{
long long grad_in_len = (long long)dnnLayoutGetMemorySize_F32((dnnLayout_t)tensor[MKLLayout]) ;
float * destPtr = (float*)tensor[CPUPtr];
float * srcPtr = (float*)tensor[MKLPtr];
#pragma omp parallel for
for (long long i = 0; i < grad_in_len/4; ++i)
{
destPtr[i] = srcPtr[i];
}
}
ERR_RETURN:
if (newPtr!=NULL)
{
free(newPtr);
}
}
示例2: s5k5bbgx_set_capture_start
static int s5k5bbgx_set_capture_start(struct v4l2_subdev *sd)
{
struct s5k5bbgx_state *state = to_state(sd);
int err = -EINVAL;
u16 val = 1, retry = 0;
/* set initial regster value */
#ifdef CONFIG_LOAD_FILE
err = s5k5bbgx_write_regs_from_sd(sd, "s5k5bbgx_capture");
#else
err = s5k5bbgx_write_regs(sd, s5k5bbgx_capture,
sizeof(s5k5bbgx_capture) / sizeof(s5k5bbgx_capture[0]));
#endif
if (unlikely(err)) {
cam_err("failed to make capture\n");
return err;
}
s5k5bbgx_get_exif(sd);
cam_info("Capture ConfigSync\n");
do {
msleep(20);
err = s5k5bbgx_read_reg(sd, REG_PAGE_CAPTURE_STATUS, REG_ADDR_CAPTURE_STATUS, &val);
CHECK_ERR(err);
cam_dbg("val = %d\n", val);
if (val == 0)
break;
retry++;
} while (retry <= S5K5BBGX_READ_STATUS_RETRIES);
return err;
}
示例3: buildin_string_find
// find
void buildin_string_find(fake * fk, interpreter * inter)
{
BIF_CHECK_ARG_NUM(3);
const char * findstr = fkpspopcstrptr(fk);
int pos = fkpspop<int>(fk);
const char * srcstr = 0;
variant * v = 0;
bool err = false;
PS_POP_AND_GET(fk->ps, v);
V_GET_STRING(v, srcstr);
CHECK_ERR(err);
int len = srcstr ? v->data.str->sz : 0;
if (pos >= 0 && pos < len && srcstr && findstr)
{
const char * find = strstr(srcstr + pos, findstr);
if (find)
{
fkpspush<bool>(fk, true);
fkpspush<int>(fk, (int)(find - srcstr));
}
else
{
fkpspush<bool>(fk, false);
fkpspush<int>(fk, -1);
}
}
else
{
fkpspush<bool>(fk, false);
fkpspush<int>(fk, -1);
}
}
示例4: main
int main(int argc, char ** argv)
{
char * recname;
config_t cfg;
if(argc != 2)
usage(argv[0]);
recname = argv[1];
err = open(STATEFILE,O_RDWR);
CHECK_ERR_LTZ("Open schedule file");
fd = err;
err = flock(fd, LOCK_SH);
CHECK_ERR("Lock statefile");
err = atexit(&exitfunc);
config_init(&cfg);
config_read_file(&cfg, STATEFILE);
config_setting_t *root;
root = config_root_setting(&cfg);
err = config_setting_remove(root, recname);
CHECK_CFG("Remove recording from schedule");
err = config_write_file(&cfg, STATEFILE);
CHECK_CFG("Write config file");
config_destroy(&cfg);
return 0;
}
示例5: library_init
/* Thread: main */
int
library_init(void)
{
int i;
int ret;
scan_exit = false;
scanning = false;
CHECK_NULL(L_LIB, evbase_lib = event_base_new());
CHECK_NULL(L_LIB, updateev = evtimer_new(evbase_lib, update_trigger_cb, NULL));
for (i = 0; sources[i]; i++)
{
if (!sources[i]->init)
continue;
ret = sources[i]->init();
if (ret < 0)
sources[i]->disabled = 1;
}
CHECK_NULL(L_LIB, cmdbase = commands_base_new(evbase_lib, NULL));
CHECK_ERR(L_LIB, pthread_create(&tid_library, NULL, library, NULL));
#if defined(HAVE_PTHREAD_SETNAME_NP)
pthread_setname_np(tid_library, "library");
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
pthread_set_name_np(tid_library, "library");
#endif
return 0;
}
示例6: CHECK_ERR
unsigned long Camera::getMaxDataRate()
{
tPvUint32 min_data_rate, max_data_rate;
CHECK_ERR( PvAttrRangeUint32(handle_, "StreamBytesPerSecond", &min_data_rate, &max_data_rate),
"Couldn't get range of attribute StreamBytesPerSecond" );
return max_data_rate;
}
示例7: cl_select_context
void cl_select_context(cl_platform_id* platform, cl_device_id* device, cl_context* context) {
cl_int err;
#if defined (__APPLE__)
CGLContextObj kCGLContext = CGLGetCurrentContext();
CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);
cl_context_properties props[] =
{
CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE, (cl_context_properties)kCGLShareGroup,
0
};
*context = clCreateContext(props, 0,0, NULL, NULL, &err);
#else
#ifdef UNIX
cl_context_properties props[] =
{
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
CL_CONTEXT_PLATFORM, (cl_context_properties)platform,
0
};
*context = clCreateContext(props, 1, &cdDevices[uiDeviceUsed], NULL, NULL, &err);
#else // Win32
cl_context_properties props[] =
{
CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
CL_CONTEXT_PLATFORM, (cl_context_properties)*platform,
0
};
*context = clCreateContext(props, 1, device, NULL, NULL, &err);
CHECK_ERR(err);
#endif
#endif
}
示例8: main
int main(int argc, char *argv[])
{
int rank;
int errors = 0, all_errors = 0;
int buf;
MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Win_create(&buf, sizeof(int), sizeof(int), MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
/* This should fail because the window is not locked. */
CHECK_ERR(MPI_Win_unlock(0, win));
MPI_Win_free(&win);
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0 && all_errors == 0)
printf(" No Errors\n");
MPI_Finalize();
return 0;
}
示例9: main
int main(int argc, char *argv[])
{
int rank, nproc;
int errors = 0, all_errors = 0;
int buf, my_buf;
MPI_Win win;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &nproc);
MPI_Win_create(&buf, sizeof(int), sizeof(int),
MPI_INFO_NULL, MPI_COMM_WORLD, &win);
MPI_Win_set_errhandler(win, MPI_ERRORS_RETURN);
MPI_Win_fence(0, win);
MPI_Win_lock(MPI_LOCK_SHARED, 0, MPI_MODE_NOCHECK, win);
MPI_Get(&my_buf, 1, MPI_INT, 0, 0, 1, MPI_INT, win);
MPI_Win_unlock(0, win);
/* This should fail because the window is no longer in a fence epoch */
CHECK_ERR(MPI_Get(&my_buf, 1, MPI_INT, 0, 0, 1, MPI_INT, win));
MPI_Win_fence(0, win);
MPI_Win_free(&win);
MPI_Reduce(&errors, &all_errors, 1, MPI_INT, MPI_SUM, 0, MPI_COMM_WORLD);
if (rank == 0 && all_errors == 0) printf(" No Errors\n");
MPI_Finalize();
return 0;
}
示例10: printMemInfo
void printMemInfo(const char *header)
{
int bytesInMb = 1024 * 1024;
int device;
size_t free;
size_t total;
CHECK_ERR(cudaGetDevice(&device));
CHECK_ERR(cudaMemGetInfo(&free, &total));
long freeMb = free / bytesInMb;
long usedMb = (total - free) / bytesInMb;
long totalMb = total / bytesInMb;
printf("--%-50s GPU [%d] Mem Used: %-6ld MB. Free: %-6ld MB. Total: %-6ld MB\n", header, device, usedMb, freeMb,
totalMb);
}
示例11: handle_error
int handle_error(struct recording_entity *re, int errornum)
{
int err = 0;
struct common_io_info *ioi = (struct common_io_info *)re->opt;
if (errornum == ENOSPC)
{
E("Mount point full. Setting to read only");
//TODO: Augment infra for read only nodes
//Remember to not remove straight from branch
ioi->status = RECSTATUS_FULL;
set_free(ioi->opt->diskbranch, re->self);
}
else
{
E("Writer broken");
/* Done in close */
ioi->opt->hd_failures++;
if (ioi->opt->optbits & READMODE)
{
afi_mark_recid_missing(ioi->opt->filename, ioi->id);
}
remove_from_branch(ioi->opt->diskbranch, re->self, 0);
err = re->close(re, NULL);
CHECK_ERR("Close faulty recer");
/* TODO: Need to solve this free-stuff! */
//free(re);
//be->recer->close(be->recer,NULL);
D("Closed recer");
}
return err;
}
示例12: common_writecfg
int common_writecfg(struct recording_entity *re, void *opti)
{
int err;
struct common_io_info *ioi = re->opt;
struct opt_s *opt = opti;
char *cfgname = (char *)malloc(sizeof(char) * FILENAME_MAX);
char *dirname = (char *)malloc(sizeof(char) * FILENAME_MAX);
CHECK_ERR_NONNULL(cfgname, "Malloc cfgname");
CHECK_ERR_NONNULL(dirname, "Malloc dirname");
struct stat sb;
sprintf(dirname, "%s%i%s%s", ROOTDIRS, ioi->id, "/", opt->filename);
if (stat(dirname, &sb) != 0)
{
//perror("Error Opening dir");
//ERR_IN_INIT;
D("The dir %s doesn't exist. Probably no files written to it. Returning ok", dirname);
free(cfgname);
free(dirname);
return 0;
}
sprintf(cfgname, "%s%i%s%s%s%s%s", ROOTDIRS, ioi->id, "/", opt->filename,
"/", opt->filename, ".cfg");
err = write_cfg_for_rec(opt, cfgname);
CHECK_ERR("write cfg for rec");
free(cfgname);
free(dirname);
return err;
}
示例13: pool_hdr_uuid_fix
/*
* pool_hdr_uuid_fix -- (internal) fix UUID value
*/
static int
pool_hdr_uuid_fix(PMEMpoolcheck *ppc, location *loc, uint32_t question,
void *context)
{
LOG(3, NULL);
ASSERTne(loc, NULL);
switch (question) {
case Q_UUID_SET:
CHECK_INFO(ppc, "%ssetting pool_hdr.uuid to %s", loc->prefix,
check_get_uuid_str(*loc->valid_uuid));
memcpy(loc->hdr.uuid, loc->valid_uuid, POOL_HDR_UUID_LEN);
break;
case Q_UUID_REGENERATE:
if (util_uuid_generate(loc->hdr.uuid) != 0) {
ppc->result = CHECK_RESULT_INTERNAL_ERROR;
return CHECK_ERR(ppc, "%suuid generation failed",
loc->prefix);
}
CHECK_INFO(ppc, "%ssetting pool_hdr.uuid to %s", loc->prefix,
check_get_uuid_str(loc->hdr.uuid));
break;
default:
ERR("not implemented question id: %u", question);
}
return 0;
}
示例14: olsrd_mdp_init
int
olsrd_mdp_init(co_obj_t *self, co_obj_t **output, co_obj_t *params)
{
svl_crypto_ctx *ctx = NULL;
CHECK(IS_LIST(params) && co_list_length(params) == 2, "Invalid params");
size_t sid_len = co_str_len(co_list_element(params, 1));
char *sid_str = _LIST_ELEMENT(params, 1);
CHECK(sid_len == (2 * SID_SIZE) + 1 && str_is_subscriber_id(sid_str) == 1, "Invalid SID");
ctx = svl_crypto_ctx_new();
stowSid(ctx->sid, 0, sid_str);
ctx->keyring_path = _LIST_ELEMENT(params, 0);
ctx->keyring_len = co_str_len(co_list_element(params, 0)) - 1;
CHECK_ERR(ctx->keyring_len < PATH_MAX,"Keyring path too long");
CHECK(serval_init_keyring(ctx), "Failed to initialize Serval keyring");
CMD_OUTPUT("key", co_bin8_create((char*)ctx->sas_private, crypto_sign_SECRETKEYBYTES, 0));
return 1;
error:
if (ctx)
svl_crypto_ctx_free(ctx);
return 0;
}
示例15: PvCaptureAdjustPacketSize
void Camera::setup()
{
// adjust packet size according to the current network capacity
tPvUint32 maxPacketSize = 9000;
PvCaptureAdjustPacketSize(handle_, maxPacketSize);
// set data rate to the max
unsigned long max_data_rate = getMaxDataRate();
if (max_data_rate < GIGE_MAX_DATA_RATE) {
ROS_WARN("Detected max data rate is %lu bytes/s, typical maximum data rate for a "
"GigE port is %lu bytes/s. Are you using a GigE network card and cable?\n",
max_data_rate, GIGE_MAX_DATA_RATE);
}
setAttribute("StreamBytesPerSecond", max_data_rate);
// capture whole frame by default
setBinning();
setRoiToWholeFrame();
// query for attributes (TODO: more)
CHECK_ERR( PvAttrUint32Get(handle_, "TotalBytesPerFrame", &frameSize_),
"Unable to retrieve frame size" );
// allocate frame buffers
frames_ = new tPvFrame[bufferSize_];
memset(frames_, 0, sizeof(tPvFrame) * bufferSize_);
for (unsigned int i = 0; i < bufferSize_; ++i)
{
frames_[i].ImageBuffer = new char[frameSize_];
frames_[i].ImageBufferSize = frameSize_;
frames_[i].Context[0] = (void*)this; // for frameDone callback
}
}