[Openmp-commits] [openmp] r331631 - [OMPT] Add api_calls_misc.c testcase and rename api_calls.c testcase
Joachim Protze via Openmp-commits
openmp-commits at lists.llvm.org
Mon May 7 05:42:15 PDT 2018
Author: jprotze
Date: Mon May 7 05:42:15 2018
New Revision: 331631
URL: http://llvm.org/viewvc/llvm-project?rev=331631&view=rev
Log:
[OMPT] Add api_calls_misc.c testcase and rename api_calls.c testcase
The api_calls_misc.c testcase tests the following api calls:
ompt_get_callback()
ompt_get_state()
ompt_enumerate_states()
ompt_enumerate_mutex_impls()
These have not been tested previously.
The api_calls.c testcase has been renamed to api_calls_places.c because it only tests api calls that are related to places.
Differential Revision: https://reviews.llvm.org/D42523
Added:
openmp/trunk/runtime/test/ompt/misc/api_calls_misc.c
openmp/trunk/runtime/test/ompt/misc/api_calls_places.c
- copied, changed from r331550, openmp/trunk/runtime/test/ompt/misc/api_calls.c
Removed:
openmp/trunk/runtime/test/ompt/misc/api_calls.c
Modified:
openmp/trunk/runtime/test/ompt/callback.h
Modified: openmp/trunk/runtime/test/ompt/callback.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/callback.h?rev=331631&r1=331630&r2=331631&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/callback.h (original)
+++ openmp/trunk/runtime/test/ompt/callback.h Mon May 7 05:42:15 2018
@@ -56,6 +56,8 @@ static void format_task_type(int type, c
}
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;
@@ -697,6 +699,8 @@ int ompt_initialize(
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");
Removed: openmp/trunk/runtime/test/ompt/misc/api_calls.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/misc/api_calls.c?rev=331630&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/api_calls.c (original)
+++ openmp/trunk/runtime/test/ompt/misc/api_calls.c (removed)
@@ -1,88 +0,0 @@
-// 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 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
- // CHECK-SAME: ()=[[NUM_PLACES:[0-9]+]]
- // CHECK: {{^}}[[MASTER_ID]]: ompt_get_num_places()=[[NUM_PLACES]]
-
- // CHECK: {{^}}[[MASTER_ID]]: omp_get_place_proc_ids
- // CHECK-SAME: (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]]: omp_get_partition_place_nums
- // CHECK-SAME: (0)=([[PARTITION_PLACE_NUMS:[0-9\,]+]])
- // CHECK: {{^}}[[MASTER_ID]]: ompt_get_partition_place_nums
- // CHECK-SAME: (0)=([[PARTITION_PLACE_NUMS]])
-
- // 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;
-}
Added: openmp/trunk/runtime/test/ompt/misc/api_calls_misc.c
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/misc/api_calls_misc.c?rev=331631&view=auto
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/api_calls_misc.c (added)
+++ openmp/trunk/runtime/test/ompt/misc/api_calls_misc.c Mon May 7 05:42:15 2018
@@ -0,0 +1,72 @@
+// RUN: %libomp-compile && %libomp-run | FileCheck %s
+// REQUIRES: ompt
+#include "callback.h"
+#include <omp.h>
+
+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 = 0;
+ 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\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\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
+ // CHECK-SAME: =[[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
+
+ // CHECK-NOT: {{^}}[[THREAD_ID]]: impl_name is NULL
+ // CHECK-NOT: {{^}}[[THREAD_ID]]: mutex_impls enumeration did not end
+
+ return 0;
+}
Copied: openmp/trunk/runtime/test/ompt/misc/api_calls_places.c (from r331550, openmp/trunk/runtime/test/ompt/misc/api_calls.c)
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/misc/api_calls_places.c?p2=openmp/trunk/runtime/test/ompt/misc/api_calls_places.c&p1=openmp/trunk/runtime/test/ompt/misc/api_calls.c&r1=331550&r2=331631&rev=331631&view=diff
==============================================================================
(empty)
More information about the Openmp-commits
mailing list