[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
This commit is contained in:
Valentin Clement 2021-07-21 21:47:54 -04:00
parent b1099120ff
commit d6929aaa67
No known key found for this signature in database
GPG Key ID: 086D54783C928776
2 changed files with 17 additions and 12 deletions

View File

@ -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 =

View File

@ -208,7 +208,7 @@ llvm.func @testdataop(%arg0: !llvm.struct<(ptr<f32>, ptr<f32>, 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* %{{.*}})