[flang-commits] [flang] c68c289 - [Flang][OpenMP] Add support for proc_bind=primary (#99319)

via flang-commits flang-commits at lists.llvm.org
Thu Jul 18 02:48:43 PDT 2024


Author: Kiran Chandramohan
Date: 2024-07-18T10:48:39+01:00
New Revision: c68c289984d161d220b9434be5dbbfc387981e23

URL: https://github.com/llvm/llvm-project/commit/c68c289984d161d220b9434be5dbbfc387981e23
DIFF: https://github.com/llvm/llvm-project/commit/c68c289984d161d220b9434be5dbbfc387981e23.diff

LOG: [Flang][OpenMP] Add support for proc_bind=primary (#99319)

The support was missing only in the parser, all other phases handle the
primary option for proc_bind.

Fixes one of the issues in parsing for gomp/affinity-1.f90.
(https://discourse.llvm.org/t/proposal-rename-flang-new-to-flang/69462/60)

Added: 
    flang/test/Parser/OpenMP/proc-bind.f90

Modified: 
    flang/lib/Parser/openmp-parsers.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 0ea48ce29ca2f..52789d6e5f0f6 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -31,10 +31,11 @@ TYPE_PARSER(construct<OmpDefaultClause>(
     "SHARED" >> pure(OmpDefaultClause::Type::Shared) ||
     "NONE" >> pure(OmpDefaultClause::Type::None)))
 
-// 2.5 PROC_BIND (MASTER | CLOSE | SPREAD)
+// 2.5 PROC_BIND (MASTER | CLOSE | PRIMARY | SPREAD )
 TYPE_PARSER(construct<OmpProcBindClause>(
     "CLOSE" >> pure(OmpProcBindClause::Type::Close) ||
     "MASTER" >> pure(OmpProcBindClause::Type::Master) ||
+    "PRIMARY" >> pure(OmpProcBindClause::Type::Primary) ||
     "SPREAD" >> pure(OmpProcBindClause::Type::Spread)))
 
 // 2.15.5.1 MAP ([ [ALWAYS[,]] map-type : ] variable-name-list)

diff  --git a/flang/test/Parser/OpenMP/proc-bind.f90 b/flang/test/Parser/OpenMP/proc-bind.f90
new file mode 100644
index 0000000000000..08bcf69e5e765
--- /dev/null
+++ b/flang/test/Parser/OpenMP/proc-bind.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s
+! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s
+
+! CHECK: !$OMP PARALLEL  PROC_BIND(PRIMARY)
+
+! PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPBlockConstruct
+! PARSE-TREE:  OmpBeginBlockDirective
+! PARSE-TREE:   OmpBlockDirective -> llvm::omp::Directive = parallel
+! PARSE-TREE:   OmpClauseList -> OmpClause -> ProcBind -> OmpProcBindClause -> Type = Primary
+subroutine sb1
+  !$omp parallel proc_bind(primary)
+  print *, "Hello"
+  !$omp end parallel
+end subroutine


        


More information about the flang-commits mailing list