[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-05 Thread Sergio Afonso via cfe-commits
@@ -2378,7 +2464,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder::InsertPointOrErrorTy contInsertPoint = ompBuilder->createReductions(builder.saveIP(), allocaIP, - reduct

[clang] [flang] [Flang][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-05 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/134230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-05 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,71 @@ +// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s + +// Only check the overall shape of the code and the presence of relevant +// runtime calls. Actual IR checking is done at the OpenMPIRBuilder level. + +omp.private {type = private} @_QF

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-05 Thread Sergio Afonso via cfe-commits
@@ -1987,7 +1984,8 @@ class OpenMPIRBuilder { InsertPointTy AllocaIP, ArrayRef ReductionInfos, ArrayRef IsByRef, -bool

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-04 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-04 Thread Sergio Afonso via cfe-commits
skatrak wrote: I think we should have another test similar to this for the GPU, since codegen for it is different. https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-04 Thread Sergio Afonso via cfe-commits
@@ -1714,6 +1727,42 @@ convertOmpSingle(omp::SingleOp &singleOp, llvm::IRBuilderBase &builder, return success(); } +static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) { + auto iface = + llvm::cast(teamsOp.getOperation()); + // Check that all uses o

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-04 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak approved this pull request. Thanks, LGTM! https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-04-04 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [Flang][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-04 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/134230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [Flang][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-03 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/134230 >From 5a3bf580e8c22b9813c082d1249b9b99823241f1 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 2 Apr 2025 16:34:38 +0100 Subject: [PATCH] [Flang][OpenMP][Driver][AMDGPU] Fix -mcode-object-version This p

[clang] [flang] [Flang][OpenMP][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-03 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/134230 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [Flang][OpenMP][Driver][AMDGPU] Fix -mcode-object-version (PR #134230)

2025-04-03 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/134230 This patch updates flang to follow clang's behavior when processing the `-mcode-object-version option`. It is now used to populate an LLVM module flag called `amdhsa_code_object_version` expected by the backen

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -3832,38 +3920,13 @@ OpenMPIRBuilder::createReductions(const LocationDescription &Loc, // Populate the outlined reduction function using the elementwise reduction // function. Partial values are extracted from the type-erased array of // pointers to private variables.

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -3688,27 +3708,95 @@ static Function *getFreshReductionFunc(Module &M) { ".omp.reduction.func", &M); } -OpenMPIRBuilder::InsertPointOrErrorTy -OpenMPIRBuilder::createReductions(const LocationDescription &Loc, - Inse

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -4161,6 +4247,37 @@ convertOmpDistribute(Operation &opInst, llvm::IRBuilderBase &builder, if (failed(checkImplementationStatus(opInst))) return failure(); + /// Process teams op reduction in distribute if the reduction is contained in + /// the distribute op. + om

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -1018,19 +1017,31 @@ allocReductionVars(T loop, ArrayRef reductionArgs, // variable allocated in the inlined region) llvm::Value *var = builder.CreateAlloca( moduleTranslation.convertType(reductionDecls[i].getType())); - deferredStores.emplace_bac

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -4554,6 +4679,25 @@ static std::optional extractConstInteger(Value value) { return std::nullopt; } +static uint64_t getTypeByteSize(mlir::Type type, const DataLayout &dl) { + uint64_t sizeInBits = dl.getTypeSizeInBits(type); + uint64_t sizeInBytes = sizeInBits / 8; +

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -4645,12 +4789,23 @@ initTargetDefaultAttrs(omp::TargetOp targetOp, Operation *capturedOp, (maxThreadsVal >= 0 && maxThreadsVal < combinedMaxThreadsVal)) combinedMaxThreadsVal = maxThreadsVal; + // Calculate reduction data size, limited to single reduction varia

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -4434,10 +4497,24 @@ getKmpcForStaticLoopForType(Type *Ty, OpenMPIRBuilder *OMPBuilder, static void createTargetLoopWorkshareCall( OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType, BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg, -Type *Parall

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -4434,10 +4497,24 @@ getKmpcForStaticLoopForType(Type *Ty, OpenMPIRBuilder *OMPBuilder, static void createTargetLoopWorkshareCall( OpenMPIRBuilder *OMPBuilder, WorksharingLoopType LoopType, BasicBlock *InsertBlock, Value *Ident, Value *LoopBodyArg, -Type *Parall

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
@@ -1714,6 +1727,43 @@ convertOmpSingle(omp::SingleOp &singleOp, llvm::IRBuilderBase &builder, return success(); } +static bool teamsReductionContainedInDistribute(omp::TeamsOp teamsOp) { + auto iface = + llvm::cast(teamsOp.getOperation()); + // Check that all uses o

[clang] [llvm] [mlir] [MLIR][OpenMP] Add codegen for teams reductions (PR #133310)

2025-03-31 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak commented: Thank you Jan, I have a few superficial comments, but the approach LGTM. https://github.com/llvm/llvm-project/pull/133310 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailm

[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-20 Thread Sergio Afonso via cfe-commits
@@ -53,6 +53,79 @@ that: * It has been tested in a very limited way so far. * It has been tested mostly on simple synthetic inputs. +### Loop nest detection + +On the `FIR` dialect level, the following loop: +```fortran + do concurrent(i=1:n, j=1:m, k=1:o) +a(i,j,k) = i +

[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-20 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/127595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-20 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak approved this pull request. LGTM, thank you! https://github.com/llvm/llvm-project/pull/127595 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-20 Thread Sergio Afonso via cfe-commits
@@ -31,6 +158,14 @@ class DoConcurrentConversion : public mlir::OpConversionPattern { mlir::LogicalResult matchAndRewrite(fir::DoLoopOp doLoop, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { +looputils::LoopNest loopNes

[clang] [flang] [flang][OpenMP] Upstream `do concurrent` loop-nest detection. (PR #127595)

2025-02-20 Thread Sergio Afonso via cfe-commits
@@ -53,6 +53,79 @@ that: * It has been tested in a very limited way so far. * It has been tested mostly on simple synthetic inputs. +### Loop nest detection + +On the `FIR` dialect level, the following loop: +```fortran + do concurrent(i=1:n, j=1:m, k=1:o) +a(i,j,k) = i +

[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)

2025-02-17 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,155 @@ + + +# `DO CONCURRENT` mapping to OpenMP + +```{contents} +--- +local: +--- +``` + +This document seeks to describe the effort to parallelize `do concurrent` loops +by mapping them to OpenMP worksharing constructs. The goals of this document +are: +* Describing h

[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)

2025-02-17 Thread Sergio Afonso via cfe-commits
@@ -292,7 +298,19 @@ createTargetMachine(llvm::StringRef targetTriple, std::string &error) { static llvm::LogicalResult runOpenMPPasses(mlir::ModuleOp mlirModule) { mlir::PassManager pm(mlirModule->getName(), mlir::OpPassManager::Nesting::Implicit); -

[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)

2025-02-17 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak commented: Sorry @ergawy for the delay getting back to this. LGTM, I just have one remaining concern. https://github.com/llvm/llvm-project/pull/126026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llv

[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)

2025-02-17 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,104 @@ +//===- DoConcurrentConversion.cpp -- map `DO CONCURRENT` to OpenMP loops --===// +// +// 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: Ap

[clang] [flang] [flang][OpenMP] Upstream first part of `do concurrent` mapping (PR #126026)

2025-02-17 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/126026 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [llvm] [mlir] [Flang][OpenMP] Lowering of host-evaluated clauses (PR #116219)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116219 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [llvm] [mlir] [MLIR][OpenMP] LLVM IR translation of host_eval (PR #116052)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116052 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] Propagate attributes to outlined target regions (PR #117875)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/117875 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/116051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116051 >From 0c19f7119c1da0646466b0eb1c3c77faedabaebf Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 27 Nov 2024 11:33:01 + Subject: [PATCH] [OMPIRBuilder] Support runtime number of teams and threads, and

[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116051 >From 1f5cd91c67e12e19dd9a142273af5a90a63cbf38 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Wed, 27 Nov 2024 11:33:01 + Subject: [PATCH] [OMPIRBuilder] Support runtime number of teams and threads, and

[clang] [llvm] [mlir] [OMPIRBuilder] Support runtime number of teams and threads, and SPMD mode (PR #116051)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116051 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] Introduce struct to hold default kernel teams/threads (PR #116050)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/116050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] Introduce struct to hold default kernel teams/threads (PR #116050)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/116050 >From 219d430cf7697eb2c4bcb5832695571ff472e0e2 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Fri, 8 Nov 2024 15:46:48 + Subject: [PATCH] [OMPIRBuilder] Introduce struct to hold default kernel teams/thr

[clang] [llvm] [mlir] [OMPIRBuilder] Introduce struct to hold default kernel teams/threads (PR #116050)

2025-01-14 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/116050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2025-01-09 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/115863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2025-01-08 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/115863 >From 23af823f4a4446d80130f9820f0a3d90ce2d999b Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 12 Nov 2024 12:41:15 + Subject: [PATCH] [OpenMP][OMPIRBuilder] Handle non-failing calls properly The pr

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2025-01-08 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/115863 >From 23af823f4a4446d80130f9820f0a3d90ce2d999b Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 12 Nov 2024 12:41:15 + Subject: [PATCH] [OpenMP][OMPIRBuilder] Handle non-failing calls properly The pr

[clang] [flang] [flang][Driver] Don't require -fno-integrated-as when using -save-temps (PR #119624)

2024-12-12 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak approved this pull request. Thank you, I think this is a good first step. Eventually, I think we'll still have to introduce proper support for `-fc1as`, because `-fno-integrated-as` (this patch making it the default for Flang) results in target offload programs faili

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2024-11-15 Thread Sergio Afonso via cfe-commits
@@ -345,18 +344,15 @@ TEST_F(OpenMPIRBuilderTest, CreateBarrier) { IRBuilder<> Builder(BB); - OpenMPIRBuilder::InsertPointOrErrorTy BarrierIP1 = - OMPBuilder.createBarrier({IRBuilder<>::InsertPoint()}, OMPD_for); - assert(BarrierIP1 && "unexpected error"); + ASSERT_

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2024-11-13 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/115863 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2024-11-13 Thread Sergio Afonso via cfe-commits
skatrak wrote: Thank you @Meinersbur for your comments. I just updated the PR description and replaced `cantFail()` calls in unit tests as you suggested, let me know if that addresses your concerns. https://github.com/llvm/llvm-project/pull/115863 __

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-11-12 Thread Sergio Afonso via cfe-commits
@@ -2331,8 +2332,11 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, auto *OMPRegionInfo = dyn_cast_or_null(CGF.CapturedStmtInfo); if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -CGF.Builder.restoreIP(OMPBuilder.createBarrier( -

[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)

2024-11-12 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/115863 The preprocessor definition used to enable asserts and the one that `llvm::Error` and `llvm::Expected` use to ensure all created instances are checked are not the same. By making these checks inside of an `asse

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-11-11 Thread Sergio Afonso via cfe-commits
@@ -2331,8 +2332,11 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, auto *OMPRegionInfo = dyn_cast_or_null(CGF.CapturedStmtInfo); if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -CGF.Builder.restoreIP(OMPBuilder.createBarrier( -

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-11-11 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/112533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-25 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/112533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -1103,6 +1105,13 @@ bool ConstructDecompositionT::applyClause( return applyToOutermost(node); } +template +bool ConstructDecompositionT::applyClause( +const tomp::clause::OmpxBareT &clause, +const ClauseTy *node) { + return applyToAll(node); ska

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-23 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/06 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -350,6 +350,10 @@ bool ClauseProcessor::processNowait(mlir::omp::NowaitClauseOps &result) const { return markClauseOccurrence(result.nowait); } +bool ClauseProcessor::processBare(mlir::omp::BareClauseOps &result) const { skatrak wrote: Nit: Move above `

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -1672,8 +1672,9 @@ void TargetOp::build(OpBuilder &builder, OperationState &state, // TODO Store clauses in op: allocateVars, allocatorVars, inReductionVars, // inReductionByref, inReductionSyms. TargetOp::build(builder, state, /*allocate_vars=*/{}, /*allocator_vars=*

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-23 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak approved this pull request. Thank you Ivan, Flang and MLIR changes look good to me. Sorry for the delay getting back to this! https://github.com/llvm/llvm-project/pull/06 ___ cfe-commits mailing list cfe-commits@lists.ll

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -1496,7 +1507,8 @@ IRBuilder<>::InsertPoint OpenMPIRBuilder::createParallel( // Let the caller create the body. assert(BodyGenCB && "Expected body generation callback!"); InsertPointTy CodeGenIP(PRegBodyBB, PRegBodyBB->begin()); - BodyGenCB(InnerAllocaIP, CodeGenIP);

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -1171,12 +1179,15 @@ void OpenMPIRBuilder::emitCancelationCheckImpl(Value *CancelFlag, // post finalization block that is known to the FiniCB callback. Builder.SetInsertPoint(CancellationBlock); if (ExitCB) -ExitCB(Builder.saveIP()); +if (Error Err = ExitCB(Bu

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-23 Thread Sergio Afonso via cfe-commits
@@ -2331,8 +2332,10 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, auto *OMPRegionInfo = dyn_cast_or_null(CGF.CapturedStmtInfo); if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -CGF.Builder.restoreIP(OMPBuilder.createBarrier( -

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-22 Thread Sergio Afonso via cfe-commits
@@ -2331,8 +2332,10 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc, auto *OMPRegionInfo = dyn_cast_or_null(CGF.CapturedStmtInfo); if (CGF.CGM.getLangOpts().OpenMPIRBuilder) { -CGF.Builder.restoreIP(OMPBuilder.createBarrier( -

[clang] [llvm] [mlir] [OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-21 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/112533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [MLIR][OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-21 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/112533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [MLIR][OpenMP][OMPIRBuilder] Error propagation across callbacks (PR #112533)

2024-10-21 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak ready_for_review https://github.com/llvm/llvm-project/pull/112533 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-11 Thread Sergio Afonso via cfe-commits
@@ -1103,6 +1105,13 @@ bool ConstructDecompositionT::applyClause( return applyToOutermost(node); } +template +bool ConstructDecompositionT::applyClause( +const tomp::clause::OmpxBareT &clause, +const ClauseTy *node) { + return applyToAll(node); ska

[clang] [flang] [llvm] [mlir] [flang][OpenMP] Add frontend support for ompx_bare clause (PR #111106)

2024-10-10 Thread Sergio Afonso via cfe-commits
@@ -1103,6 +1105,13 @@ bool ConstructDecompositionT::applyClause( return applyToOutermost(node); } +template +bool ConstructDecompositionT::applyClause( +const tomp::clause::OmpxBareT &clause, +const ClauseTy *node) { + return applyToAll(node); ska

[clang] [flang] [mlir] [MLIR][OpenMP] Add omp.target_triples attribute to the OffloadModuleInterface (PR #100154)

2024-08-01 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/100154 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-08-01 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak closed https://github.com/llvm/llvm-project/pull/100152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-08-01 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From e59c38db58ba5ca2eef66d3b3477d5ad81043228 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH 1/2] [Flang][Driver] Introduce -fopenmp-targets offloading optio

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-08-01 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From e59c38db58ba5ca2eef66d3b3477d5ad81043228 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH] [Flang][Driver] Introduce -fopenmp-targets offloading option Th

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-31 Thread Sergio Afonso via cfe-commits
skatrak wrote: Thank you all for your reviews. I think it should be ok to merge at this point, but I'll wait until tomorrow to give some time in case there are any remaining concerns about this change. https://github.com/llvm/llvm-project/pull/100152 ___

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-31 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From 3861b28deeb1b558f182f2ab5680b123fd94c005 Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH] [Flang][Driver] Introduce -fopenmp-targets offloading option Th

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-30 Thread Sergio Afonso via cfe-commits
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, if (Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-nogpulib"); } + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // info

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-30 Thread Sergio Afonso via cfe-commits
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, if (Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-nogpulib"); } + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // info

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-30 Thread Sergio Afonso via cfe-commits
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, if (Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-nogpulib"); } + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // info

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-30 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From cf26a318d3b49eb6217f29405cee9fd2c20f8e8a Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH 1/5] [Flang][Driver] Introduce -fopenmp-targets offloading optio

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-29 Thread Sergio Afonso via cfe-commits
skatrak wrote: > The only issue I see is that this PR adds a new driver flag that may be used > to compile the applications. Renaming the user visible flags is not that > easy. But if they get renamed before any compiler release then it should be > fine. Thank you for the comment. Actually, t

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-26 Thread Sergio Afonso via cfe-commits
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, if (Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-nogpulib"); } + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // info

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Sergio Afonso via cfe-commits
skatrak wrote: I'm not very knowledgeable on the set of offloading-related options clang supports, how those impact the set of invocations and options produced by the driver, or how these options eventually impact passes and codegen. Much less about potential shortcomings and improvements to t

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-25 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From cf26a318d3b49eb6217f29405cee9fd2c20f8e8a Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH 1/4] [Flang][Driver] Introduce -fopenmp-targets offloading optio

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-24 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From cf26a318d3b49eb6217f29405cee9fd2c20f8e8a Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH 1/3] [Flang][Driver] Introduce -fopenmp-targets offloading optio

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-24 Thread Sergio Afonso via cfe-commits
@@ -227,3 +227,20 @@ ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" ! FORCE-USM-OFFLOAD-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" "amdgcn-amd-amdhsa" ! FORCE-USM-OFFLOAD-SAME: "-fopenmp" "-fopenmp-force-usm" + skatrak wrote: Done. https://github

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-24 Thread Sergio Afonso via cfe-commits
@@ -492,6 +493,18 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs, if (Args.hasArg(options::OPT_nogpulib)) CmdArgs.push_back("-nogpulib"); } + + // For all the host OpenMP offloading compile jobs we need to pass the targets + // info

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-24 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak updated https://github.com/llvm/llvm-project/pull/100152 >From cf26a318d3b49eb6217f29405cee9fd2c20f8e8a Mon Sep 17 00:00:00 2001 From: Sergio Afonso Date: Tue, 23 Jul 2024 16:19:55 +0100 Subject: [PATCH 1/2] [Flang][Driver] Introduce -fopenmp-targets offloading optio

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-23 Thread Sergio Afonso via cfe-commits
skatrak wrote: > Code changes look good to me. I can't speak to the needs of anyone else using > offloading. > > I see this is copied exactly from `Toolchains/Clang.cpp`. I think that's okay > for such a small bit of code. Thank you for the quick review. Yes, it's basically copied from clang,

[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-07-23 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak created https://github.com/llvm/llvm-project/pull/100152 This patch modifies the flang driver to introduce the `-fopenmp-targets` option to the frontend compiler invocations corresponding to the OpenMP host device on offloading-enabled compilations. This option hold

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-07-03 Thread Sergio Afonso via cfe-commits
@@ -705,28 +740,7 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder, }; SmallVector dds; - if (!taskOp.getDependVars().empty() && taskOp.getDepends()) { -for (auto dep : - llvm::zip(taskOp.getDependVars(), taskOp.getDepends()->getValue()))

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-07-03 Thread Sergio Afonso via cfe-commits
@@ -682,6 +682,41 @@ convertOmpTeams(omp::TeamsOp op, llvm::IRBuilderBase &builder, return bodyGenStatus; } +static void +buildDependData(Operation *op, LLVM::ModuleTranslation &moduleTranslation, skatrak wrote: I'd suggest taking `std::optional depends` a

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-07-03 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-07-03 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak approved this pull request. Thank you Pranav, LGTM. I have just one more comment but no need to wait for another review by me before merging this. Just make sure @Meinersbur is happy with it as well! https://github.com/llvm/llvm-project/pull/93977 ___

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -705,28 +728,9 @@ convertOmpTaskOp(omp::TaskOp taskOp, llvm::IRBuilderBase &builder, }; SmallVector dds; - if (!taskOp.getDependVars().empty() && taskOp.getDepends()) { -for (auto dep : - llvm::zip(taskOp.getDependVars(), taskOp.getDepends()->getValue()))

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -0,0 +1,83 @@ +! Offloading test checking the use of the depend clause on +! the target construct +! REQUIRES: flang, amdgcn-amd-amdhsa +! UNSUPPORTED: nvptx64-nvidia-cuda +! UNSUPPORTED: nvptx64-nvidia-cuda-LTO +! UNSUPPORTED: aarch64-unknown-linux-gnu +! UNSUPPORTED: aarch64-

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
https://github.com/skatrak edited https://github.com/llvm/llvm-project/pull/93977 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -5229,13 +5382,284 @@ static void emitTargetOutlinedFunction( OMPBuilder.emitTargetRegionFunction(EntryInfo, GenerateOutlinedFunction, true, OutlinedFn, OutlinedFnID); } +OpenMPIRBuilder::InsertPointTy OpenMPIRBuilder::emitTargetTask(

[clang] [llvm] [mlir] [OMPIRBuilder] - Handle dependencies in `createTarget` (PR #93977)

2024-06-26 Thread Sergio Afonso via cfe-commits
@@ -5272,36 +5682,53 @@ static void emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder, Value *DynCGGroupMem = Builder.getInt32(0); bool HasNoWait = false; + bool HasDependencies = Dependencies.size() > 0; + bool RequiresOuterTargetTask = HasNoWait || Ha

  1   2   >