[Openmp-commits] [openmp] r321269 - [OMPT] Add missing ompt_get_num_procs function

Joachim Protze via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 21 06:36:30 PST 2017


Author: jprotze
Date: Thu Dec 21 06:36:30 2017
New Revision: 321269

URL: http://llvm.org/viewvc/llvm-project?rev=321269&view=rev
Log:
[OMPT] Add missing ompt_get_num_procs function

This function is defined in OpenMP-TR6 section 4.1.5.1.6
The functions was not implemented yet.

Since ompt-functions can only be called after the runtime was initialized and
has loaded a tool, it can assume the runtime to be initialized. In contrast
to omp_get_num_procs which needs to check whether the runtime is initialized.

Differential Revision: https://reviews.llvm.org/D40949

Modified:
    openmp/trunk/runtime/src/include/50/ompt.h.var
    openmp/trunk/runtime/src/ompt-general.cpp
    openmp/trunk/runtime/test/ompt/callback.h
    openmp/trunk/runtime/test/ompt/misc/api_calls.c

Modified: openmp/trunk/runtime/src/include/50/ompt.h.var
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/include/50/ompt.h.var?rev=321269&r1=321268&r2=321269&view=diff
==============================================================================
--- openmp/trunk/runtime/src/include/50/ompt.h.var (original)
+++ openmp/trunk/runtime/src/include/50/ompt.h.var Thu Dec 21 06:36:30 2017
@@ -32,6 +32,7 @@
     macro (ompt_get_thread_data)            \
     macro (ompt_get_unique_id)              \
                                             \
+    macro(ompt_get_num_procs)               \
     macro(ompt_get_num_places)              \
     macro(ompt_get_place_proc_ids)          \
     macro(ompt_get_place_num)               \
@@ -582,6 +583,9 @@ OMPT_API_FUNCTION(int, ompt_get_task_inf
     int *thread_num
 ));
 
+/* procs */
+OMPT_API_FUNCTION(int, ompt_get_num_procs, (void));
+
 /* places */
 OMPT_API_FUNCTION(int, ompt_get_num_places, (void));
 

Modified: openmp/trunk/runtime/src/ompt-general.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-general.cpp?rev=321269&r1=321268&r2=321269&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-general.cpp (original)
+++ openmp/trunk/runtime/src/ompt-general.cpp Thu Dec 21 06:36:30 2017
@@ -491,6 +491,15 @@ OMPT_API_ROUTINE int ompt_get_task_info(
 }
 
 /*****************************************************************************
+ * num_procs
+ ****************************************************************************/
+
+OMPT_API_ROUTINE int ompt_get_num_procs(void) {
+// copied from kmp_ftn_entry.h (but modified: OMPT can only be called when runtime is initialized)
+  return __kmp_avail_proc;
+}
+
+/*****************************************************************************
  * places
  ****************************************************************************/
 

Modified: openmp/trunk/runtime/test/ompt/callback.h
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/ompt/callback.h?rev=321269&r1=321268&r2=321269&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/callback.h (original)
+++ openmp/trunk/runtime/test/ompt/callback.h Thu Dec 21 06:36:30 2017
@@ -37,6 +37,7 @@ static ompt_get_task_info_t ompt_get_tas
 static ompt_get_thread_data_t ompt_get_thread_data;
 static ompt_get_parallel_info_t ompt_get_parallel_info;
 static ompt_get_unique_id_t ompt_get_unique_id;
+static ompt_get_num_procs_t ompt_get_num_procs;
 static ompt_get_num_places_t ompt_get_num_places;
 static ompt_get_place_proc_ids_t ompt_get_place_proc_ids;
 static ompt_get_place_num_t ompt_get_place_num;
@@ -684,6 +685,7 @@ int ompt_initialize(
   ompt_get_parallel_info = (ompt_get_parallel_info_t) lookup("ompt_get_parallel_info");
   ompt_get_unique_id = (ompt_get_unique_id_t) lookup("ompt_get_unique_id");
 
+  ompt_get_num_procs = (ompt_get_num_procs_t) lookup("ompt_get_num_procs");
   ompt_get_num_places = (ompt_get_num_places_t) lookup("ompt_get_num_places");
   ompt_get_place_proc_ids = (ompt_get_place_proc_ids_t) lookup("ompt_get_place_proc_ids");
   ompt_get_place_num = (ompt_get_place_num_t) lookup("ompt_get_place_num");

Modified: 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=321269&r1=321268&r2=321269&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/api_calls.c (original)
+++ openmp/trunk/runtime/test/ompt/misc/api_calls.c Thu Dec 21 06:36:30 2017
@@ -43,6 +43,9 @@ int main()
 
     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.
@@ -61,6 +64,9 @@ int main()
   // 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;
 }




More information about the Openmp-commits mailing list