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

Kiran Chandramohan via flang-commits flang-commits at lists.llvm.org
Wed Jul 17 05:59:32 PDT 2024


https://github.com/kiranchandramohan created https://github.com/llvm/llvm-project/pull/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)

>From 8c4208e5fe8730741e18bd240094f10b28729153 Mon Sep 17 00:00:00 2001
From: Kiran Chandramohan <kiran.chandramohan at arm.com>
Date: Tue, 16 Jul 2024 19:39:50 +0000
Subject: [PATCH] [Flang][OpenMP] Add support for proc_bind=primary

The support was missing only in the parser, all other phases
handle the primary option for proc_bind.
---
 flang/lib/Parser/openmp-parsers.cpp    |  3 ++-
 flang/test/Parser/OpenMP/proc-bind.f90 | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)
 create mode 100644 flang/test/Parser/OpenMP/proc-bind.f90

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



More information about the flang-commits mailing list