Skip to content

Commit 168a2b8

Browse files
adurangabhinavgaba
authored andcommitted
add dataFence to plugin interface
1 parent de8d968 commit 168a2b8

File tree

7 files changed

+40
-0
lines changed

7 files changed

+40
-0
lines changed

offload/include/device.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ struct DeviceTy {
9898
int32_t dataExchange(void *SrcPtr, DeviceTy &DstDev, void *DstPtr,
9999
int64_t Size, AsyncInfoTy &AsyncInfo);
100100

101+
// Insert a data fence between previous data operations and the following
102+
// operations if necessary for the device.
103+
int32_t dataFence(AsyncInfoTy &AsyncInfo);
104+
105+
101106
/// Notify the plugin about a new mapping starting at the host address
102107
/// \p HstPtr and \p Size bytes.
103108
int32_t notifyDataMapped(void *HstPtr, int64_t Size);

offload/libomptarget/device.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ int32_t DeviceTy::dataExchange(void *SrcPtr, DeviceTy &DstDev, void *DstPtr,
191191
DstPtr, Size, AsyncInfo);
192192
}
193193

194+
int32_t DeviceTy::dataFence(AsyncInfoTy &AsyncInfo) {
195+
return RTL->data_fence(RTLDeviceID, AsyncInfo);
196+
}
197+
194198
int32_t DeviceTy::notifyDataMapped(void *HstPtr, int64_t Size) {
195199
DP("Notifying about new mapping: HstPtr=" DPxMOD ", Size=%" PRId64 "\n",
196200
DPxPTR(HstPtr), Size);

offload/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,10 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy {
25382538
getAgent(), (uint64_t)Size);
25392539
}
25402540

2541+
Error dataFence(__tgt_async_info *Async) override {
2542+
return Plugin::success();
2543+
}
2544+
25412545
/// Initialize the async info for interoperability purposes.
25422546
Error initAsyncInfoImpl(AsyncInfoWrapperTy &AsyncInfoWrapper) override {
25432547
// TODO: Implement this function.

offload/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,10 @@ struct GenericDeviceTy : public DeviceAllocatorTy {
891891
virtual Error dataRetrieveImpl(void *HstPtr, const void *TgtPtr, int64_t Size,
892892
AsyncInfoWrapperTy &AsyncInfoWrapper) = 0;
893893

894+
/// Instert a data fence between previous data operations and the following
895+
/// operations if necessary for the device
896+
virtual Error dataFence(__tgt_async_info *AsyncInfo) = 0;
897+
894898
/// Exchange data between devices (device to device transfer). Calling this
895899
/// function is only valid if GenericPlugin::isDataExchangable() passing the
896900
/// two devices returns true.
@@ -1355,6 +1359,10 @@ struct GenericPluginTy {
13551359
int DstDeviceId, void *DstPtr, int64_t Size,
13561360
__tgt_async_info *AsyncInfo);
13571361

1362+
/// Places a fence between previous data movements and following data movements
1363+
/// if necessary on the device
1364+
int32_t data_fence(int32_t DeviceId, __tgt_async_info *AsyncInfo);
1365+
13581366
/// Begin executing a kernel on the given device.
13591367
int32_t launch_kernel(int32_t DeviceId, void *TgtEntryPtr, void **TgtArgs,
13601368
ptrdiff_t *TgtOffsets, KernelArgsTy *KernelArgs,

offload/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,3 +2231,14 @@ int32_t GenericPluginTy::get_function(__tgt_device_binary Binary,
22312231
*KernelPtr = &Kernel;
22322232
return OFFLOAD_SUCCESS;
22332233
}
2234+
2235+
int32_t GenericPluginTy::data_fence(int32_t DeviceId, __tgt_async_info *AsyncInfo ) {
2236+
auto Err = getDevice(DeviceId).dataFence(AsyncInfo);
2237+
if (Err) {
2238+
REPORT("Failure to place data fence on device %d: %s\n",
2239+
DeviceId, toString(std::move(Err)).data());
2240+
return OFFLOAD_FAIL;
2241+
}
2242+
2243+
return OFFLOAD_SUCCESS;
2244+
}

offload/plugins-nextgen/cuda/src/rtl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,10 @@ struct CUDADeviceTy : public GenericDeviceTy {
858858
return Plugin::success();
859859
}
860860

861+
Error dataFence(__tgt_async_info *Async) override {
862+
return Plugin::success();
863+
}
864+
861865
/// Initialize the device info for interoperability purposes.
862866
Error initDeviceInfoImpl(__tgt_device_info *DeviceInfo) override {
863867
assert(Context && "Context is null");

offload/plugins-nextgen/host/src/rtl.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,10 @@ struct GenELF64DeviceTy : public GenericDeviceTy {
295295
"dataExchangeImpl not supported");
296296
}
297297

298+
Error dataFence(__tgt_async_info *Async) override {
299+
return Plugin::success();
300+
}
301+
298302
/// All functions are already synchronous. No need to do anything on this
299303
/// synchronization function.
300304
Error synchronizeImpl(__tgt_async_info &AsyncInfo) override {

0 commit comments

Comments
 (0)