35#ifndef OMPT_MULTIPLEX_H
36#define OMPT_MULTIPLEX_H
65#ifdef OMPT_MULTIPLEX_TOOL_NAME
66#ifndef CLIENT_TOOL_LIBRARIES_VAR
67#define CLIENT_TOOL_LIBRARIES_VAR OMPT_MULTIPLEX_TOOL_NAME "_TOOL_LIBRARIES"
69#ifndef CLIENT_TOOL_VERBOSE_INIT_VAR
70#define CLIENT_TOOL_VERBOSE_INIT_VAR \
71 OMPT_MULTIPLEX_TOOL_NAME "_TOOL_VERBOSE_INIT"
77#ifndef CLIENT_TOOL_VERBOSE_INIT_VAR
78#warning CLIENT_TOOL_VERBOSE_INIT_VAR redefined to OMP_TOOL_VERBOSE_INIT
79#define CLIENT_TOOL_VERBOSE_INIT_VAR "OMP_TOOL_VERBOSE_INIT"
83#ifndef CLIENT_TOOL_LIBRARIES_VAR
84#error CLIENT_TOOL_LIBRARIES_VAR should be defined before including of ompt-multiplex.h
87#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) && \
88 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA)
89#error OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA must be set if OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA is set
92#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) && \
93 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA)
94#error OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA must be set if OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA is set
97#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA) && \
98 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA)
99#error OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA must be set if OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA is set
102#define OMPT_API_ROUTINE static
104#ifndef OMPT_STR_MATCH
105#define OMPT_STR_MATCH(haystack, needle) (!strcasecmp(haystack, needle))
112#define OMPT_VERBOSE_INIT_PRINT(...) \
114 fprintf(verbose_file, __VA_ARGS__)
115#define OMPT_VERBOSE_INIT_CONTINUED_PRINT(...) \
117 fprintf(verbose_file, __VA_ARGS__)
119static FILE *verbose_file;
120static int verbose_init;
126 if (ompt_env_verbose_init && strcmp(ompt_env_verbose_init,
"") &&
130 verbose_file = stderr;
132 verbose_file = stdout;
134 getenv(
"OMP_TOOL_VERBOSE_INIT")))
135 verbose_file = fopen(ompt_env_verbose_init,
"w");
138 printf(
"Multiplex: Can not open file defined in OMP_TOOL_VERBOSE_INIT "
145#define OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(macro) \
146 macro(callback_thread_begin, ompt_callback_thread_begin_t, 1); \
147 macro(callback_thread_end, ompt_callback_thread_end_t, 2); \
148 macro(callback_parallel_begin, ompt_callback_parallel_begin_t, 3); \
149 macro(callback_parallel_end, ompt_callback_parallel_end_t, 4); \
150 macro(callback_task_create, ompt_callback_task_create_t, 5); \
151 macro(callback_task_schedule, ompt_callback_task_schedule_t, 6); \
152 macro(callback_implicit_task, ompt_callback_implicit_task_t, 7); \
153 macro(callback_target, ompt_callback_target_t, 8); \
154 macro(callback_target_data_op, ompt_callback_target_data_op_t, 9); \
155 macro(callback_target_submit, ompt_callback_target_submit_t, 10); \
156 macro(callback_control_tool, ompt_callback_control_tool_t, 11); \
157 macro(callback_device_initialize, ompt_callback_device_initialize_t, 12); \
158 macro(callback_device_finalize, ompt_callback_device_finalize_t, 13); \
159 macro(callback_device_load, ompt_callback_device_load_t, 14); \
160 macro(callback_device_unload, ompt_callback_device_unload_t, 15); \
161 macro(callback_sync_region_wait, ompt_callback_sync_region_t, 16); \
162 macro(callback_mutex_released, ompt_callback_mutex_t, 17); \
163 macro(callback_dependences, ompt_callback_dependences_t, 18); \
164 macro(callback_task_dependence, ompt_callback_task_dependence_t, 19); \
165 macro(callback_work, ompt_callback_work_t, 20); \
166 macro(callback_masked, ompt_callback_masked_t, 21); \
167 macro(callback_target_map, ompt_callback_target_map_t, 22); \
168 macro(callback_sync_region, ompt_callback_sync_region_t, 23); \
169 macro(callback_lock_init, ompt_callback_mutex_acquire_t, 24); \
170 macro(callback_lock_destroy, ompt_callback_mutex_t, 25); \
171 macro(callback_mutex_acquire, ompt_callback_mutex_acquire_t, 26); \
172 macro(callback_mutex_acquired, ompt_callback_mutex_t, 27); \
173 macro(callback_nest_lock, ompt_callback_nest_lock_t, 28); \
174 macro(callback_flush, ompt_callback_flush_t, 29); \
175 macro(callback_cancel, ompt_callback_cancel_t, 30); \
176 macro(callback_reduction, ompt_callback_sync_region_t, 31); \
177 macro(callback_dispatch, ompt_callback_dispatch_t, 32); \
178 macro(callback_thread_role_shift, ompt_callback_thread_role_shift_t, 38);
180typedef struct ompt_multiplex_callbacks_s {
181#define ompt_event_macro(event, callback, eventid) callback ompt_##event
185#undef ompt_event_macro
188typedef struct ompt_multiplex_callback_implementation_status_s {
189#define ompt_event_macro(event, callback, eventid) int ompt_##event
193#undef ompt_event_macro
204typedef struct ompt_multiplex_data_pair_s {
209#if !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) || \
210 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) || \
211 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA)
213ompt_multiplex_allocate_data_pair(
ompt_data_t *data_pointer) {
215 if (!data_pointer->
ptr) {
216 printf(
"Malloc ERROR\n");
226static void ompt_multiplex_free_data_pair(
ompt_data_t *data_pointer) {
227 free((*data_pointer).ptr);
254#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
255 return ompt_multiplex_get_own_ompt_data(data);
262#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
263 return ompt_multiplex_get_own_ompt_data(data);
270#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
271 return ompt_multiplex_get_own_ompt_data(data);
278#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
279 return ompt_multiplex_get_client_ompt_data(data);
281 return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA(data);
286#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
287 return ompt_multiplex_get_client_ompt_data(data);
289 return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(data);
294#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
295 return ompt_multiplex_get_client_ompt_data(data);
297 return OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA(data);
301static void ompt_multiplex_callback_mutex_acquire(
ompt_mutex_t kind,
305 const void *codeptr_ra) {
308 kind, hint, impl, wait_id, codeptr_ra);
312 kind, hint, impl, wait_id, codeptr_ra);
316static void ompt_multiplex_callback_mutex_acquired(
ompt_mutex_t kind,
318 const void *codeptr_ra) {
329static void ompt_multiplex_callback_mutex_released(
ompt_mutex_t kind,
331 const void *codeptr_ra) {
344 const void *codeptr_ra) {
359 const void *codeptr_ra) {
362 kind, endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
363 ompt_multiplex_get_own_task_data(task_data), codeptr_ra);
367 kind, endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
368 ompt_multiplex_get_client_task_data(task_data), codeptr_ra);
372static void ompt_multiplex_callback_sync_region_wait(
375 const void *codeptr_ra) {
378 kind, endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
379 ompt_multiplex_get_own_task_data(task_data), codeptr_ra);
383 kind, endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
384 ompt_multiplex_get_client_task_data(task_data), codeptr_ra);
388static void ompt_multiplex_callback_flush(
ompt_data_t *thread_data,
389 const void *codeptr_ra) {
392 ompt_multiplex_get_own_thread_data(thread_data), codeptr_ra);
396 ompt_multiplex_get_client_thread_data(thread_data), codeptr_ra);
400static void ompt_multiplex_callback_cancel(
ompt_data_t *task_data,
int flags,
401 const void *codeptr_ra) {
404 ompt_multiplex_get_own_task_data(task_data), flags, codeptr_ra);
408 ompt_multiplex_get_client_task_data(task_data), flags, codeptr_ra);
412static void ompt_multiplex_callback_implicit_task(
414 ompt_data_t *task_data,
unsigned int team_size,
unsigned int thread_num,
417#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
418 ompt_multiplex_allocate_data_pair(task_data);
420#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
422 ompt_multiplex_allocate_data_pair(parallel_data);
426 endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
427 ompt_multiplex_get_own_task_data(task_data), team_size, thread_num,
432 endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
433 ompt_multiplex_get_client_task_data(task_data), team_size, thread_num,
439#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) || \
440 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA)
443 endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
444 ompt_multiplex_get_own_task_data(task_data), team_size, thread_num,
451 endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
452 ompt_multiplex_get_client_task_data(task_data), team_size, thread_num,
456#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) && \
457 !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA)
460 endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
461 ompt_multiplex_get_own_task_data(task_data), team_size, thread_num,
466#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
467 ompt_multiplex_free_data_pair(task_data);
470#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA)
472 OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA(parallel_data);
474#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA)
475 OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA(task_data);
480static void ompt_multiplex_callback_lock_init(
ompt_mutex_t kind,
484 const void *codeptr_ra) {
487 wait_id, codeptr_ra);
491 kind, hint, impl, wait_id, codeptr_ra);
495static void ompt_multiplex_callback_lock_destroy(
ompt_mutex_t kind,
497 const void *codeptr_ra) {
508static void ompt_multiplex_callback_work(
ompt_work_t wstype,
512 const void *codeptr_ra) {
515 wstype, endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
516 ompt_multiplex_get_own_task_data(task_data), count, codeptr_ra);
521 ompt_multiplex_get_client_parallel_data(parallel_data),
522 ompt_multiplex_get_client_task_data(task_data), count, codeptr_ra);
529 const void *codeptr_ra) {
532 endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
533 ompt_multiplex_get_own_task_data(task_data), codeptr_ra);
537 endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
538 ompt_multiplex_get_client_task_data(task_data), codeptr_ra);
542static void ompt_multiplex_callback_thread_role_shift(
ompt_data_t *thread_data,
547 ompt_multiplex_get_own_thread_data(thread_data), prior_role, next_role);
551 ompt_multiplex_get_client_thread_data(thread_data), prior_role, next_role);
555static void ompt_multiplex_callback_parallel_begin(
557 ompt_data_t *parallel_data, uint32_t requested_team_size,
int flag,
558 const void *codeptr_ra) {
559#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
560 ompt_multiplex_allocate_data_pair(parallel_data);
564 ompt_multiplex_get_own_task_data(parent_task_data), parent_task_frame,
565 ompt_multiplex_get_own_parallel_data(parallel_data),
566 requested_team_size, flag, codeptr_ra);
570 ompt_multiplex_get_client_task_data(parent_task_data),
572 ompt_multiplex_get_client_parallel_data(parallel_data),
573 requested_team_size, flag, codeptr_ra);
577static void ompt_multiplex_callback_parallel_end(
ompt_data_t *parallel_data,
580 const void *codeptr_ra) {
583#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA) || \
584 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA)
587 ompt_multiplex_get_own_parallel_data(parallel_data),
588 ompt_multiplex_get_own_task_data(task_data), flag, codeptr_ra);
594 ompt_multiplex_get_client_parallel_data(parallel_data),
595 ompt_multiplex_get_client_task_data(task_data), flag, codeptr_ra);
598#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA) && \
599 !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA)
602 ompt_multiplex_get_own_parallel_data(parallel_data),
603 ompt_multiplex_get_own_task_data(task_data), flag, codeptr_ra);
607#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
608 ompt_multiplex_free_data_pair(parallel_data);
611#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA)
612 OMPT_MULTIPLEX_CUSTOM_DELETE_PARALLEL_DATA(parallel_data);
616static void ompt_multiplex_callback_task_create(
618 ompt_data_t *new_task_data,
int type,
int has_dependences,
619 const void *codeptr_ra) {
620#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
621 ompt_multiplex_allocate_data_pair(new_task_data);
624#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
627 ompt_multiplex_get_parallel_info(0, ¶llel_data, NULL);
628 ompt_multiplex_allocate_data_pair(parallel_data);
634 ompt_multiplex_get_own_task_data(parent_task_data), parent_frame,
635 ompt_multiplex_get_own_task_data(new_task_data), type, has_dependences,
640 ompt_multiplex_get_client_task_data(parent_task_data), parent_frame,
641 ompt_multiplex_get_client_task_data(new_task_data), type,
642 has_dependences, codeptr_ra);
647ompt_multiplex_callback_task_schedule(
ompt_data_t *first_task_data,
653 ompt_multiplex_get_own_task_data(first_task_data), prior_task_status,
654 ompt_multiplex_get_own_task_data(second_task_data));
658 ompt_multiplex_get_client_task_data(first_task_data),
660 ompt_multiplex_get_client_task_data(second_task_data));
665#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA) || \
666 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA)
669 ompt_multiplex_get_own_task_data(first_task_data), prior_task_status,
670 ompt_multiplex_get_own_task_data(second_task_data));
676 ompt_multiplex_get_client_task_data(first_task_data),
678 ompt_multiplex_get_client_task_data(second_task_data));
681#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA) && \
682 !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA)
685 ompt_multiplex_get_own_task_data(first_task_data), prior_task_status,
686 ompt_multiplex_get_own_task_data(second_task_data));
690#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
691 ompt_multiplex_free_data_pair(first_task_data);
694#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA)
695 OMPT_MULTIPLEX_CUSTOM_DELETE_TASK_DATA(first_task_data);
700static void ompt_multiplex_callback_dependences(
ompt_data_t *task_data,
705 ompt_multiplex_get_own_task_data(task_data), deps, ndeps);
709 ompt_multiplex_get_client_task_data(task_data), deps, ndeps);
714ompt_multiplex_callback_task_dependence(
ompt_data_t *first_task_data,
718 ompt_multiplex_get_own_task_data(first_task_data),
719 ompt_multiplex_get_own_task_data(second_task_data));
723 ompt_multiplex_get_client_task_data(first_task_data),
724 ompt_multiplex_get_client_task_data(second_task_data));
728static void ompt_multiplex_callback_thread_begin(
ompt_thread_t thread_type,
730#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
731 ompt_multiplex_allocate_data_pair(thread_data);
735 thread_type, ompt_multiplex_get_own_thread_data(thread_data));
739 thread_type, ompt_multiplex_get_client_thread_data(thread_data));
743static void ompt_multiplex_callback_thread_end(
ompt_data_t *thread_data) {
746#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA) || \
747 !defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA)
750 ompt_multiplex_get_own_thread_data(thread_data));
756 ompt_multiplex_get_client_thread_data(thread_data));
759#if defined(OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA) && \
760 !defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA)
763 ompt_multiplex_get_own_thread_data(thread_data));
767#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
768 ompt_multiplex_free_data_pair(thread_data);
771#if defined(OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA)
772 OMPT_MULTIPLEX_CUSTOM_DELETE_THREAD_DATA(thread_data);
776static int ompt_multiplex_callback_control_tool(uint64_t command,
777 uint64_t modifier,
void *arg,
778 const void *codeptr_ra) {
779 int ownRet = 0, clientRet = 0;
782 command, modifier, arg, codeptr_ra);
786 command, modifier, arg, codeptr_ra);
788 return ownRet < clientRet ? ownRet : clientRet;
791static void ompt_multiplex_callback_target(
796 kind, endpoint, device_num, ompt_multiplex_get_own_task_data(task_data),
797 target_id, codeptr_ra);
801 kind, endpoint, device_num,
802 ompt_multiplex_get_client_task_data(task_data), target_id, codeptr_ra);
806static void ompt_multiplex_callback_target_data_op(
808 void *src_addr,
int src_device_num,
void *dest_addr,
int dest_device_num,
809 size_t bytes,
const void *codeptr_ra) {
812 target_id, host_op_id, optype, src_addr, src_device_num, dest_addr,
813 dest_device_num, bytes, codeptr_ra);
817 target_id, host_op_id, optype, src_addr, src_device_num, dest_addr,
818 dest_device_num, bytes, codeptr_ra);
824 unsigned int requested_num_teams) {
827 target_id, host_op_id, requested_num_teams);
831 target_id, host_op_id, requested_num_teams);
835static void ompt_multiplex_callback_device_initialize(
840 device_num, type, device, lookup, documentation);
844 device_num, type, device, lookup, documentation);
848static void ompt_multiplex_callback_device_finalize(
int device_num) {
858ompt_multiplex_callback_device_load(
int device_num,
const char *filename,
859 int64_t offset_in_file,
void *vma_in_file,
860 size_t bytes,
void *host_addr,
861 void *device_addr, uint64_t module_id) {
864 device_num, filename, offset_in_file, vma_in_file, bytes, host_addr,
865 device_addr, module_id);
869 device_num, filename, offset_in_file, vma_in_file, bytes, host_addr,
870 device_addr, module_id);
874static void ompt_multiplex_callback_device_unload(
int device_num,
875 uint64_t module_id) {
887ompt_multiplex_callback_target_map(
ompt_id_t target_id,
unsigned int nitems,
888 void **host_addr,
void **device_addr,
889 size_t *bytes,
unsigned int *mapping_flags,
890 const void *codeptr_ra) {
893 target_id, nitems, host_addr, device_addr, bytes, mapping_flags,
898 target_id, nitems, host_addr, device_addr, bytes, mapping_flags,
907 const void *codeptr_ra) {
910 kind, endpoint, ompt_multiplex_get_own_parallel_data(parallel_data),
911 ompt_multiplex_get_own_task_data(task_data), codeptr_ra);
915 kind, endpoint, ompt_multiplex_get_client_parallel_data(parallel_data),
916 ompt_multiplex_get_client_task_data(task_data), codeptr_ra);
920static void ompt_multiplex_callback_dispatch(
ompt_data_t *parallel_data,
926 ompt_multiplex_get_own_parallel_data(parallel_data),
927 ompt_multiplex_get_own_task_data(task_data), kind, instance);
931 ompt_multiplex_get_client_parallel_data(parallel_data),
932 ompt_multiplex_get_client_task_data(task_data), kind, instance);
943 int ret = ompt_multiplex_get_task_info(ancestor_level, type, task_data,
944 task_frame, parallel_data, thread_num);
946#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
948 *task_data = ompt_multiplex_get_own_ompt_data(*task_data);
950#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
952 *parallel_data = ompt_multiplex_get_own_ompt_data(*parallel_data);
962 int ret = ompt_multiplex_get_task_info(ancestor_level, type, task_data,
963 task_frame, parallel_data, thread_num);
966#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA
967 *task_data = ompt_multiplex_get_client_ompt_data(*task_data);
969 *task_data = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_TASK_DATA(*task_data);
973#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
974 *parallel_data = ompt_multiplex_get_client_ompt_data(*parallel_data);
977 OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(*parallel_data);
984#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
985 ret = ompt_multiplex_get_own_ompt_data(ompt_multiplex_get_thread_data());
987 ret = ompt_multiplex_get_thread_data();
994#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA
995 ret = ompt_multiplex_get_client_ompt_data(ompt_multiplex_get_thread_data());
997 ret = OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_THREAD_DATA(
998 ompt_multiplex_get_thread_data());
1006 int ret = ompt_multiplex_get_parallel_info(ancestor_level, parallel_data,
1009 *parallel_data = ompt_multiplex_get_own_parallel_data(*parallel_data);
1016 int ret = ompt_multiplex_get_parallel_info(ancestor_level, parallel_data,
1019#ifndef OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA
1020 *parallel_data = ompt_multiplex_get_client_ompt_data(*parallel_data);
1023 OMPT_MULTIPLEX_CUSTOM_GET_CLIENT_PARALLEL_DATA(*parallel_data);
1032#define ompt_event_macro(event_name, callback_type, event_id) \
1033 case ompt_##event_name: \
1034 ompt_multiplex_own_callbacks.ompt_##event_name = (callback_type)callback; \
1035 if (ompt_multiplex_implementation_status.ompt_##event_name == -1) \
1036 return ompt_multiplex_implementation_status.ompt_##event_name = \
1037 ompt_multiplex_set_callback( \
1038 ompt_##event_name, \
1039 (ompt_callback_t)&ompt_multiplex_##event_name); \
1041 return ompt_multiplex_implementation_status.ompt_##event_name
1045#undef ompt_event_macro
1057#define ompt_event_macro(event_name, callback_type, event_id) \
1058 case ompt_##event_name: \
1059 ompt_multiplex_client_callbacks.ompt_##event_name = \
1060 (callback_type)callback; \
1061 if (ompt_multiplex_implementation_status.ompt_##event_name == -1) \
1062 return ompt_multiplex_implementation_status.ompt_##event_name = \
1063 ompt_multiplex_set_callback( \
1064 ompt_##event_name, \
1065 (ompt_callback_t)&ompt_multiplex_##event_name); \
1067 return ompt_multiplex_implementation_status.ompt_##event_name
1071#undef ompt_event_macro
1079 if (!strcmp(name,
"ompt_set_callback"))
1081 else if (!strcmp(name,
"ompt_get_task_info"))
1083 else if (!strcmp(name,
"ompt_get_thread_data"))
1085 else if (!strcmp(name,
"ompt_get_parallel_info"))
1092 if (!strcmp(name,
"ompt_set_callback"))
1094 else if (!strcmp(name,
"ompt_get_task_info"))
1096 else if (!strcmp(name,
"ompt_get_thread_data"))
1098 else if (!strcmp(name,
"ompt_get_parallel_info"))
1107 ompt_multiplex_set_callback =
1109 ompt_multiplex_get_task_info =
1111 ompt_multiplex_get_thread_data =
1113 ompt_multiplex_get_parallel_info =
1117#define ompt_event_macro(event_name, callback_type, event_id) \
1118 ompt_multiplex_implementation_status.ompt_##event_name = -1
1122#undef ompt_event_macro
1133 return ownRet > clientRet ? ownRet : clientRet;
1150ompt_multiplex_own_start_tool(
unsigned int omp_version,
1151 const char *runtime_version);
1155 const char *runtime_version) {
1158 "----- START LOGGING OF CLIENT TOOL REGISTRATION -----\n");
1162 const char *tool_libs = getenv(CLIENT_TOOL_LIBRARIES_VAR);
1167 char *tool_libs_buffer = strdup(tool_libs);
1168 if (!tool_libs_buffer) {
1169 printf(
"strdup Error (%i)\n", errno);
1173 size_t progress = 0;
1176 while (progress < strlen(tool_libs)) {
1179 const char *) = NULL;
1181 "Look for candidates within " CLIENT_TOOL_LIBRARIES_VAR
"...\n");
1182 size_t tmp_progress = progress;
1183 while (tmp_progress < strlen(tool_libs) &&
1184 tool_libs_buffer[tmp_progress] !=
':')
1186 if (tmp_progress < strlen(tool_libs))
1187 tool_libs_buffer[tmp_progress] = 0;
1189 char *fname = tool_libs_buffer + progress;
1191 void *h = dlopen(fname, RTLD_LAZY);
1195 dlsym(h,
"ompt_start_tool");
1196 if (client_start_tool &&
1198 (*client_start_tool)(omp_version, runtime_version))) {
1201 "Tool was started and is using the OMPT interface.\n");
1205 "Failed: client_start_tool = %p, ompt_multiplex_client_fns = %p, "
1211 printf(
"Loading %s from %s failed with: %s\n",
1212 tool_libs_buffer + progress, CLIENT_TOOL_LIBRARIES_VAR,
1215 progress = tmp_progress + 1;
1217 free(tool_libs_buffer);
1219 "----- END LOGGING OF CLIENT TOOL REGISTRATION -----\n");
1223 "----- START LOGGING OF OWN TOOL REGISTRATION -----\n");
1225 ompt_multiplex_own_start_tool(omp_version, runtime_version);
1232 if (verbose_init && verbose_file != stderr && verbose_file != stdout)
1233 fclose(verbose_file);
1238 return &ompt_start_tool_result;
1246#define ompt_start_tool ompt_multiplex_own_start_tool
#define DLB_EXPORT_SYMBOL
Definition: dlb_common.h:39
OMPT_API_ROUTINE int ompt_multiplex_own_set_callback(ompt_callbacks_t which, ompt_callback_t callback)
Definition: ompt-multiplex.h:1028
#define OMPT_VERBOSE_INIT_CONTINUED_PRINT(...)
Definition: ompt-multiplex.h:115
#define ompt_event_macro(event, callback, eventid)
Definition: ompt-multiplex.h:189
#define OMPT_STR_MATCH(haystack, needle)
Definition: ompt-multiplex.h:105
ompt_multiplex_callback_implementation_status_t ompt_multiplex_implementation_status
Definition: ompt-multiplex.h:202
#define ompt_start_tool
Definition: ompt-multiplex.h:1246
#define OMPT_VERBOSE_INIT_PRINT(...)
Definition: ompt-multiplex.h:112
ompt_interface_fn_t ompt_multiplex_client_lookup(const char *name)
Definition: ompt-multiplex.h:1091
int ompt_multiplex_own_get_parallel_info(int ancestor_level, ompt_data_t **parallel_data, int *team_size)
Definition: ompt-multiplex.h:1003
ompt_interface_fn_t ompt_multiplex_own_lookup(const char *name)
Definition: ompt-multiplex.h:1078
OMPT_API_ROUTINE int ompt_multiplex_client_set_callback(ompt_callbacks_t which, ompt_callback_t callback)
Definition: ompt-multiplex.h:1053
#define OMPT_LOAD_CLIENT_FOREACH_OMPT_EVENT(macro)
Definition: ompt-multiplex.h:145
ompt_data_t * ompt_multiplex_own_get_thread_data()
Definition: ompt-multiplex.h:982
ompt_function_lookup_t ompt_multiplex_lookup_function
Definition: ompt-multiplex.h:198
ompt_multiplex_callbacks_t ompt_multiplex_own_callbacks
Definition: ompt-multiplex.h:199
#define OMPT_API_ROUTINE
Definition: ompt-multiplex.h:102
void ompt_multiplex_finalize(ompt_data_t *fns)
Definition: ompt-multiplex.h:1136
ompt_start_tool_result_t * ompt_multiplex_own_fns
Definition: ompt-multiplex.h:196
int ompt_multiplex_own_get_task_info(int ancestor_level, int *type, ompt_data_t **task_data, ompt_frame_t **task_frame, ompt_data_t **parallel_data, int *thread_num)
Definition: ompt-multiplex.h:938
#define CLIENT_TOOL_VERBOSE_INIT_VAR
Definition: ompt-multiplex.h:79
int ompt_multiplex_initialize(ompt_function_lookup_t lookup, int initial_device_num, ompt_data_t *data)
Definition: ompt-multiplex.h:1104
int ompt_multiplex_client_get_parallel_info(int ancestor_level, ompt_data_t **parallel_data, int *team_size)
Definition: ompt-multiplex.h:1013
ompt_multiplex_callbacks_t ompt_multiplex_client_callbacks
Definition: ompt-multiplex.h:200
ompt_start_tool_result_t * ompt_multiplex_client_fns
Definition: ompt-multiplex.h:197
int ompt_multiplex_client_get_task_info(int ancestor_level, int *type, ompt_data_t **task_data, ompt_frame_t **task_frame, ompt_data_t **parallel_data, int *thread_num)
Definition: ompt-multiplex.h:957
void setup_verbose_init()
Definition: ompt-multiplex.h:122
ompt_data_t * ompt_multiplex_client_get_thread_data()
Definition: ompt-multiplex.h:992
Definition: omp-tools.h:577
Definition: omp-tools.h:526
Definition: ompt-multiplex.h:188
Definition: ompt-multiplex.h:180
Definition: ompt-multiplex.h:204
ompt_data_t own_data
Definition: ompt-multiplex.h:205
ompt_data_t client_data
Definition: ompt-multiplex.h:206
Definition: omp-tools.h:521
void * ptr
Definition: omp-tools.h:523