diff options
| author | Joachim Protze <protze@itc.rwth-aachen.de> | 2017-11-01 10:08:30 +0000 |
|---|---|---|
| committer | Joachim Protze <protze@itc.rwth-aachen.de> | 2017-11-01 10:08:30 +0000 |
| commit | 82e94a593433f36734e2d34898d353a2ecb65b8b (patch) | |
| tree | d7ac69e35db74384a401862feb3eb31e78ca94ca /openmp/runtime/test/ompt/misc/api_calls.c | |
| parent | b93c06331ea77953e80bbd5ffb30167eade466f0 (diff) | |
| download | bcm5719-llvm-82e94a593433f36734e2d34898d353a2ecb65b8b.tar.gz bcm5719-llvm-82e94a593433f36734e2d34898d353a2ecb65b8b.zip | |
Update implementation of OMPT to the specification OpenMP 5.0 Preview 1 (TR4).
The code is tested to work with latest clang, GNU and Intel compiler. The implementation
is optimized for low overhead when no tool is attached shifting the cost to execution with
tool attached.
This patch does not implement OMPT for libomptarget.
Patch by Simon Convent and Joachim Protze
Differential Revision: https://reviews.llvm.org/D38185
llvm-svn: 317085
Diffstat (limited to 'openmp/runtime/test/ompt/misc/api_calls.c')
| -rw-r--r-- | openmp/runtime/test/ompt/misc/api_calls.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/openmp/runtime/test/ompt/misc/api_calls.c b/openmp/runtime/test/ompt/misc/api_calls.c new file mode 100644 index 00000000000..f7f1e16aa6d --- /dev/null +++ b/openmp/runtime/test/ompt/misc/api_calls.c @@ -0,0 +1,66 @@ +// RUN: %libomp-compile && env OMP_PLACES=cores %libomp-run | FileCheck %s +// REQUIRES: ompt, linux +#include "callback.h" +#include <omp.h> +#define __USE_GNU +#include <sched.h> +#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()); + } + + // 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]] + + + return 0; +} |

