[Openmp-commits] [PATCH] D50014: [OpenMP] Fix doacross testing for gcc

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Jul 30 14:40:02 PDT 2018


jlpeyton created this revision.
jlpeyton added a reviewer: Hahnfeld.
jlpeyton added a project: OpenMP.
Herald added a subscriber: guansong.

This patch adds a test using the doacross clauses in OpenMP and removes gcc from testing kmp_doacross_check.c which is only testing the kmp rather than the gomp interface.


Repository:
  rOMP OpenMP

https://reviews.llvm.org/D50014

Files:
  runtime/test/worksharing/for/kmp_doacross_check.c
  runtime/test/worksharing/for/omp_doacross.c


Index: runtime/test/worksharing/for/omp_doacross.c
===================================================================
--- /dev/null
+++ runtime/test/worksharing/for/omp_doacross.c
@@ -0,0 +1,60 @@
+// RUN: %libomp-compile-and-run
+#include <stdio.h>
+#include <stdlib.h>
+#include "omp_testsuite.h"
+
+#ifndef N
+#define N 750
+#endif
+
+int test_doacross()
+{
+  int i,j;
+  // Allocate and zero out the matrix
+  int* m = (int*)malloc(sizeof(int)*N*N);
+  for (i = 0; i < N; ++i) {
+    for (j = 0; j < N; ++j) {
+      m[i*N+j] = 0;
+    }
+  }
+  // Have first row and column be 0, 1, 2, 3, etc.
+  for (i = 0; i < N; ++i)
+    m[i*N] = i;
+  for (j = 0; j < N; ++j)
+    m[j] = j;
+  // Perform wavefront which results in matrix:
+  // 0 1 2 3 4
+  // 1 2 3 4 5
+  // 2 3 4 5 6
+  // 3 4 5 6 7
+  // 4 5 6 7 8
+  #pragma omp parallel shared(m)
+  {
+    int row, col;
+    #pragma omp for ordered(2)
+    for (row = 1; row < N; ++row) {
+      for (col = 1; col < N; ++col) {
+        #pragma omp ordered depend(sink:row-1,col) depend(sink:row,col-1)
+        m[row*N+col] = m[(row-1)*N+col] + m[row*N+(col-1)] - m[(row-1)*N+(col-1)];
+        #pragma omp ordered depend(source)
+      }
+    }
+  }
+
+  // Check the bottom right element to see if iteration dependencies were held
+  int retval = (m[(N-1)*N+N-1] == 2*(N-1));
+  free(m);
+  return retval;
+}
+
+int main(int argc, char** argv)
+{
+  int i;
+  int num_failed = 0;
+  for (i = 0; i < REPETITIONS; i++) {
+    if (!test_doacross()) {
+      num_failed++;
+    }
+  }
+  return num_failed;
+}
Index: runtime/test/worksharing/for/kmp_doacross_check.c
===================================================================
--- runtime/test/worksharing/for/kmp_doacross_check.c
+++ runtime/test/worksharing/for/kmp_doacross_check.c
@@ -1,4 +1,5 @@
 // RUN: %libomp-compile-and-run
+// UNSUPPORTED: gcc
 #include <stdio.h>
 
 #define N   1000


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50014.158075.patch
Type: text/x-patch
Size: 1906 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20180730/1f8fcbd9/attachment.bin>


More information about the Openmp-commits mailing list