[Openmp-commits] [openmp] r325422 - [OMPT] Update api_calls testcase
Joachim Protze via Openmp-commits
openmp-commits at lists.llvm.org
Sat Feb 17 01:40:02 PST 2018
Author: jprotze
Date: Sat Feb 17 01:40:02 2018
New Revision: 325422
URL: http://llvm.org/viewvc/llvm-project?rev=325422&view=rev
Log:
[OMPT] Update api_calls testcase
Only use ompt_ functions when testing OMPT in api_calls testcase.
Add size parameter to print_list.
Fix small bug in implementation of ompt_get_partition_place_nums(): return correct length.
Differential Revision: https://reviews.llvm.org/D42162
Modified:
openmp/trunk/runtime/src/ompt-general.cpp
openmp/trunk/runtime/test/ompt/misc/api_calls.c
Modified: openmp/trunk/runtime/src/ompt-general.cpp
URL: http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/src/ompt-general.cpp?rev=325422&r1=325421&r2=325422&view=diff
==============================================================================
--- openmp/trunk/runtime/src/ompt-general.cpp (original)
+++ openmp/trunk/runtime/src/ompt-general.cpp Sat Feb 17 01:40:02 2018
@@ -606,7 +606,7 @@ OMPT_API_ROUTINE int ompt_get_partition_
for (i = 0, place_num = start; place_num <= end; ++place_num, ++i) {
place_nums[i] = place_num;
}
- return end - start;
+ return end - start + 1;
#endif
}
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=325422&r1=325421&r2=325422&view=diff
==============================================================================
--- openmp/trunk/runtime/test/ompt/misc/api_calls.c (original)
+++ openmp/trunk/runtime/test/ompt/misc/api_calls.c Sat Feb 17 01:40:02 2018
@@ -6,67 +6,83 @@
#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]);
+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 < omp_get_place_num_procs(0); i++)
- {
+ for (i = 1; i < size; i++) {
printf(",%d", list[i]);
}
printf(")\n");
}
-int main()
-{
- #pragma omp parallel num_threads(1)
+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());
+ 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)];
+ 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);
- 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());
+ 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[omp_get_partition_num_places()];
+ 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);
- 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());
+ 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:[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(0)=([[PROC_IDS:[0-9\,]+]])
+ // 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;
}
More information about the Openmp-commits
mailing list