[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] [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] [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)

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] [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 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 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] 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] [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] 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] [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] [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] 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 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] [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
@@ -2378,7 +2464,7 @@ convertOmpParallel(omp::ParallelOp opInst, llvm::IRBuilderBase &builder, llvm::OpenMPIRBuilder::InsertPointOrErrorTy contInsertPoint = ompBuilder->createReductions(builder.saveIP(), allocaIP, - reduct

[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] [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] [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
@@ -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
@@ -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 `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
@@ -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
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
@@ -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] [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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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] [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-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
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] [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] [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 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-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 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] [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

<    1   2