Skip to content

Commit 01508a8

Browse files
committed
add testcase for some ompt api calls
1 parent 80e023a commit 01508a8

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

runtime/test/ompt/callback.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ static ompt_get_task_info_t ompt_get_task_info;
4646
static ompt_get_thread_data_t ompt_get_thread_data;
4747
static ompt_get_parallel_info_t ompt_get_parallel_info;
4848
static ompt_get_unique_id_t ompt_get_unique_id;
49+
static ompt_get_num_places_t ompt_get_num_places;
50+
static ompt_get_place_proc_ids_t ompt_get_place_proc_ids;
51+
static ompt_get_place_num_t ompt_get_place_num;
52+
static ompt_get_partition_place_nums_t ompt_get_partition_place_nums;
53+
static ompt_get_proc_id_t ompt_get_proc_id;
4954

5055
static void print_ids(int level)
5156
{
@@ -604,6 +609,12 @@ int ompt_initialize(
604609
ompt_get_parallel_info = (ompt_get_parallel_info_t) lookup("ompt_get_parallel_info");
605610
ompt_get_unique_id = (ompt_get_unique_id_t) lookup("ompt_get_unique_id");
606611

612+
ompt_get_num_places = (ompt_get_num_places_t) lookup("ompt_get_num_places");
613+
ompt_get_place_proc_ids = (ompt_get_place_proc_ids_t) lookup("ompt_get_place_proc_ids");
614+
ompt_get_place_num = (ompt_get_place_num_t) lookup("ompt_get_place_num");
615+
ompt_get_partition_place_nums = (ompt_get_partition_place_nums_t) lookup("ompt_get_partition_place_nums");
616+
ompt_get_proc_id = (ompt_get_proc_id_t) lookup("ompt_get_proc_id");
617+
607618
register_callback(ompt_callback_mutex_acquire);
608619
register_callback_t(ompt_callback_mutex_acquired, ompt_callback_mutex_t);
609620
register_callback_t(ompt_callback_mutex_released, ompt_callback_mutex_t);

runtime/test/ompt/misc/api_calls.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %libomp-compile-and-run | FileCheck %s
2+
// REQUIRES: ompt
3+
#include "callback.h"
4+
#include <omp.h>
5+
6+
int main()
7+
{
8+
#pragma omp parallel num_threads(1)
9+
{
10+
printf("%" PRIu64 ": omp_get_num_places()=%d\n", ompt_get_thread_data()->value, omp_get_num_places());
11+
printf("%" PRIu64 ": ompt_get_num_places()=%d\n", ompt_get_thread_data()->value, ompt_get_num_places());
12+
13+
printf("%" PRIu64 ": omp_get_place_num()=%d\n", ompt_get_thread_data()->value, omp_get_place_num());
14+
printf("%" PRIu64 ": ompt_get_place_num()=%d\n", ompt_get_thread_data()->value, ompt_get_place_num());
15+
16+
}
17+
18+
// Check if libomp supports the callbacks for this test.
19+
20+
// CHECK: 0: NULL_POINTER=[[NULL:.*$]]
21+
22+
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: omp_get_num_places()=[[NUM_PLACES:[0-9]+]]
23+
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_places()=[[NUM_PLACES]]
24+
// CHECK: {{^}}[[MASTER_ID:[0-9]+]]: omp_get_place_num()=[[PLACE_NUM:[-]?[0-9]+]]
25+
// CHECK: {{^}}[[MASTER_ID]]: ompt_get_place_num()=[[PLACE_NUM]]
26+
27+
return 0;
28+
}

0 commit comments

Comments
 (0)