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

via flang-commits flang-commits at lists.llvm.org
Wed Jul 17 06:00:11 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-parser

Author: Kiran Chandramohan (kiranchandramohan)

<details>
<summary>Changes</summary>

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)

---
Full diff: https://github.com/llvm/llvm-project/pull/99319.diff


2 Files Affected:

- (modified) flang/lib/Parser/openmp-parsers.cpp (+2-1) 
- (added) flang/test/Parser/OpenMP/proc-bind.f90 (+14) 


``````````diff
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp
index 0ea48ce29ca2f..ded9494159193 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 | 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/99319


More information about the flang-commits mailing list