-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][bbc][flang] Add _OPENMP macro definition
OpenMP standard (section 3.3 for OpenMP 5.2) requires that _OPENMP macro contains release date of given OpenMP standard version. Differential Revision: https://reviews.llvm.org/D151083 Reviewed By: kiranchandramohan
- Loading branch information
1 parent
53cc33b
commit 4a5ac14
Showing
5 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===-- include/flang/Common/OpenMP-features.h -----------------*- C++ -*-====// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef FORTRAN_COMMON_OPENMP_FEATURES_H_ | ||
#define FORTRAN_COMMON_OPENMP_FEATURES_H_ | ||
|
||
namespace Fortran::common { | ||
|
||
/// Set _OPENMP macro according to given version number | ||
template <typename FortranPredefinitions> | ||
void setOpenMPMacro(int version, FortranPredefinitions &predefinitions) { | ||
switch (version) { | ||
case 20: | ||
predefinitions.emplace_back("_OPENMP", "200011"); | ||
break; | ||
case 25: | ||
predefinitions.emplace_back("_OPENMP", "200505"); | ||
break; | ||
case 30: | ||
predefinitions.emplace_back("_OPENMP", "200805"); | ||
break; | ||
case 31: | ||
predefinitions.emplace_back("_OPENMP", "201107"); | ||
break; | ||
case 40: | ||
predefinitions.emplace_back("_OPENMP", "201307"); | ||
break; | ||
case 45: | ||
predefinitions.emplace_back("_OPENMP", "201511"); | ||
break; | ||
case 50: | ||
predefinitions.emplace_back("_OPENMP", "201811"); | ||
break; | ||
case 51: | ||
predefinitions.emplace_back("_OPENMP", "202011"); | ||
break; | ||
case 52: | ||
predefinitions.emplace_back("_OPENMP", "202111"); | ||
break; | ||
case 11: | ||
default: | ||
predefinitions.emplace_back("_OPENMP", "199911"); | ||
break; | ||
} | ||
} | ||
} // namespace Fortran::common | ||
#endif // FORTRAN_COMMON_OPENMP_FEATURES_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
! Test predefined _OPENMP macro which denotes OpenMP version | ||
|
||
! RUN: bbc -fopenmp -o - %s | FileCheck %s --check-prefix=DEFAULT-OPENMP-VERSION | ||
! RUN: bbc -fopenmp -fopenmp-version=11 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-11 | ||
! RUN: bbc -fopenmp -fopenmp-version=11 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-11 | ||
! RUN: bbc -fopenmp -fopenmp-version=20 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-20 | ||
! RUN: bbc -fopenmp -fopenmp-version=25 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-25 | ||
! RUN: bbc -fopenmp -fopenmp-version=30 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-30 | ||
! RUN: bbc -fopenmp -fopenmp-version=31 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-31 | ||
! RUN: bbc -fopenmp -fopenmp-version=40 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-40 | ||
! RUN: bbc -fopenmp -fopenmp-version=45 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-45 | ||
! RUN: bbc -fopenmp -fopenmp-version=50 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-50 | ||
! RUN: bbc -fopenmp -fopenmp-version=51 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-51 | ||
! RUN: bbc -fopenmp -fopenmp-version=52 -o - %s | FileCheck %s --check-prefix=OPENMP-VERSION-52 | ||
|
||
! DEFAULT-OPENMP-VERSION: {{.*}} = arith.constant 199911 : i32 | ||
! OPENMP-VERSION-11: {{.*}} = arith.constant 199911 : i32 | ||
! OPENMP-VERSION-20: {{.*}} = arith.constant 200011 : i32 | ||
! OPENMP-VERSION-25: {{.*}} = arith.constant 200505 : i32 | ||
! OPENMP-VERSION-30: {{.*}} = arith.constant 200805 : i32 | ||
! OPENMP-VERSION-31: {{.*}} = arith.constant 201107 : i32 | ||
! OPENMP-VERSION-40: {{.*}} = arith.constant 201307 : i32 | ||
! OPENMP-VERSION-45: {{.*}} = arith.constant 201511 : i32 | ||
! OPENMP-VERSION-50: {{.*}} = arith.constant 201811 : i32 | ||
! OPENMP-VERSION-51: {{.*}} = arith.constant 202011 : i32 | ||
! OPENMP-VERSION-52: {{.*}} = arith.constant 202111 : i32 | ||
|
||
#if _OPENMP | ||
integer :: var1 = _OPENMP | ||
#endif | ||
end program | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
! Test predefined _OPENMP macro which denotes OpenMP version | ||
|
||
! RUN: %flang_fc1 -fopenmp -cpp -E %s | FileCheck %s --check-prefix=DEFAULT-OPENMP-VERSION | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=11 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-11 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=11 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-11 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=20 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-20 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=25 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-25 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=30 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-30 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=31 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-31 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=40 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-40 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=45 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-45 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=50 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-50 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=51 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-51 | ||
! RUN: %flang_fc1 -fopenmp -fopenmp-version=52 -cpp -E %s | FileCheck %s --check-prefix=OPENMP-VERSION-52 | ||
|
||
! DEFAULT-OPENMP-VERSION: integer :: var1 = 199911 | ||
! OPENMP-VERSION-11: integer :: var1 = 199911 | ||
! OPENMP-VERSION-20: integer :: var1 = 200011 | ||
! OPENMP-VERSION-25: integer :: var1 = 200505 | ||
! OPENMP-VERSION-30: integer :: var1 = 200805 | ||
! OPENMP-VERSION-31: integer :: var1 = 201107 | ||
! OPENMP-VERSION-40: integer :: var1 = 201307 | ||
! OPENMP-VERSION-45: integer :: var1 = 201511 | ||
! OPENMP-VERSION-50: integer :: var1 = 201811 | ||
! OPENMP-VERSION-51: integer :: var1 = 202011 | ||
! OPENMP-VERSION-52: integer :: var1 = 202111 | ||
|
||
#if _OPENMP | ||
integer :: var1 = _OPENMP | ||
#endif | ||
end program | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters