[Openmp-commits] [openmp] r338757 - [OpenMP] Fix doacross testing for gcc

Jonas Hahnfeld via Openmp-commits openmp-commits at lists.llvm.org
Thu Aug 2 12:23:30 PDT 2018


Hi Hans,

the last mentioned fix, please consider backporting for 7.0.

Regards,
Jonas

On 2018-08-02 21:13, Jonathan Peyton via Openmp-commits wrote:
> Author: jlpeyton
> Date: Thu Aug  2 12:13:07 2018
> New Revision: 338757
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=338757&view=rev
> Log:
> [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
> 
> Added:
>     openmp/trunk/runtime/test/worksharing/for/omp_doacross.c
> Modified:
>     openmp/trunk/cmake/OpenMPTesting.cmake
>     openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c
> 
> Modified: openmp/trunk/cmake/OpenMPTesting.cmake
> URL:
> http://llvm.org/viewvc/llvm-project/openmp/trunk/cmake/OpenMPTesting.cmake?rev=338757&r1=338756&r2=338757&view=diff
> ==============================================================================
> --- openmp/trunk/cmake/OpenMPTesting.cmake (original)
> +++ openmp/trunk/cmake/OpenMPTesting.cmake Thu Aug  2 12:13:07 2018
> @@ -87,7 +87,9 @@ function(set_test_compiler_information d
> 
>      # Determine major version.
>      string(REGEX MATCH "[0-9]+" major 
> "${OPENMP_TEST_C_COMPILER_VERSION}")
> +    string(REGEX MATCH "[0-9]+\\.[0-9]+" majorminor
> "${OPENMP_TEST_C_COMPILER_VERSION}")
>      set(OPENMP_TEST_COMPILER_VERSION_MAJOR "${major}" PARENT_SCOPE)
> +    set(OPENMP_TEST_COMPILER_VERSION_MAJOR_MINOR "${majorminor}" 
> PARENT_SCOPE)
>    endif()
>  endfunction()
> 
> @@ -117,6 +119,7 @@ else()
>    # Cannot use CLANG_VERSION because we are not guaranteed that this
> is already set.
>    set(OPENMP_TEST_COMPILER_VERSION "${LLVM_VERSION}")
>    set(OPENMP_TEST_COMPILER_VERSION_MAJOR "${LLVM_MAJOR_VERSION}")
> +  set(OPENMP_TEST_COMPILER_VERSION_MAJOR_MINOR
> "${LLVM_MAJOR_VERSION}.${LLVM_MINOR_VERSION}")
>    # TODO: Implement blockaddress in GlobalISel and remove this flag!
>    set(OPENMP_TEST_COMPILER_OPENMP_FLAGS "-fopenmp 
> -fno-experimental-isel")
>  endif()
> @@ -131,7 +134,7 @@ function(set_test_compiler_features)
>      # Just use the lowercase of the compiler ID as fallback.
>      string(TOLOWER "${OPENMP_TEST_COMPILER_ID}" comp)
>    endif()
> -  set(OPENMP_TEST_COMPILER_FEATURES "['${comp}',
> '${comp}-${OPENMP_TEST_COMPILER_VERSION_MAJOR}',
> '${comp}-${OPENMP_TEST_COMPILER_VERSION}']" PARENT_SCOPE)
> +  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)
>  endfunction()
>  set_test_compiler_features()
> 
> 
> Modified: 
> openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c
> URL:
> http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c?rev=338757&r1=338756&r2=338757&view=diff
> ==============================================================================
> --- openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c 
> (original)
> +++ openmp/trunk/runtime/test/worksharing/for/kmp_doacross_check.c Thu
> Aug  2 12:13:07 2018
> @@ -1,4 +1,10 @@
>  // RUN: %libomp-compile-and-run
> +// UNSUPPORTED: gcc
> +// This test is incompatible with gcc because of the explicit call to
> +// __kmpc_doacross_fini().  gcc relies on an implicit call to this 
> function
> +// when the last iteration is executed inside the GOMP_loop_*_next() 
> functions.
> +// Hence, in gcc, having the explicit call leads to 
> __kmpc_doacross_fini()
> +// being called twice.
>  #include <stdio.h>
> 
>  #define N   1000
> 
> Added: openmp/trunk/runtime/test/worksharing/for/omp_doacross.c
> URL:
> http://llvm.org/viewvc/llvm-project/openmp/trunk/runtime/test/worksharing/for/omp_doacross.c?rev=338757&view=auto
> ==============================================================================
> --- openmp/trunk/runtime/test/worksharing/for/omp_doacross.c (added)
> +++ openmp/trunk/runtime/test/worksharing/for/omp_doacross.c Thu Aug
> 2 12:13:07 2018
> @@ -0,0 +1,60 @@
> +// RUN: %libomp-compile-and-run
> +// XFAIL: gcc-4, gcc-5, clang-3.7, clang-3.8, icc-15, icc-16
> +#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;
> +}
> 
> 
> _______________________________________________
> Openmp-commits mailing list
> Openmp-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/openmp-commits


More information about the Openmp-commits mailing list