本文整理汇总了C++中chpl_internal_error函数的典型用法代码示例。如果您正苦于以下问题:C++ chpl_internal_error函数的具体用法?C++ chpl_internal_error怎么用?C++ chpl_internal_error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chpl_internal_error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: chpl_mem_layerInit
void chpl_mem_layerInit(void) {
void* heap_base_;
size_t heap_size_;
chpl_comm_desired_shared_heap(&heap_base_, &heap_size_);
if (heap_base_ != NULL && heap_size_ == 0) {
chpl_internal_error("if heap address is specified, size must be also");
}
// If we have a shared heap, initialize our shared heap. This will take care
// of initializing jemalloc. If we're not using a shared heap, do a first
// allocation to allow jemaloc to set up:
//
// jemalloc 4.0.4 man: "Once, when the first call is made to one of the
// memory allocation routines, the allocator initializes its internals"
if (heap_base_ != NULL) {
heap_base = heap_base_;
heap_size = heap_size_;
cur_heap_offset = 0;
if (pthread_mutex_init(&chunk_alloc_lock, NULL) != 0) {
chpl_internal_error("cannot init chunk_alloc lock");
}
initializeSharedHeap();
} else {
void* p;
if ((p = je_malloc(1)) == NULL) {
chpl_internal_error("cannot init heap: je_malloc() failed");
}
je_free(p);
}
}
开发者ID:AbheekG,项目名称:chapel,代码行数:31,代码来源:mem-jemalloc.c
示例2: chpl_thread_init
void chpl_thread_init(int32_t numThreadsPerLocale,
int32_t maxThreadsPerLocale,
uint64_t callStackSize,
void(*threadBeginFn)(void*),
void(*threadEndFn)(void)) {
//
// If a value was specified for the call stack size config const, use
// that (rounded up to a whole number of pages) to set the system
// stack limit.
//
if (callStackSize != 0) {
uint64_t pagesize = (uint64_t) sysconf(_SC_PAGESIZE);
struct rlimit rlim;
callStackSize = (callStackSize + pagesize - 1) & ~(pagesize - 1);
if (getrlimit(RLIMIT_STACK, &rlim) != 0)
chpl_internal_error("getrlimit() failed");
if (rlim.rlim_max != RLIM_INFINITY && callStackSize > rlim.rlim_max) {
char warning[128];
sprintf(warning, "callStackSize capped at %lu\n",
(unsigned long)rlim.rlim_max);
chpl_warning(warning, 0, NULL);
callStackSize = rlim.rlim_max;
}
rlim.rlim_cur = threadCallStackSize = callStackSize;
if (setrlimit(RLIMIT_STACK, &rlim) != 0)
chpl_internal_error("setrlimit() failed");
}
}
开发者ID:deniskin82,项目名称:chapel,代码行数:34,代码来源:threads-minimal.c
示例3: initialize_arenas
// initialize our arenas (this is required to be able to set the chunk hooks)
static void initialize_arenas(void) {
size_t s_narenas;
unsigned narenas;
unsigned arena;
// "thread.arena" takes an unsigned, but num_arenas is a size_t.
s_narenas = get_num_arenas();
if (s_narenas > (size_t) UINT_MAX) {
chpl_internal_error("narenas too large to fit into unsigned");
}
narenas = (unsigned) s_narenas;
// for each non-zero arena, set the current thread to use it (this
// initializes each arena). arena 0 is automatically initialized.
//
// jemalloc 4.0.4 man: "If the specified arena was not initialized
// beforehand, it will be automatically initialized as a side effect of
// calling this interface."
for (arena=1; arena<narenas; arena++) {
if (je_mallctl("thread.arena", NULL, NULL, &arena, sizeof(arena)) != 0) {
chpl_internal_error("could not change current thread's arena");
}
}
// then set the current thread back to using arena 0
arena = 0;
if (je_mallctl("thread.arena", NULL, NULL, &arena, sizeof(arena)) != 0) {
chpl_internal_error("could not change current thread's arena back to 0");
}
}
开发者ID:AbheekG,项目名称:chapel,代码行数:31,代码来源:mem-jemalloc.c
示例4: chpl_thread_exit
void chpl_thread_exit(void) {
chpl_bool debug = false;
thread_list_p tlp;
pthread_mutex_lock(&thread_info_lock);
exiting = true;
// shut down all threads
for (tlp = thread_list_head; tlp != NULL; tlp = tlp->next) {
if (pthread_cancel(tlp->thread) != 0)
chpl_internal_error("thread cancel failed");
}
pthread_mutex_unlock(&thread_info_lock);
while (thread_list_head != NULL) {
if (pthread_join(thread_list_head->thread, NULL) != 0)
chpl_internal_error("thread join failed");
tlp = thread_list_head;
thread_list_head = thread_list_head->next;
chpl_mem_free(tlp, 0, 0);
}
CHPL_TLS_DELETE(chpl_thread_id);
CHPL_TLS_DELETE(chpl_thread_data);
if (pthread_attr_destroy(&thread_attributes) != 0)
chpl_internal_error("pthread_attr_destroy() failed");
if (debug)
fprintf(stderr, "A total of %u threads were created\n", numThreads);
}
开发者ID:AbheekG,项目名称:chapel,代码行数:32,代码来源:threads-pthreads.c
示例5: chpl_mem_layerInit
void chpl_mem_layerInit(void)
{
void* heap_base;
size_t heap_size;
chpl_comm_desired_shared_heap(&heap_base, &heap_size);
if (heap_base != NULL && heap_size == 0)
chpl_internal_error("if heap address is specified, size must be also");
//
// Do a first allocation, to allow tcmalloc to set up its internal
// management structures.
//
{
void* p;
if ((p = tc_malloc(1)) == NULL)
chpl_internal_error("cannot init heap: tc_malloc() failed");
tc_free(p);
}
//
// Initialize our tcmalloc system allocator.
//
tcmallocChapelInit_c(heap_base, heap_size);
//
// If the heap has to come from the memory supplied to us (say, in
// order that the comm layer be able to depend on all allocations
// having come from it), use up all the system memory tcmalloc had
// acquired before we set up our own system allocator just now.
// All allocations after this will come from the memory supplied
// to us.
//
// Note that this can waste up to twice INITIAL_USE_UP_SIZE bytes
// of the memory supplied to us, plus overhead.
//
if (heap_base != NULL) {
#define INITIAL_USE_UP_SIZE ((size_t) 4 * 1024)
size_t size;
char* p;
for (size = INITIAL_USE_UP_SIZE; size > 0; size /= 2) {
do {
p = tc_malloc(size);
} while (p != NULL
&& (p < (char*) heap_base
|| p > (char*) heap_base + heap_size));
#undef INITIAL_USE_UP_SIZE
}
}
}
开发者ID:CoryMcCartan,项目名称:chapel,代码行数:55,代码来源:mem-tcmalloc.c
示例6: maybe_set_jemalloc_lg_chunk
static
void maybe_set_jemalloc_lg_chunk(void) {
size_t hps;
hps = chpl_comm_ugni_getHeapPageSize();
if (hps == chpl_comm_ugni_getSysPageSize())
return;
//
// We're using the jemalloc memory layer, the heap is dynamically
// extensible, and we've got hugepages, so we'll be registering
// memory. (chpl_comm_ugni_getHeapPageSize()) checks all this.)
//
// Arrange for jemalloc's chunk size (and alignment) to be the same
// as what the comm layer recommends, which is the heap page size.
// Make sure this is a power of 2, because jemalloc needs that.
//
int hps_log2;
char* ev;
char buf[1000];
// sanity check: power of 2 and >= sys page size
assert((hps & (hps - 1)) == 0
&& hps >= chpl_comm_ugni_getSysPageSize());
// lg_chunk is specified as the base-2 log of the expansion chunk size
hps_log2 = lrint(log2((double) hps));
//
// Now, set the jemalloc environment variable. We also must include
// the "purge:" setting we specify at jemalloc configuration time,
// because the env var overrides config-time settings.
//
if ((ev = getenv(jemalloc_conf_ev_name())) == NULL) {
const char* fmt = "purge:decay,lg_chunk:%d";
if (snprintf(buf, sizeof(buf), fmt, hps_log2) >= sizeof(buf)) {
chpl_internal_error("setting jemalloc conf env var would truncate");
}
} else {
// Override any user-specified lg_chunk. Smaller or larger, it
// would break our logic either way.
const char* fmt = ((strstr(ev, "purge:") == NULL)
? "%s,purge:decay,lg_chunk:%d"
: "%s,lg_chunk:%d");
if (snprintf(buf, sizeof(buf), fmt, ev, hps_log2) >= sizeof(buf)) {
chpl_internal_error("setting jemalloc conf env var would truncate");
}
}
if (setenv(jemalloc_conf_ev_name(), buf, 1) != 0)
chpl_internal_error("cannot setenv jemalloc conf env var");
}
开发者ID:DawidvC,项目名称:chapel,代码行数:52,代码来源:comm-ugni-launch.c
示例7: report_error
static
void report_error(const char* what, int errnum) {
char buf[100];
snprintf(buf, sizeof(buf), "%s: %s", what, strerror(errnum));
chpl_internal_error(buf);
}
开发者ID:bollu,项目名称:chapel,代码行数:7,代码来源:chpl-topo.c
示例8: chpl_comm_post_task_init
void chpl_comm_post_task_init(void) {
int i;
if (chpl_numNodes == 1) {
// return;
}
libfabric_init();
chpl_comm_ofi_put_get_init(&ofi);
chpl_comm_ofi_am_init(&ofi);
if (num_progress_threads > 0) {
// Start progress thread(s). Don't proceed from here until at
// least one is running.
CALL_CHECK_ZERO(pthread_mutex_lock(&progress_thread_entEx_cond_mutex));
for (i = 0; i < num_progress_threads; i++) {
pti[i]. id = i;
if (chpl_task_createCommTask(progress_thread, (void *) &pti[i]) != 0) {
chpl_internal_error("unable to start progress thread");
}
}
// Some progress thread we created will release us.
CALL_CHECK_ZERO(pthread_cond_wait(&progress_thread_enter_cond,
&progress_thread_entEx_cond_mutex));
CALL_CHECK_ZERO(pthread_mutex_unlock(&progress_thread_entEx_cond_mutex));
}
// Initialize the caching layer, if it is active.
// chpl_cache_init();
}
开发者ID:DawidvC,项目名称:chapel,代码行数:33,代码来源:comm-ofi.c
示例9: replaceChunkHooks
// replace the chunk hooks for each arena with the hooks we provided above
static void replaceChunkHooks(void) {
size_t narenas;
size_t arena;
// set the pointers for the new_hooks to our above functions
chunk_hooks_t new_hooks = {
chunk_alloc,
null_dalloc,
null_commit,
null_decommit,
null_purge,
null_split,
null_merge
};
// for each arena, change the chunk hooks
narenas = get_num_arenas();
for (arena=0; arena<narenas; arena++) {
char path[128];
snprintf(path, sizeof(path), "arena.%zu.chunk_hooks", arena);
if (je_mallctl(path, NULL, NULL, &new_hooks, sizeof(chunk_hooks_t)) != 0) {
chpl_internal_error("could not update the chunk hooks");
}
}
}
开发者ID:AbheekG,项目名称:chapel,代码行数:26,代码来源:mem-jemalloc.c
示例10: chpl_launch_create_command
static char* chpl_launch_create_command(int argc, char* argv[],
int32_t numLocales) {
int i;
int size;
char baseCommand[256];
char* command;
chpl_compute_real_binary_name(argv[0]);
sprintf(baseCommand, "mpirun -np %d %s %s", numLocales, MPIRUN_XTRA_OPTS,
chpl_get_real_binary_name());
size = strlen(MPIRUN_PATH) + 1 + strlen(baseCommand) + 1;
for (i=1; i<argc; i++) {
size += strlen(argv[i]) + 3;
}
command = chpl_mem_allocMany(size, sizeof(char), CHPL_RT_MD_COMMAND_BUFFER, -1, "");
sprintf(command, "%s/%s", MPIRUN_PATH, baseCommand);
for (i=1; i<argc; i++) {
strcat(command, " '");
strcat(command, argv[i]);
strcat(command, "'");
}
if (strlen(command)+1 > size) {
chpl_internal_error("buffer overflow");
}
return command;
}
开发者ID:sungeunchoi,项目名称:chapel,代码行数:33,代码来源:launch-mpirun.c
示例11: jemalloc_conf_ev_name
//
// With mem=jemalloc and comm=ugni with hugepages and a dynamically
// extensible heap, we have to configure jemalloc's large chunk size.
// It would be preferable to deal with this entirely within the target
// program, but we need it before jemalloc does its constructor-based
// initialization and we don't have a dependable way to arrange that
// in the target program.
//
static
char* jemalloc_conf_ev_name(void) {
#define _STRFY(s) #s
#define _EXPAND_THEN_STRFY(s) _STRFY(s)
#ifdef CHPL_JEMALLOC_PREFIX
#define EVN_PREFIX_STR _EXPAND_THEN_STRFY(CHPL_JEMALLOC_PREFIX)
#else
#define EVN_PREFIX_STR ""
#endif
static char evn[100] = "";
// safe because always called serially
if (evn[0] != '\0')
return evn;
if (snprintf(evn, sizeof(evn), "%sMALLOC_CONF", EVN_PREFIX_STR)
>= sizeof(evn)) {
chpl_internal_error("jemalloc conf env var name buffer is too small");
}
for (int i = 0; evn[i] != '\0'; i++) {
if (islower(evn[i]))
evn[i] = toupper(evn[i]);
}
return evn;
#undef _STRFY
#undef _EXPAND_THEN_STRFY
#undef EVN_PREFIX_STR
}
开发者ID:DawidvC,项目名称:chapel,代码行数:40,代码来源:comm-ugni-launch.c
示例12: chpl_launch_create_command
static char* chpl_launch_create_command(int argc, char* argv[],
int32_t numLocales) {
int i;
int size;
char baseCommand[256];
char* command;
if (numLocales != 1) {
chpl_error("dummy launcher only supports numLocales==1", 0, "<command-line>");
}
chpl_compute_real_binary_name(argv[0]);
sprintf(baseCommand, "%s", chpl_get_real_binary_name());
size = strlen(baseCommand) + 1;
for (i=1; i<argc; i++) {
size += strlen(argv[i]) + 3;
}
command = chpl_mem_allocMany(size, sizeof(char), CHPL_RT_MD_COMMAND_BUFFER, -1, "");
sprintf(command, "%s", baseCommand);
for (i=1; i<argc; i++) {
strcat(command, " '");
strcat(command, argv[i]);
strcat(command, "'");
}
if (strlen(command)+1 > size) {
chpl_internal_error("buffer overflow");
}
return command;
}
开发者ID:CoryMcCartan,项目名称:chapel,代码行数:35,代码来源:launch-dummy.c
示例13: chpl_compute_real_binary_name
void chpl_compute_real_binary_name(const char* argv0) {
char* cursor = chpl_real_binary_name;
int exe_length = strlen(launcher_exe_suffix);
int length;
const char* real_suffix = getenv("CHPL_LAUNCHER_SUFFIX");
if (NULL == real_suffix) {
real_suffix = launcher_real_suffix;
}
length = strlen(argv0);
if (length + strlen(launcher_real_suffix) >= BIN_NAME_SIZE)
chpl_internal_error("Real executable name is too long.");
// See if the launcher name contains the exe_suffix
if (exe_length > 0 &&
!strncmp(argv0 + length - exe_length, launcher_exe_suffix, exe_length))
// We matched the exe suffix, so remove it before adding the real suffix.
length -= exe_length;
// Copy the filename sans exe suffix.
strncpy(cursor, argv0, length);
cursor += length;
strcpy(cursor, launcher_real_suffix);
}
开发者ID:coderbond007,项目名称:chapel,代码行数:26,代码来源:main_launcher.c
示例14: chpl_launch_create_command
static char* chpl_launch_create_command(int argc, char* argv[],
int32_t numLocales) {
int i;
int size;
char baseCommand[256];
char* command;
FILE* llFile, *expectFile;
char* projectString = getenv(launcherAccountEnvvar);
char* basenamePtr = strrchr(argv[0], '/');
pid_t mypid;
if (basenamePtr == NULL) {
basenamePtr = argv[0];
} else {
basenamePtr++;
}
chpl_compute_real_binary_name(argv[0]);
#ifndef DEBUG_LAUNCH
mypid = getpid();
#else
mypid = 0;
#endif
sprintf(expectFilename, "%s%d", baseExpectFilename, (int)mypid);
sprintf(llFilename, "%s%d", baseLLFilename, (int)mypid);
llFile = fopen(llFilename, "w");
fprintf(llFile, "# @ wall_clock_limit = 00:10:00\n");
fprintf(llFile, "# @ job_type = parallel\n");
fprintf(llFile, "# @ node = %d\n", numLocales);
fprintf(llFile, "# @ tasks_per_node = 1\n");
if (projectString && strlen(projectString) > 0)
fprintf(llFile, "# @ class = %s\n", projectString);
fprintf(llFile, "# @ output = out.$(jobid)\n");
fprintf(llFile, "# @ error = err.$(jobid)\n");
fprintf(llFile, "# @ queue\n");
fprintf(llFile, "\n");
fprintf(llFile, "%s", chpl_get_real_binary_name());
for (i=1; i<argc; i++) {
fprintf(llFile, " '%s'", argv[i]);
}
fprintf(llFile, "\n");
fclose(llFile);
sprintf(baseCommand, "llsubmit %s", llFilename);
size = strlen(baseCommand) + 1;
command = chpl_mem_allocMany(size, sizeof(char), CHPL_RT_MD_COMMAND_BUFFER, -1, "");
sprintf(command, "%s", baseCommand);
if (strlen(command)+1 > size) {
chpl_internal_error("buffer overflow");
}
return command;
}
开发者ID:CoryMcCartan,项目名称:chapel,代码行数:59,代码来源:launch-loadleveler.c
示例15: chpl_comm_getenvMaxHeapSize
size_t chpl_comm_getenvMaxHeapSize(void)
{
if (pthread_once(&maxHeapSize_once, set_maxHeapSize) != 0) {
chpl_internal_error("pthread_once(&maxHeapSize_once) failed");
}
return maxHeapSize;
}
开发者ID:panzone,项目名称:chapel,代码行数:8,代码来源:chpl-comm.c
示例16: get_num_arenas
// get the number of arenas
static size_t get_num_arenas(void) {
size_t narenas;
size_t sz;
sz = sizeof(narenas);
if (je_mallctl("opt.narenas", &narenas, &sz, NULL, 0) != 0) {
chpl_internal_error("could not get number of arenas from jemalloc");
}
return narenas;
}
开发者ID:AbheekG,项目名称:chapel,代码行数:10,代码来源:mem-jemalloc.c
示例17: chpl_thread_condvar_destroy
static void chpl_thread_condvar_destroy(chpl_thread_condvar_t* cv) {
// Leak condvars on cygwin. Some bug results from condvars still being used at
// this point on cygwin. For now, just leak them to avoid errors as a result of
// the undefined behavior of trying to destroy an in-use condvar.
#ifndef __CYGWIN__
if (pthread_cond_destroy((pthread_cond_t*) cv))
chpl_internal_error("pthread_cond_destroy() failed");
#endif
}
开发者ID:ct-clmsn,项目名称:chapel,代码行数:9,代码来源:tasks-fifo.c
示例18: get_thread_private_data
//
// Get the the thread private data pointer for my thread.
//
static thread_private_data_t* get_thread_private_data(void) {
thread_private_data_t* tp;
tp = (thread_private_data_t*) chpl_thread_getPrivateData();
if (tp == NULL)
chpl_internal_error("no thread private data");
return tp;
}
开发者ID:ct-clmsn,项目名称:chapel,代码行数:13,代码来源:tasks-fifo.c
示例19: chpl_comm_startVerbose
void chpl_comm_startVerbose(chpl_bool print_unstable) {
chpl_comm_diags_print_unstable = (print_unstable == true);
if (pthread_once(&bcastPrintUnstable_once, broadcast_print_unstable) != 0) {
chpl_internal_error("pthread_once(&bcastPrintUnstable_once) failed");
}
chpl_verbose_comm = 1;
chpl_comm_diags_disable();
chpl_comm_bcast_rt_private(chpl_verbose_comm);
chpl_comm_diags_enable();
}
开发者ID:chapel-lang,项目名称:chapel,代码行数:11,代码来源:chpl-comm-diags.c
示例20: chpl_env_rt_get
const char* chpl_env_rt_get(const char* evs, const char* dflt) {
char evName[100];
const char* evVal;
if (snprintf(evName, sizeof(evName), "CHPL_RT_%s", evs) >= sizeof(evName))
chpl_internal_error("environment variable name buffer too small");
evVal = getenv(evName);
if (evVal == NULL)
return dflt;
return evVal;
}
开发者ID:chapel-lang,项目名称:chapel,代码行数:12,代码来源:chpl-env.c
注:本文中的chpl_internal_error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论