[clang] [OpenACC] Implement 'reduction' sema for compute constructs (PR #92808)

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Mon May 20 12:12:06 PDT 2024


================
@@ -706,6 +736,48 @@ SemaOpenACC::ActOnClause(ArrayRef<const OpenACCClause *> ExistingClauses,
         Clause.getLParenLoc(), Clause.getDeviceTypeArchitectures(),
         Clause.getEndLoc());
   }
+  case OpenACCClauseKind::Reduction: {
+    // Restrictions only properly implemented on 'compute' constructs, and
+    // 'compute' constructs are the only construct that can do anything with
+    // this yet, so skip/treat as unimplemented in this case.
+    if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
+      break;
+
+    // OpenACC 3.3 Section 2.5.4:
+    // A reduction clause may not appear on a parallel construct with a
+    // num_gangs clause that has more than one argument.
+    if (Clause.getDirectiveKind() == OpenACCDirectiveKind::Parallel) {
+      auto NumGangsClauses =
+          llvm::make_filter_range(ExistingClauses, [](const OpenACCClause *C) {
+            return C->getClauseKind() == OpenACCClauseKind::NumGangs;
+          });
----------------
alexey-bataev wrote:

`llvm::make_filter_range(ExistingClauses, IsaPred<OpenACCNumGangsClause>)`?

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


More information about the cfe-commits mailing list