31 #include "ompt-specific.cpp"
37 #define ompt_get_callback_success 1
38 #define ompt_get_callback_failure 0
40 #define no_tool_present 0
42 #define OMPT_API_ROUTINE static
44 #ifndef OMPT_STR_MATCH
45 #define OMPT_STR_MATCH(haystack, needle) (!strcasecmp(haystack, needle))
52 #define OMPT_VERBOSE_INIT_PRINT(...) \
54 fprintf(verbose_file, __VA_ARGS__)
55 #define OMPT_VERBOSE_INIT_CONTINUED_PRINT(...) \
57 fprintf(verbose_file, __VA_ARGS__)
59 static FILE *verbose_file;
60 static int verbose_init;
67 const char *state_name;
68 ompt_state_t state_id;
74 } kmp_mutex_impl_info_t;
87 ompt_callbacks_active_t ompt_enabled;
89 ompt_target_callbacks_active_t ompt_target_enabled;
91 ompt_state_info_t ompt_state_info[] = {
92 #define ompt_state_macro(state, code) {#state, state},
93 FOREACH_OMPT_STATE(ompt_state_macro)
94 #undef ompt_state_macro
97 kmp_mutex_impl_info_t kmp_mutex_impl_info[] = {
98 #define kmp_mutex_impl_macro(name, id) {#name, name},
99 FOREACH_KMP_MUTEX_IMPL(kmp_mutex_impl_macro)
100 #undef kmp_mutex_impl_macro
103 ompt_callbacks_internal_t ompt_callbacks;
105 ompt_target_callbacks_internal_t ompt_target_callbacks;
107 ompt_callbacks_internal_noemi_t ompt_callbacks_noemi;
109 static ompt_start_tool_result_t *ompt_start_tool_result = NULL;
112 static HMODULE ompt_tool_module = NULL;
113 #define OMPT_DLCLOSE(Lib) FreeLibrary(Lib)
115 static void *ompt_tool_module = NULL;
116 #define OMPT_DLCLOSE(Lib) dlclose(Lib)
123 static ompt_interface_fn_t ompt_fn_lookup(
const char *s);
125 OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(
void);
131 typedef ompt_start_tool_result_t *(*ompt_start_tool_t)(
unsigned int,
134 _OMP_EXTERN OMPT_WEAK_ATTRIBUTE
bool
135 libomp_start_tool(ompt_target_callbacks_active_t *libomptarget_ompt_enabled) {
136 if (!TCR_4(__kmp_init_middle)) {
137 __kmp_middle_initialize();
140 libomptarget_ompt_enabled->enabled = ompt_enabled.enabled;
141 if (ompt_enabled.enabled) {
143 #define ompt_event_macro(event_name, callback_type, event_id) \
144 libomptarget_ompt_enabled->event_name = ompt_target_enabled.event_name;
146 FOREACH_OMPT_51_TARGET_EVENT(ompt_event_macro)
147 #undef ompt_event_macro
152 void ompt_callback_target_data_op_emi_wrapper(
153 ompt_scope_endpoint_t endpoint, ompt_data_t *target_task_data,
154 ompt_data_t *target_data, ompt_id_t *host_op_id,
155 ompt_target_data_op_t optype,
void *src_addr,
int src_device_num,
156 void *dest_addr,
int dest_device_num,
size_t bytes,
157 const void *codeptr_ra) {}
159 void ompt_callback_target_emi_wrapper(ompt_target_t kind,
160 ompt_scope_endpoint_t endpoint,
161 int device_num, ompt_data_t *task_data,
162 ompt_data_t *target_task_data,
163 ompt_data_t *target_data,
164 const void *codeptr_ra) {}
166 void ompt_callback_target_map_emi_wrapper(ompt_data_t *target_data,
167 unsigned int nitems,
void **host_addr,
168 void **device_addr,
size_t *bytes,
169 unsigned int *mapping_flags,
170 const void *codeptr_ra) {}
172 void ompt_callback_target_submit_emi_wrapper(ompt_scope_endpoint_t endpoint,
173 ompt_data_t *target_data,
174 ompt_id_t *host_op_id,
175 unsigned int requested_num_teams) {
190 static ompt_start_tool_result_t *ompt_tool_darwin(
unsigned int omp_version,
191 const char *runtime_version) {
192 ompt_start_tool_result_t *ret = NULL;
194 ompt_start_tool_t start_tool =
195 (ompt_start_tool_t)dlsym(RTLD_DEFAULT,
"ompt_start_tool");
197 ret = start_tool(omp_version, runtime_version);
202 #elif OMPT_HAVE_WEAK_ATTRIBUTE
208 _OMP_EXTERN OMPT_WEAK_ATTRIBUTE ompt_start_tool_result_t *
209 ompt_start_tool(
unsigned int omp_version,
const char *runtime_version) {
210 ompt_start_tool_result_t *ret = NULL;
215 ompt_start_tool_t next_tool =
216 (ompt_start_tool_t)dlsym(RTLD_NEXT,
"ompt_start_tool");
218 ret = next_tool(omp_version, runtime_version);
223 #elif OMPT_HAVE_PSAPI
231 #pragma comment(lib, "psapi.lib")
234 #define NUM_MODULES 128
236 static ompt_start_tool_result_t *
237 ompt_tool_windows(
unsigned int omp_version,
const char *runtime_version) {
239 DWORD needed, new_size;
241 HANDLE process = GetCurrentProcess();
242 modules = (HMODULE *)malloc(NUM_MODULES *
sizeof(HMODULE));
243 ompt_start_tool_t ompt_tool_p = NULL;
246 printf(
"ompt_tool_windows(): looking for ompt_start_tool\n");
248 if (!EnumProcessModules(process, modules, NUM_MODULES *
sizeof(HMODULE),
255 new_size = needed /
sizeof(HMODULE);
256 if (new_size > NUM_MODULES) {
258 printf(
"ompt_tool_windows(): resize buffer to %d bytes\n", needed);
260 modules = (HMODULE *)realloc(modules, needed);
262 if (!EnumProcessModules(process, modules, needed, &needed)) {
267 for (i = 0; i < new_size; ++i) {
268 (FARPROC &)ompt_tool_p = GetProcAddress(modules[i],
"ompt_start_tool");
271 TCHAR modName[MAX_PATH];
272 if (GetModuleFileName(modules[i], modName, MAX_PATH))
273 printf(
"ompt_tool_windows(): ompt_start_tool found in module %s\n",
277 return (*ompt_tool_p)(omp_version, runtime_version);
281 TCHAR modName[MAX_PATH];
282 if (GetModuleFileName(modules[i], modName, MAX_PATH))
283 printf(
"ompt_tool_windows(): ompt_start_tool not found in module %s\n",
292 #error Activation of OMPT is not supported on this platform.
295 static ompt_start_tool_result_t *
296 ompt_try_start_tool(
unsigned int omp_version,
const char *runtime_version) {
297 ompt_start_tool_result_t *ret = NULL;
298 ompt_start_tool_t start_tool = NULL;
301 const char *sep =
";";
303 const char *sep =
":";
306 OMPT_VERBOSE_INIT_PRINT(
"----- START LOGGING OF TOOL REGISTRATION -----\n");
307 OMPT_VERBOSE_INIT_PRINT(
"Search for OMP tool in current address space... ");
311 ret = ompt_tool_darwin(omp_version, runtime_version);
312 #elif OMPT_HAVE_WEAK_ATTRIBUTE
313 ret = ompt_start_tool(omp_version, runtime_version);
314 #elif OMPT_HAVE_PSAPI
315 ret = ompt_tool_windows(omp_version, runtime_version);
317 #error Activation of OMPT is not supported on this platform.
320 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success.\n");
321 OMPT_VERBOSE_INIT_PRINT(
322 "Tool was started and is using the OMPT interface.\n");
323 OMPT_VERBOSE_INIT_PRINT(
"----- END LOGGING OF TOOL REGISTRATION -----\n");
328 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed.\n");
329 const char *tool_libs = getenv(
"OMP_TOOL_LIBRARIES");
331 OMPT_VERBOSE_INIT_PRINT(
"Searching tool libraries...\n");
332 OMPT_VERBOSE_INIT_PRINT(
"OMP_TOOL_LIBRARIES = %s\n", tool_libs);
333 char *libs = __kmp_str_format(
"%s", tool_libs);
335 char *fname = __kmp_str_token(libs, sep, &buf);
341 OMPT_VERBOSE_INIT_PRINT(
"Opening %s... ", fname);
342 void *h = dlopen(fname, RTLD_LAZY);
344 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed: %s\n", dlerror());
346 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success. \n");
347 OMPT_VERBOSE_INIT_PRINT(
"Searching for ompt_start_tool in %s... ",
349 start_tool = (ompt_start_tool_t)dlsym(h,
"ompt_start_tool");
351 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed: %s\n", dlerror());
354 OMPT_VERBOSE_INIT_PRINT(
"Opening %s... ", fname);
355 HMODULE h = LoadLibrary(fname);
357 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed: Error %u\n", GetLastError());
359 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success. \n");
360 OMPT_VERBOSE_INIT_PRINT(
"Searching for ompt_start_tool in %s... ",
362 start_tool = (ompt_start_tool_t)GetProcAddress(h,
"ompt_start_tool");
364 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed: Error %u\n",
368 #error Activation of OMPT is not supported on this platform.
371 ret = (*start_tool)(omp_version, runtime_version);
373 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success.\n");
374 OMPT_VERBOSE_INIT_PRINT(
375 "Tool was started and is using the OMPT interface.\n");
376 ompt_tool_module = h;
379 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
380 "Found but not using the OMPT interface.\n");
381 OMPT_VERBOSE_INIT_PRINT(
"Continuing search...\n");
385 fname = __kmp_str_token(NULL, sep, &buf);
387 __kmp_str_free(&libs);
389 OMPT_VERBOSE_INIT_PRINT(
"No OMP_TOOL_LIBRARIES defined.\n");
394 OMPT_VERBOSE_INIT_PRINT(
"----- END LOGGING OF TOOL REGISTRATION -----\n");
400 const char *fname =
"libarcher.so";
401 OMPT_VERBOSE_INIT_PRINT(
402 "...searching tool libraries failed. Using archer tool.\n");
403 OMPT_VERBOSE_INIT_PRINT(
"Opening %s... ", fname);
404 void *h = dlopen(fname, RTLD_LAZY);
406 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success.\n");
407 OMPT_VERBOSE_INIT_PRINT(
"Searching for ompt_start_tool in %s... ", fname);
408 start_tool = (ompt_start_tool_t)dlsym(h,
"ompt_start_tool");
410 ret = (*start_tool)(omp_version, runtime_version);
412 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Success.\n");
413 OMPT_VERBOSE_INIT_PRINT(
414 "Tool was started and is using the OMPT interface.\n");
415 OMPT_VERBOSE_INIT_PRINT(
416 "----- END LOGGING OF TOOL REGISTRATION -----\n");
419 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
420 "Found but not using the OMPT interface.\n");
422 OMPT_VERBOSE_INIT_CONTINUED_PRINT(
"Failed: %s\n", dlerror());
427 OMPT_VERBOSE_INIT_PRINT(
"No OMP tool loaded.\n");
428 OMPT_VERBOSE_INIT_PRINT(
"----- END LOGGING OF TOOL REGISTRATION -----\n");
432 void ompt_pre_init() {
436 static int ompt_pre_initialized = 0;
438 if (ompt_pre_initialized)
441 ompt_pre_initialized = 1;
446 const char *ompt_env_var = getenv(
"OMP_TOOL");
447 tool_setting_e tool_setting = omp_tool_error;
449 if (!ompt_env_var || !strcmp(ompt_env_var,
""))
450 tool_setting = omp_tool_unset;
451 else if (OMPT_STR_MATCH(ompt_env_var,
"disabled"))
452 tool_setting = omp_tool_disabled;
453 else if (OMPT_STR_MATCH(ompt_env_var,
"enabled"))
454 tool_setting = omp_tool_enabled;
456 const char *ompt_env_verbose_init = getenv(
"OMP_TOOL_VERBOSE_INIT");
459 if (ompt_env_verbose_init && strcmp(ompt_env_verbose_init,
"") &&
460 !OMPT_STR_MATCH(ompt_env_verbose_init,
"disabled")) {
462 if (OMPT_STR_MATCH(ompt_env_verbose_init,
"STDERR"))
463 verbose_file = stderr;
464 else if (OMPT_STR_MATCH(ompt_env_verbose_init,
"STDOUT"))
465 verbose_file = stdout;
467 verbose_file = fopen(ompt_env_verbose_init,
"w");
472 printf(
"ompt_pre_init(): tool_setting = %d\n", tool_setting);
474 switch (tool_setting) {
475 case omp_tool_disabled:
476 OMPT_VERBOSE_INIT_PRINT(
"OMP tool disabled. \n");
480 case omp_tool_enabled:
485 ompt_start_tool_result =
486 ompt_try_start_tool(__kmp_openmp_version, ompt_get_runtime_version());
488 memset(&ompt_enabled, 0,
sizeof(ompt_enabled));
493 "Warning: OMP_TOOL has invalid value \"%s\".\n"
494 " legal values are (NULL,\"\",\"disabled\","
499 if (verbose_init && verbose_file != stderr && verbose_file != stdout)
500 fclose(verbose_file);
502 printf(
"ompt_pre_init(): ompt_enabled = %d\n", ompt_enabled);
506 extern "C" int omp_get_initial_device(
void);
508 void ompt_post_init() {
512 static int ompt_post_initialized = 0;
514 if (ompt_post_initialized)
517 ompt_post_initialized = 1;
522 if (ompt_start_tool_result) {
523 ompt_enabled.enabled = !!ompt_start_tool_result->initialize(
524 ompt_fn_lookup, omp_get_initial_device(),
525 &(ompt_start_tool_result->tool_data));
527 if (!ompt_enabled.enabled) {
529 memset(&ompt_enabled, 0,
sizeof(ompt_enabled));
533 kmp_info_t *root_thread = ompt_get_thread();
535 ompt_set_thread_state(root_thread, ompt_state_overhead);
537 if (ompt_enabled.ompt_callback_thread_begin) {
538 ompt_callbacks.ompt_callback(ompt_callback_thread_begin)(
539 ompt_thread_initial, __ompt_get_thread_data_internal());
541 ompt_data_t *task_data;
542 ompt_data_t *parallel_data;
543 __ompt_get_task_info_internal(0, NULL, &task_data, NULL, ¶llel_data,
545 if (ompt_enabled.ompt_callback_implicit_task) {
546 ompt_callbacks.ompt_callback(ompt_callback_implicit_task)(
547 ompt_scope_begin, parallel_data, task_data, 1, 1, ompt_task_initial);
550 ompt_set_thread_state(root_thread, ompt_state_work_serial);
555 if (ompt_enabled.enabled
557 && ompt_start_tool_result && ompt_start_tool_result->finalize
560 ompt_start_tool_result->finalize(&(ompt_start_tool_result->tool_data));
563 if (ompt_tool_module)
564 OMPT_DLCLOSE(ompt_tool_module);
565 memset(&ompt_enabled, 0,
sizeof(ompt_enabled));
576 OMPT_API_ROUTINE
int ompt_enumerate_states(
int current_state,
int *next_state,
577 const char **next_state_name) {
578 const static int len =
sizeof(ompt_state_info) /
sizeof(ompt_state_info_t);
581 for (i = 0; i < len - 1; i++) {
582 if (ompt_state_info[i].state_id == current_state) {
583 *next_state = ompt_state_info[i + 1].state_id;
584 *next_state_name = ompt_state_info[i + 1].state_name;
592 OMPT_API_ROUTINE
int ompt_enumerate_mutex_impls(
int current_impl,
594 const char **next_impl_name) {
595 const static int len =
596 sizeof(kmp_mutex_impl_info) /
sizeof(kmp_mutex_impl_info_t);
598 for (i = 0; i < len - 1; i++) {
599 if (kmp_mutex_impl_info[i].
id != current_impl)
601 *next_impl = kmp_mutex_impl_info[i + 1].id;
602 *next_impl_name = kmp_mutex_impl_info[i + 1].name;
612 OMPT_API_ROUTINE ompt_set_result_t ompt_set_callback(ompt_callbacks_t which,
613 ompt_callback_t callback) {
616 #define ompt_event_macro(event_name, callback_type, event_id) \
618 ompt_callbacks.ompt_callback(event_name) = (callback_type)callback; \
619 ompt_enabled.event_name = (callback != 0); \
621 return ompt_event_implementation_status(event_name); \
623 return ompt_set_always;
625 FOREACH_OMPT_HOST_EVENT(ompt_event_macro)
627 #undef ompt_event_macro
629 #define ompt_event_macro(event_name, callback_type, event_id) \
631 ompt_target_callbacks.ompt_callback(event_name) = (callback_type)callback; \
632 ompt_target_enabled.event_name = (callback != 0); \
634 return ompt_event_implementation_status(event_name); \
636 return ompt_set_always;
638 FOREACH_OMPT_51_TARGET_EVENT(ompt_event_macro)
640 #undef ompt_event_macro
642 #define ompt_event_macro(event_name, callback_type, event_id) \
644 ompt_callbacks_noemi.ompt_callback(event_name) = (callback_type)callback; \
645 ompt_target_enabled.ompt_emi_event(event_name) = (callback != 0); \
647 ompt_target_callbacks.ompt_emi_callback(event_name) = \
648 (ompt_emi_callback_type(event_name))(&ompt_emi_wrapper(event_name)); \
649 return ompt_event_implementation_status(event_name); \
651 ompt_target_callbacks.ompt_emi_callback(event_name) = NULL; \
652 return ompt_set_always; \
655 FOREACH_OMPT_NOEMI_EVENT(ompt_event_macro)
657 #undef ompt_event_macro
660 return ompt_set_error;
664 OMPT_API_ROUTINE
int ompt_get_callback(ompt_callbacks_t which,
665 ompt_callback_t *callback) {
666 if (!ompt_enabled.enabled)
667 return ompt_get_callback_failure;
671 #define ompt_event_macro(event_name, callback_type, event_id) \
673 ompt_callback_t mycb = \
674 (ompt_callback_t)ompt_callbacks.ompt_callback(event_name); \
675 if (ompt_enabled.event_name && mycb) { \
677 return ompt_get_callback_success; \
679 return ompt_get_callback_failure; \
682 FOREACH_OMPT_HOST_EVENT(ompt_event_macro)
684 #undef ompt_event_macro
686 #define ompt_event_macro(event_name, callback_type, event_id) \
688 ompt_callback_t mycb = \
689 (ompt_callback_t)ompt_target_callbacks.ompt_callback(event_name); \
690 if (ompt_target_enabled.event_name && mycb) { \
692 return ompt_get_callback_success; \
694 return ompt_get_callback_failure; \
697 FOREACH_OMPT_DEVICE_EVENT(ompt_event_macro)
699 #undef ompt_event_macro
701 #define ompt_event_macro(event_name, callback_type, event_id) \
702 case ompt_emi_event(event_name): { \
703 ompt_callback_t mycb = \
704 (ompt_callback_t)ompt_target_callbacks.ompt_emi_callback(event_name); \
705 if (ompt_target_enabled.ompt_emi_event(event_name) && \
706 mycb != (ompt_callback_t)(&ompt_emi_wrapper(event_name))) { \
708 return ompt_get_callback_success; \
710 return ompt_get_callback_failure; \
713 FOREACH_OMPT_NOEMI_EVENT(ompt_event_macro)
715 #undef ompt_event_macro
717 #define ompt_event_macro(event_name, callback_type, event_id) \
719 ompt_callback_t mycb = \
720 (ompt_callback_t)ompt_callbacks_noemi.ompt_callback(event_name); \
721 ompt_callback_t wrapper = \
722 (ompt_callback_t)ompt_target_callbacks.ompt_emi_callback(event_name); \
723 if (ompt_target_enabled.ompt_emi_event(event_name) && \
724 wrapper == (ompt_callback_t)(&ompt_emi_wrapper(event_name))) { \
726 return ompt_get_callback_success; \
728 return ompt_get_callback_failure; \
731 FOREACH_OMPT_NOEMI_EVENT(ompt_event_macro)
733 #undef ompt_event_macro
736 return ompt_get_callback_failure;
744 OMPT_API_ROUTINE
int ompt_get_parallel_info(
int ancestor_level,
745 ompt_data_t **parallel_data,
747 if (!ompt_enabled.enabled)
749 return __ompt_get_parallel_info_internal(ancestor_level, parallel_data,
753 OMPT_API_ROUTINE
int ompt_get_state(ompt_wait_id_t *wait_id) {
754 if (!ompt_enabled.enabled)
755 return ompt_state_work_serial;
756 int thread_state = __ompt_get_state_internal(wait_id);
758 if (thread_state == ompt_state_undefined) {
759 thread_state = ompt_state_work_serial;
769 OMPT_API_ROUTINE ompt_data_t *ompt_get_thread_data(
void) {
770 if (!ompt_enabled.enabled)
772 return __ompt_get_thread_data_internal();
775 OMPT_API_ROUTINE
int ompt_get_task_info(
int ancestor_level,
int *type,
776 ompt_data_t **task_data,
777 ompt_frame_t **task_frame,
778 ompt_data_t **parallel_data,
780 if (!ompt_enabled.enabled)
782 return __ompt_get_task_info_internal(ancestor_level, type, task_data,
783 task_frame, parallel_data, thread_num);
786 OMPT_API_ROUTINE
int ompt_get_task_memory(
void **addr,
size_t *size,
788 return __ompt_get_task_memory_internal(addr, size, block);
795 OMPT_API_ROUTINE
int ompt_get_num_procs(
void) {
798 return __kmp_avail_proc;
805 OMPT_API_ROUTINE
int ompt_get_num_places(
void) {
807 #if !KMP_AFFINITY_SUPPORTED
810 if (!KMP_AFFINITY_CAPABLE())
812 return __kmp_affinity_num_masks;
816 OMPT_API_ROUTINE
int ompt_get_place_proc_ids(
int place_num,
int ids_size,
819 #if !KMP_AFFINITY_SUPPORTED
823 int tmp_ids[ids_size];
824 for (
int j = 0; j < ids_size; j++)
826 if (!KMP_AFFINITY_CAPABLE())
828 if (place_num < 0 || place_num >= (
int)__kmp_affinity_num_masks)
832 kmp_affin_mask_t *mask = KMP_CPU_INDEX(__kmp_affinity_masks, place_num);
834 KMP_CPU_SET_ITERATE(i, mask) {
835 if ((!KMP_CPU_ISSET(i, __kmp_affin_fullMask)) ||
836 (!KMP_CPU_ISSET(i, mask))) {
839 if (count < ids_size)
843 if (ids_size >= count) {
844 for (i = 0; i < count; i++) {
852 OMPT_API_ROUTINE
int ompt_get_place_num(
void) {
854 #if !KMP_AFFINITY_SUPPORTED
857 if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
862 if (!KMP_AFFINITY_CAPABLE())
864 gtid = __kmp_entry_gtid();
865 thread = __kmp_thread_from_gtid(gtid);
866 if (thread == NULL || thread->th.th_current_place < 0)
868 return thread->th.th_current_place;
872 OMPT_API_ROUTINE
int ompt_get_partition_place_nums(
int place_nums_size,
875 #if !KMP_AFFINITY_SUPPORTED
878 if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
881 int i, gtid, place_num, first_place, last_place, start, end;
883 if (!KMP_AFFINITY_CAPABLE())
885 gtid = __kmp_entry_gtid();
886 thread = __kmp_thread_from_gtid(gtid);
889 first_place = thread->th.th_first_place;
890 last_place = thread->th.th_last_place;
891 if (first_place < 0 || last_place < 0)
893 if (first_place <= last_place) {
900 if (end - start <= place_nums_size)
901 for (i = 0, place_num = start; place_num <= end; ++place_num, ++i) {
902 place_nums[i] = place_num;
904 return end - start + 1;
912 OMPT_API_ROUTINE
int ompt_get_proc_id(
void) {
913 if (!ompt_enabled.enabled || __kmp_get_gtid() < 0)
916 return sched_getcpu();
919 GetCurrentProcessorNumberEx(&pn);
920 return 64 * pn.Group + pn.Number;
943 int __kmp_control_tool(uint64_t command, uint64_t modifier,
void *arg) {
945 if (ompt_enabled.enabled) {
946 if (ompt_enabled.ompt_callback_control_tool) {
947 return ompt_callbacks.ompt_callback(ompt_callback_control_tool)(
948 command, modifier, arg, OMPT_LOAD_RETURN_ADDRESS(__kmp_entry_gtid()));
961 OMPT_API_ROUTINE uint64_t ompt_get_unique_id(
void) {
962 return __ompt_get_unique_id_internal();
965 OMPT_API_ROUTINE
void ompt_finalize_tool(
void) { __kmp_internal_end_atexit(); }
971 OMPT_API_ROUTINE
int ompt_get_target_info(uint64_t *device_num,
972 ompt_id_t *target_id,
973 ompt_id_t *host_op_id) {
977 OMPT_API_ROUTINE
int ompt_get_num_devices(
void) {
985 static ompt_interface_fn_t ompt_fn_lookup(
const char *s) {
987 #define ompt_interface_fn(fn) \
988 fn##_t fn##_f = fn; \
989 if (strcmp(s, #fn) == 0) \
990 return (ompt_interface_fn_t)fn##_f;
992 FOREACH_OMPT_INQUIRY_FN(ompt_interface_fn)