[Openmp-commits] [PATCH] D73850: [OpenMP][OMPT] fix reduction test for 32-bit x86

Joachim Protze via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sun Feb 2 10:06:40 PST 2020


protze.joachim created this revision.
protze.joachim added a reviewer: mgorny.
Herald added subscribers: jfb, guansong.
Herald added a reviewer: jdoerfert.
Herald added a project: OpenMP.

fix for: https://bugs.llvm.org/show_bug.cgi?id=44733

function `__kmp_determine_reduction_method` has strange architecture specific optimizations to determine the reduction algorithm. For 32-bit we need at least 3 variables to avoid atomic reduction.

This patch adds reduction variables to the testcase.

see: llvm-project/openmp/runtime/src/kmp_runtime.cpp:8143


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73850

Files:
  openmp/runtime/test/ompt/synchronization/reduction/tree_reduce.c


Index: openmp/runtime/test/ompt/synchronization/reduction/tree_reduce.c
===================================================================
--- openmp/runtime/test/ompt/synchronization/reduction/tree_reduce.c
+++ openmp/runtime/test/ompt/synchronization/reduction/tree_reduce.c
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run | %sort-threads | FileCheck %s
+// RUN: %libomp-compile -DNOWAIT && %libomp-run | FileCheck %s
 // REQUIRES: ompt
 // UNSUPPORTED: gcc
 #include "callback.h"
@@ -11,14 +12,17 @@
 #endif
 
 int main() {
-  int sum = 0;
+  int sum = 0, a = 0, b = 0;
   int i;
-#pragma omp parallel num_threads(5)
-#pragma omp for reduction(+ : sum) FOR_CLAUSE
+#pragma omp parallel num_threads(4)
+// for 32-bit architecture we need at least 3 variables to trigger tree
+#pragma omp for reduction(+ : sum, a, b) FOR_CLAUSE
   for (i = 0; i < 10000; i++) {
-    sum += i;
+    a = b = sum += i;
   }
 
+
+  printf("%i\n", sum);
   // CHECK: 0: NULL_POINTER=[[NULL:.*$]]
 
   // CHECK: {{^}}[[MASTER_ID:[0-9]+]]: ompt_event_parallel_begin:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73850.241929.patch
Type: text/x-patch
Size: 1047 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20200202/51c2eef3/attachment.bin>


More information about the Openmp-commits mailing list