From d6929aaa67c7996a69451e301970408362af909e Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Wed, 21 Jul 2021 21:47:54 -0400 Subject: [PATCH] [mlir][openacc] Make use of the second counter extension in DataOp translation Make use of runtime extension for the second reference counter used in structured data region. This extension is implemented in D106510 and D106509. Differential Revision: https://reviews.llvm.org/D106517 --- .../OpenACC/OpenACCToLLVMIRTranslation.cpp | 27 +++++++++++-------- mlir/test/Target/LLVMIR/openacc-llvm.mlir | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp index 2900a095e3db..f6f7be139dd6 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp @@ -40,6 +40,8 @@ static constexpr uint64_t kHostCopyoutFlag = 0x002; static constexpr uint64_t kCopyFlag = kDeviceCopyinFlag | kHostCopyoutFlag; static constexpr uint64_t kPresentFlag = 0x1000; static constexpr uint64_t kDeleteFlag = 0x008; +// Runtime extension to implement the OpenACC second reference counter. +static constexpr uint64_t kHoldFlag = 0x2000; /// Default value for the device id static constexpr int64_t kDefaultDevice = -1; @@ -307,51 +309,54 @@ static LogicalResult convertDataOp(acc::DataOp &op, // TODO handle no_create, deviceptr and attach operands. if (failed(processOperands(builder, moduleTranslation, op, op.copyOperands(), - totalNbOperand, kCopyFlag, flags, names, index, - mapperAllocas))) + totalNbOperand, kCopyFlag | kHoldFlag, flags, + names, index, mapperAllocas))) return failure(); if (failed(processOperands( builder, moduleTranslation, op, op.copyinOperands(), totalNbOperand, - kDeviceCopyinFlag, flags, names, index, mapperAllocas))) + kDeviceCopyinFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); // TODO copyin readonly currenlty handled as copyin. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.copyinReadonlyOperands(), totalNbOperand, - kDeviceCopyinFlag, flags, names, index, + kDeviceCopyinFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); if (failed(processOperands( builder, moduleTranslation, op, op.copyoutOperands(), totalNbOperand, - kHostCopyoutFlag, flags, names, index, mapperAllocas))) + kHostCopyoutFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); // TODO copyout zero currenlty handled as copyout. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.copyoutZeroOperands(), totalNbOperand, - kHostCopyoutFlag, flags, names, index, + kHostCopyoutFlag | kHoldFlag, flags, names, index, mapperAllocas))) return failure(); if (failed(processOperands(builder, moduleTranslation, op, - op.createOperands(), totalNbOperand, kCreateFlag, - flags, names, index, mapperAllocas))) + op.createOperands(), totalNbOperand, + kCreateFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); // TODO create zero currenlty handled as create. Update when extension // available. if (failed(processOperands(builder, moduleTranslation, op, op.createZeroOperands(), totalNbOperand, - kCreateFlag, flags, names, index, mapperAllocas))) + kCreateFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); if (failed(processOperands(builder, moduleTranslation, op, - op.presentOperands(), totalNbOperand, kPresentFlag, - flags, names, index, mapperAllocas))) + op.presentOperands(), totalNbOperand, + kPresentFlag | kHoldFlag, flags, names, index, + mapperAllocas))) return failure(); llvm::GlobalVariable *maptypes = diff --git a/mlir/test/Target/LLVMIR/openacc-llvm.mlir b/mlir/test/Target/LLVMIR/openacc-llvm.mlir index 867213d15276..517897e78611 100644 --- a/mlir/test/Target/LLVMIR/openacc-llvm.mlir +++ b/mlir/test/Target/LLVMIR/openacc-llvm.mlir @@ -208,7 +208,7 @@ llvm.func @testdataop(%arg0: !llvm.struct<(ptr, ptr, i64, array<1 x i6 // CHECK: [[LOCGLOBAL:@.*]] = private unnamed_addr constant %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[LOCSTR]], i32 0, i32 0) }, align 8 // CHECK: [[MAPNAME1:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i8] c";{{.*}};unknown;{{[0-9]*}};{{[0-9]*}};;\00", align 1 // CHECK: [[MAPNAME2:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i8] c";{{.*}};unknown;{{[0-9]*}};{{[0-9]*}};;\00", align 1 -// CHECK: [[MAPTYPES:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i64] [i64 3, i64 2] +// CHECK: [[MAPTYPES:@.*]] = private unnamed_addr constant [{{[0-9]*}} x i64] [i64 8195, i64 8194] // CHECK: [[MAPNAMES:@.*]] = private constant [{{[0-9]*}} x i8*] [i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[MAPNAME1]], i32 0, i32 0), i8* getelementptr inbounds ([{{[0-9]*}} x i8], [{{[0-9]*}} x i8]* [[MAPNAME2]], i32 0, i32 0)] // CHECK: define void @testdataop({ float*, float*, i64, [1 x i64], [1 x i64] } %{{.*}}, float* [[SIMPLEPTR:%.*]], i32* %{{.*}})