@@ -2434,6 +2434,7 @@ class OpenMPIRBuilder {
2434
2434
CurInfo.NonContigInfo .Strides .end ());
2435
2435
}
2436
2436
};
2437
+ using MapInfosOrErrorTy = Expected<MapInfosTy &>;
2437
2438
2438
2439
// / Callback function type for functions emitting the host fallback code that
2439
2440
// / is executed when the kernel launch fails. It takes an insertion point as
@@ -2442,6 +2443,11 @@ class OpenMPIRBuilder {
2442
2443
using EmitFallbackCallbackTy =
2443
2444
function_ref<InsertPointOrErrorTy(InsertPointTy)>;
2444
2445
2446
+ // Callback function type for emitting and fetching user defined custom
2447
+ // mappers.
2448
+ using CustomMapperCallbackTy =
2449
+ function_ref<Expected<Function *>(unsigned int )>;
2450
+
2445
2451
// / Generate a target region entry call and host fallback call.
2446
2452
// /
2447
2453
// / \param Loc The location at which the request originated and is fulfilled.
@@ -2508,24 +2514,24 @@ class OpenMPIRBuilder {
2508
2514
// / return nullptr by reference. Accepts a reference to a MapInfosTy object
2509
2515
// / that contains information generated for mappable clauses,
2510
2516
// / including base pointers, pointers, sizes, map types, user-defined mappers.
2511
- void emitOffloadingArrays (
2517
+ Error emitOffloadingArrays (
2512
2518
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
2513
- TargetDataInfo &Info, bool IsNonContiguous = false ,
2514
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB = nullptr ,
2515
- function_ref<Value * (unsigned int )> CustomMapperCB = nullptr);
2519
+ TargetDataInfo &Info, CustomMapperCallbackTy CustomMapperCB ,
2520
+ bool IsNonContiguous = false ,
2521
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB = nullptr);
2516
2522
2517
2523
// / Allocates memory for and populates the arrays required for offloading
2518
2524
// / (offload_{baseptrs|ptrs|mappers|sizes|maptypes|mapnames}). Then, it
2519
2525
// / emits their base addresses as arguments to be passed to the runtime
2520
2526
// / library. In essence, this function is a combination of
2521
2527
// / emitOffloadingArrays and emitOffloadingArraysArgument and should arguably
2522
2528
// / be preferred by clients of OpenMPIRBuilder.
2523
- void emitOffloadingArraysAndArgs (
2529
+ Error emitOffloadingArraysAndArgs (
2524
2530
InsertPointTy AllocaIP, InsertPointTy CodeGenIP, TargetDataInfo &Info,
2525
2531
TargetDataRTArgs &RTArgs, MapInfosTy &CombinedInfo,
2526
- bool IsNonContiguous = false , bool ForEndCall = false ,
2527
- function_ref< void ( unsigned int , Value *)> DeviceAddrCB = nullptr ,
2528
- function_ref<Value * (unsigned int )> CustomMapperCB = nullptr);
2532
+ CustomMapperCallbackTy CustomMapperCB , bool IsNonContiguous = false ,
2533
+ bool ForEndCall = false ,
2534
+ function_ref<void (unsigned int , Value * )> DeviceAddrCB = nullptr);
2529
2535
2530
2536
// / Creates offloading entry for the provided entry ID \a ID, address \a
2531
2537
// / Addr, size \a Size, and flags \a Flags.
@@ -2993,12 +2999,12 @@ class OpenMPIRBuilder {
2993
2999
// / \param FuncName Optional param to specify mapper function name.
2994
3000
// / \param CustomMapperCB Optional callback to generate code related to
2995
3001
// / custom mappers.
2996
- Function *emitUserDefinedMapper (
2997
- function_ref<MapInfosTy &(InsertPointTy CodeGenIP, llvm::Value *PtrPHI,
2998
- llvm::Value *BeginArg)>
3002
+ Expected< Function *> emitUserDefinedMapper (
3003
+ function_ref<MapInfosOrErrorTy(
3004
+ InsertPointTy CodeGenIP, llvm::Value *PtrPHI, llvm::Value *BeginArg)>
2999
3005
PrivAndGenMapInfoCB,
3000
3006
llvm::Type *ElemTy, StringRef FuncName,
3001
- function_ref<bool( unsigned int , Function **)> CustomMapperCB = nullptr );
3007
+ CustomMapperCallbackTy CustomMapperCB);
3002
3008
3003
3009
// / Generator for '#omp target data'
3004
3010
// /
@@ -3012,21 +3018,21 @@ class OpenMPIRBuilder {
3012
3018
// / \param IfCond Value which corresponds to the if clause condition.
3013
3019
// / \param Info Stores all information realted to the Target Data directive.
3014
3020
// / \param GenMapInfoCB Callback that populates the MapInfos and returns.
3021
+ // / \param CustomMapperCB Callback to generate code related to
3022
+ // / custom mappers.
3015
3023
// / \param BodyGenCB Optional Callback to generate the region code.
3016
3024
// / \param DeviceAddrCB Optional callback to generate code related to
3017
3025
// / use_device_ptr and use_device_addr.
3018
- // / \param CustomMapperCB Optional callback to generate code related to
3019
- // / custom mappers.
3020
3026
InsertPointOrErrorTy createTargetData (
3021
3027
const LocationDescription &Loc, InsertPointTy AllocaIP,
3022
3028
InsertPointTy CodeGenIP, Value *DeviceID, Value *IfCond,
3023
3029
TargetDataInfo &Info, GenMapInfoCallbackTy GenMapInfoCB,
3030
+ CustomMapperCallbackTy CustomMapperCB,
3024
3031
omp::RuntimeFunction *MapperFunc = nullptr ,
3025
3032
function_ref<InsertPointOrErrorTy(InsertPointTy CodeGenIP,
3026
3033
BodyGenTy BodyGenType)>
3027
3034
BodyGenCB = nullptr,
3028
3035
function_ref<void(unsigned int , Value *)> DeviceAddrCB = nullptr,
3029
- function_ref<Value *(unsigned int )> CustomMapperCB = nullptr,
3030
3036
Value *SrcLocInfo = nullptr);
3031
3037
3032
3038
using TargetBodyGenCallbackTy = function_ref<InsertPointOrErrorTy(
@@ -3042,6 +3048,7 @@ class OpenMPIRBuilder {
3042
3048
// / \param IsOffloadEntry whether it is an offload entry.
3043
3049
// / \param CodeGenIP The insertion point where the call to the outlined
3044
3050
// / function should be emitted.
3051
+ // / \param Info Stores all information realted to the Target directive.
3045
3052
// / \param EntryInfo The entry information about the function.
3046
3053
// / \param DefaultAttrs Structure containing the default attributes, including
3047
3054
// / numbers of threads and teams to launch the kernel with.
@@ -3053,20 +3060,23 @@ class OpenMPIRBuilder {
3053
3060
// / \param BodyGenCB Callback that will generate the region code.
3054
3061
// / \param ArgAccessorFuncCB Callback that will generate accessors
3055
3062
// / instructions for passed in target arguments where neccessary
3063
+ // / \param CustomMapperCB Callback to generate code related to
3064
+ // / custom mappers.
3056
3065
// / \param Dependencies A vector of DependData objects that carry
3057
3066
// / dependency information as passed in the depend clause
3058
3067
// / \param HasNowait Whether the target construct has a `nowait` clause or
3059
3068
// / not.
3060
3069
InsertPointOrErrorTy createTarget (
3061
3070
const LocationDescription &Loc, bool IsOffloadEntry,
3062
3071
OpenMPIRBuilder::InsertPointTy AllocaIP,
3063
- OpenMPIRBuilder::InsertPointTy CodeGenIP,
3072
+ OpenMPIRBuilder::InsertPointTy CodeGenIP, TargetDataInfo &Info,
3064
3073
TargetRegionEntryInfo &EntryInfo,
3065
3074
const TargetKernelDefaultAttrs &DefaultAttrs,
3066
3075
const TargetKernelRuntimeAttrs &RuntimeAttrs, Value *IfCond,
3067
3076
SmallVectorImpl<Value *> &Inputs, GenMapInfoCallbackTy GenMapInfoCB,
3068
3077
TargetBodyGenCallbackTy BodyGenCB,
3069
3078
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
3079
+ CustomMapperCallbackTy CustomMapperCB,
3070
3080
SmallVector<DependData> Dependencies = {}, bool HasNowait = false );
3071
3081
3072
3082
// / Returns __kmpc_for_static_init_* runtime function for the specified
0 commit comments