Skip to content

Commit 366ce74

Browse files
committed
Merging r338757:
------------------------------------------------------------------------ r338757 | jlpeyton | 2018-08-02 21:13:07 +0200 (Thu, 02 Aug 2018) | 8 lines [OpenMP] Fix doacross testing for gcc 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. Differential Revision: https://reviews.llvm.org/D50014 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/openmp/branches/release_70@338844 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e7966c0 commit 366ce74

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

cmake/OpenMPTesting.cmake

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ function(set_test_compiler_information dir)
8787

8888
# Determine major version.
8989
string(REGEX MATCH "[0-9]+" major "${OPENMP_TEST_C_COMPILER_VERSION}")
90+
string(REGEX MATCH "[0-9]+\\.[0-9]+" majorminor "${OPENMP_TEST_C_COMPILER_VERSION}")
9091
set(OPENMP_TEST_COMPILER_VERSION_MAJOR "${major}" PARENT_SCOPE)
92+
set(OPENMP_TEST_COMPILER_VERSION_MAJOR_MINOR "${majorminor}" PARENT_SCOPE)
9193
endif()
9294
endfunction()
9395

@@ -117,6 +119,7 @@ else()
117119
# Cannot use CLANG_VERSION because we are not guaranteed that this is already set.
118120
set(OPENMP_TEST_COMPILER_VERSION "${LLVM_VERSION}")
119121
set(OPENMP_TEST_COMPILER_VERSION_MAJOR "${LLVM_MAJOR_VERSION}")
122+
set(OPENMP_TEST_COMPILER_VERSION_MAJOR_MINOR "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}")
120123
# TODO: Implement blockaddress in GlobalISel and remove this flag!
121124
set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "-fopenmp -fno-experimental-isel")
122125
endif()
@@ -131,7 +134,7 @@ function(set_test_compiler_features)
131134
# Just use the lowercase of the compiler ID as fallback.
132135
string(TOLOWER "${OPENMP_TEST_COMPILER_ID}" comp)
133136
endif()
134-
set(OPENMP_TEST_COMPILER_FEATURES "['${comp}', '${comp}-${OPENMP_TEST_COMPILER_VERSION_MAJOR}', '${comp}-${OPENMP_TEST_COMPILER_VERSION}']" PARENT_SCOPE)
137+
set(OPENMP_TEST_COMPILER_FEATURES "['${comp}', '${comp}-${OPENMP_TEST_COMPILER_VERSION_MAJOR}', '${comp}-${OPENMP_TEST_COMPILER_VERSION_MAJOR_MINOR}', '${comp}-${OPENMP_TEST_COMPILER_VERSION}']" PARENT_SCOPE)
135138
endfunction()
136139
set_test_compiler_features()
137140

runtime/test/worksharing/for/kmp_doacross_check.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
// RUN: %libomp-compile-and-run
2+
// UNSUPPORTED: gcc
3+
// This test is incompatible with gcc because of the explicit call to
4+
// __kmpc_doacross_fini(). gcc relies on an implicit call to this function
5+
// when the last iteration is executed inside the GOMP_loop_*_next() functions.
6+
// Hence, in gcc, having the explicit call leads to __kmpc_doacross_fini()
7+
// being called twice.
28
#include <stdio.h>
39

410
#define N 1000
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// RUN: %libomp-compile-and-run
2+
// XFAIL: gcc-4, gcc-5, clang-3.7, clang-3.8, icc-15, icc-16
3+
#include <stdio.h>
4+
#include <stdlib.h>
5+
#include "omp_testsuite.h"
6+
7+
#ifndef N
8+
#define N 750
9+
#endif
10+
11+
int test_doacross() {
12+
int i, j;
13+
// Allocate and zero out the matrix
14+
int *m = (int *)malloc(sizeof(int) * N * N);
15+
for (i = 0; i < N; ++i) {
16+
for (j = 0; j < N; ++j) {
17+
m[i * N + j] = 0;
18+
}
19+
}
20+
// Have first row and column be 0, 1, 2, 3, etc.
21+
for (i = 0; i < N; ++i)
22+
m[i * N] = i;
23+
for (j = 0; j < N; ++j)
24+
m[j] = j;
25+
// Perform wavefront which results in matrix:
26+
// 0 1 2 3 4
27+
// 1 2 3 4 5
28+
// 2 3 4 5 6
29+
// 3 4 5 6 7
30+
// 4 5 6 7 8
31+
#pragma omp parallel shared(m)
32+
{
33+
int row, col;
34+
#pragma omp for ordered(2)
35+
for (row = 1; row < N; ++row) {
36+
for (col = 1; col < N; ++col) {
37+
#pragma omp ordered depend(sink : row - 1, col) depend(sink : row, col - 1)
38+
m[row * N + col] = m[(row - 1) * N + col] + m[row * N + (col - 1)] -
39+
m[(row - 1) * N + (col - 1)];
40+
#pragma omp ordered depend(source)
41+
}
42+
}
43+
}
44+
45+
// Check the bottom right element to see if iteration dependencies were held
46+
int retval = (m[(N - 1) * N + N - 1] == 2 * (N - 1));
47+
free(m);
48+
return retval;
49+
}
50+
51+
int main(int argc, char **argv) {
52+
int i;
53+
int num_failed = 0;
54+
for (i = 0; i < REPETITIONS; i++) {
55+
if (!test_doacross()) {
56+
num_failed++;
57+
}
58+
}
59+
return num_failed;
60+
}

0 commit comments

Comments
 (0)