Index: runtime/test/ompt/callback.h =================================================================== --- runtime/test/ompt/callback.h +++ runtime/test/ompt/callback.h @@ -34,6 +34,8 @@ }; static ompt_set_callback_t ompt_set_callback; +static ompt_get_callback_t ompt_get_callback; +static ompt_get_state_t ompt_get_state; static ompt_get_task_info_t ompt_get_task_info; static ompt_get_thread_data_t ompt_get_thread_data; static ompt_get_parallel_info_t ompt_get_parallel_info; @@ -681,6 +683,8 @@ ompt_data_t *tool_data) { ompt_set_callback = (ompt_set_callback_t) lookup("ompt_set_callback"); + ompt_get_callback = (ompt_get_callback_t) lookup("ompt_get_callback"); + ompt_get_state = (ompt_get_state_t) lookup("ompt_get_state"); ompt_get_task_info = (ompt_get_task_info_t) lookup("ompt_get_task_info"); ompt_get_thread_data = (ompt_get_thread_data_t) lookup("ompt_get_thread_data"); ompt_get_parallel_info = (ompt_get_parallel_info_t) lookup("ompt_get_parallel_info"); Index: runtime/test/ompt/misc/api_calls.c =================================================================== --- runtime/test/ompt/misc/api_calls.c +++ /dev/null @@ -1,72 +0,0 @@ -// RUN: %libomp-compile && env OMP_PLACES=cores %libomp-run | FileCheck %s -// REQUIRES: ompt, linux -#include "callback.h" -#include -#define __USE_GNU -#include -#undef __USE_GNU - -void print_list(char* function_name, int list[]) -{ - printf("%" PRIu64 ": %s(0)=(%d", ompt_get_thread_data()->value, function_name, list[0]); - int i; - for(i = 1; i < omp_get_place_num_procs(0); i++) - { - printf(",%d", list[i]); - } - printf(")\n"); -} - -int main() -{ - #pragma omp parallel num_threads(1) - { - printf("%" PRIu64 ": omp_get_num_places()=%d\n", ompt_get_thread_data()->value, omp_get_num_places()); - printf("%" PRIu64 ": ompt_get_num_places()=%d\n", ompt_get_thread_data()->value, ompt_get_num_places()); - - int omp_ids[omp_get_place_num_procs(0)]; - omp_get_place_proc_ids(0, omp_ids); - print_list("omp_get_place_proc_ids" ,omp_ids); - int ompt_ids[omp_get_place_num_procs(0)]; - ompt_get_place_proc_ids(0, omp_get_place_num_procs(0), ompt_ids); - print_list("ompt_get_place_proc_ids", ompt_ids); - - printf("%" PRIu64 ": omp_get_place_num()=%d\n", ompt_get_thread_data()->value, omp_get_place_num()); - printf("%" PRIu64 ": ompt_get_place_num()=%d\n", ompt_get_thread_data()->value, ompt_get_place_num()); - - int omp_nums[omp_get_partition_num_places()]; - omp_get_partition_place_nums(omp_nums); - print_list("omp_get_partition_place_nums" ,omp_nums); - int ompt_nums[omp_get_partition_num_places()]; - ompt_get_partition_place_nums(omp_get_partition_num_places(), ompt_nums); - print_list("ompt_get_partition_place_nums", ompt_nums); - - printf("%" PRIu64 ": sched_getcpu()=%d\n", ompt_get_thread_data()->value, sched_getcpu()); - printf("%" PRIu64 ": ompt_get_proc_id()=%d\n", ompt_get_thread_data()->value, ompt_get_proc_id()); - - printf("%" PRIu64 ": omp_get_num_procs()=%d\n", ompt_get_thread_data()->value, omp_get_num_procs()); - printf("%" PRIu64 ": ompt_get_num_procs()=%d\n", ompt_get_thread_data()->value, ompt_get_num_procs()); - } - - // Check if libomp supports the callbacks for this test. - - // CHECK: 0: NULL_POINTER=[[NULL:.*$]] - - // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: omp_get_num_places()=[[NUM_PLACES:[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_places()=[[NUM_PLACES]] - - // CHECK: {{^}}[[MASTER_ID]]: omp_get_place_proc_ids(0)=([[PROC_IDS:[0-9\,]+]]) - // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids(0)=([[PROC_IDS]]) - - // CHECK: {{^}}[[MASTER_ID]]: omp_get_place_num()=[[PLACE_NUM:[-]?[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=[[PLACE_NUM]] - - // CHECK: {{^}}[[MASTER_ID]]: sched_getcpu()=[[CPU_ID:[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=[[CPU_ID]] - - // CHECK: {{^}}[[MASTER_ID]]: omp_get_num_procs()=[[NUM_PROCS:[-]?[0-9]+]] - // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()=[[NUM_PROCS]] - - - return 0; -} Index: runtime/test/ompt/misc/api_calls_misc.c =================================================================== --- /dev/null +++ runtime/test/ompt/misc/api_calls_misc.c @@ -0,0 +1,69 @@ +// RUN: %libomp-compile && %libomp-run | FileCheck %s +// REQUIRES: ompt +#include "callback.h" +#include + +int main() +{ + #pragma omp parallel num_threads(1) + { + //ompt_get_callback() + ompt_callback_t callback; + ompt_get_callback(ompt_callback_thread_begin, &callback); + printf("%" PRIu64 ": &on_ompt_callback_thread_begin=%p\n", ompt_get_thread_data()->value, &on_ompt_callback_thread_begin); + printf("%" PRIu64 ": ompt_get_callback() result=%p\n", ompt_get_thread_data()->value, callback); + + //ompt_get_state() + printf("%" PRIu64 ": ompt_get_state()=%d\n", ompt_get_thread_data()->value, ompt_get_state(NULL)); + + //ompt_enumerate_states() + int state = omp_state_undefined; + const char *state_name; + int steps; + while(ompt_enumerate_states(state, &state, &state_name) && steps < 1000) + { + steps++; + if(!state_name) + printf("%" PRIu64 ": state_name is NULL\n", ompt_get_thread_data()->value); + } + if(steps >= 1000) + { + //enumeration did not end after 1000 steps + printf("%" PRIu64 ": states enumeration did not end after 1000 steps\n", ompt_get_thread_data()->value); + } + + //ompt_enumerate_mutex_impls() + int impl = ompt_mutex_impl_unknown; + const char *impl_name; + steps = 0; + while (ompt_enumerate_mutex_impls(impl, &impl, &impl_name) && steps < 1000) + { + steps++; + if(!impl_name) + printf("%" PRIu64 ": impl_name is NULL\n", ompt_get_thread_data()->value); + } + if(steps >= 1000) + { + //enumeration did not end after 1000 steps + printf("%" PRIu64 ": mutex_impls enumeration did not end after 1000 steps\n", ompt_get_thread_data()->value); + } + + } + + // Check if libomp supports the callbacks for this test. + + // CHECK: 0: NULL_POINTER=[[NULL:.*$]] + + // CHECK: {{^}}[[THREAD_ID:[0-9]+]]: &on_ompt_callback_thread_begin=[[FUNCTION_POINTER:0x[0-f]+]] + // CHECK: {{^}}[[THREAD_ID]]: ompt_get_callback() result=[[FUNCTION_POINTER]] + + // CHECK: {{^}}[[THREAD_ID]]: ompt_get_state()=1 + + // CHECK-NOT: {{^}}[[THREAD_ID]]: state_name is NULL + // CHECK-NOT: {{^}}[[THREAD_ID]]: states enumeration did not end after 1000 steps + + // CHECK-NOT: {{^}}[[THREAD_ID]]: impl_name is NULL + // CHECK-NOT: {{^}}[[THREAD_ID]]: mutex_impls enumeration did not end after 1000 steps + + return 0; +} Index: runtime/test/ompt/misc/api_calls_places.c =================================================================== --- /dev/null +++ runtime/test/ompt/misc/api_calls_places.c @@ -0,0 +1,76 @@ +// RUN: %libomp-compile && env OMP_PLACES=cores %libomp-run | FileCheck %s +// REQUIRES: ompt, linux +#include "callback.h" +#include +#define __USE_GNU +#include +#undef __USE_GNU + +void print_list(char* function_name, int size, int list[]) +{ + printf("%" PRIu64 ": %s(0)=(%d", ompt_get_thread_data()->value, function_name, list[0]); + int i; + for(i = 1; i < size; i++) + { + printf(",%d", list[i]); + } + printf(")\n"); +} + +int main() +{ + #pragma omp parallel num_threads(1) + { + printf("%" PRIu64 ": omp_get_num_places()=%d\n", ompt_get_thread_data()->value, omp_get_num_places()); + printf("%" PRIu64 ": ompt_get_num_places()=%d\n", ompt_get_thread_data()->value, ompt_get_num_places()); + + int omp_ids_size = omp_get_place_num_procs(0); + int omp_ids[omp_ids_size]; + omp_get_place_proc_ids(0, omp_ids); + print_list("omp_get_place_proc_ids", omp_ids_size, omp_ids); + int ompt_ids_size = ompt_get_place_proc_ids(0, 0, NULL); + int ompt_ids[ompt_ids_size]; + ompt_get_place_proc_ids(0, ompt_ids_size, ompt_ids); + print_list("ompt_get_place_proc_ids", ompt_ids_size, ompt_ids); + + printf("%" PRIu64 ": omp_get_place_num()=%d\n", ompt_get_thread_data()->value, omp_get_place_num()); + printf("%" PRIu64 ": ompt_get_place_num()=%d\n", ompt_get_thread_data()->value, ompt_get_place_num()); + + int omp_nums_size = omp_get_partition_num_places(); + int omp_nums[omp_nums_size]; + omp_get_partition_place_nums(omp_nums); + print_list("omp_get_partition_place_nums", omp_nums_size, omp_nums); + int ompt_nums_size = ompt_get_partition_place_nums(0, NULL); + int ompt_nums[ompt_nums_size]; + ompt_get_partition_place_nums(ompt_nums_size, ompt_nums); + print_list("ompt_get_partition_place_nums", ompt_nums_size, ompt_nums); + + printf("%" PRIu64 ": sched_getcpu()=%d\n", ompt_get_thread_data()->value, sched_getcpu()); + printf("%" PRIu64 ": ompt_get_proc_id()=%d\n", ompt_get_thread_data()->value, ompt_get_proc_id()); + + printf("%" PRIu64 ": omp_get_num_procs()=%d\n", ompt_get_thread_data()->value, omp_get_num_procs()); + printf("%" PRIu64 ": ompt_get_num_procs()=%d\n", ompt_get_thread_data()->value, ompt_get_num_procs()); + } + + // Check if libomp supports the callbacks for this test. + + // CHECK: 0: NULL_POINTER=[[NULL:.*$]] + + // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: omp_get_num_places()=[[NUM_PLACES:[0-9]+]] + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_places()=[[NUM_PLACES]] + + // CHECK: {{^}}[[MASTER_ID]]: omp_get_place_proc_ids(0)=([[PROC_IDS:[0-9\,]+]]) + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_proc_ids(0)=([[PROC_IDS]]) + + // CHECK: {{^}}[[MASTER_ID]]: omp_get_place_num()=[[PLACE_NUM:[-]?[0-9]+]] + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=[[PLACE_NUM]] + + // CHECK: {{^}}[[MASTER_ID]]: sched_getcpu()=[[CPU_ID:[0-9]+]] + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_proc_id()=[[CPU_ID]] + + // CHECK: {{^}}[[MASTER_ID]]: omp_get_num_procs()=[[NUM_PROCS:[-]?[0-9]+]] + // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_procs()=[[NUM_PROCS]] + + + return 0; +}