Skip to content

Commit 62305b2

Browse files
authored
Revert "[Libomptarget] Rework Record & Replay to be a plugin member (#88928)"
This reverts commit 9a0a28f.
1 parent e11b17a commit 62305b2

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

openmp/libomptarget/plugins-nextgen/common/include/PluginInterface.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
#include "llvm/Support/raw_ostream.h"
4646
#include "llvm/TargetParser/Triple.h"
4747

48-
struct RecordReplayTy;
49-
5048
namespace llvm {
5149
namespace omp {
5250
namespace target {
@@ -1033,12 +1031,6 @@ struct GenericPluginTy {
10331031
return *RPCServer;
10341032
}
10351033

1036-
/// Get a reference to the R&R interface for this plugin.
1037-
RecordReplayTy &getRecordAndReplay() const {
1038-
assert(RecordReplay && "R&R not initialized");
1039-
return *RecordReplay;
1040-
}
1041-
10421034
/// Get the OpenMP requires flags set for this plugin.
10431035
int64_t getRequiresFlags() const { return RequiresFlags; }
10441036

@@ -1228,9 +1220,6 @@ struct GenericPluginTy {
12281220

12291221
/// The interface between the plugin and the GPU for host services.
12301222
RPCServerTy *RPCServer;
1231-
1232-
/// The interface into the record-and-replay functionality.
1233-
RecordReplayTy *RecordReplay;
12341223
};
12351224

12361225
namespace Plugin {

openmp/libomptarget/plugins-nextgen/common/src/PluginInterface.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ struct RecordReplayTy {
362362
}
363363
};
364364

365+
static RecordReplayTy RecordReplay;
366+
365367
// Extract the mapping of host function pointers to device function pointers
366368
// from the entry table. Functions marked as 'indirect' in OpenMP will have
367369
// offloading entries generated for them which map the host's function pointer
@@ -471,8 +473,7 @@ GenericKernelTy::getKernelLaunchEnvironment(
471473
// Ctor/Dtor have no arguments, replaying uses the original kernel launch
472474
// environment. Older versions of the compiler do not generate a kernel
473475
// launch environment.
474-
if (isCtorOrDtor() ||
475-
GenericDevice.Plugin.getRecordAndReplay().isReplaying() ||
476+
if (isCtorOrDtor() || RecordReplay.isReplaying() ||
476477
Version < OMP_KERNEL_ARG_MIN_VERSION_WITH_DYN_PTR)
477478
return nullptr;
478479

@@ -561,7 +562,6 @@ Error GenericKernelTy::launch(GenericDeviceTy &GenericDevice, void **ArgPtrs,
561562

562563
// Record the kernel description after we modified the argument count and num
563564
// blocks/threads.
564-
RecordReplayTy &RecordReplay = GenericDevice.Plugin.getRecordAndReplay();
565565
if (RecordReplay.isRecording()) {
566566
RecordReplay.saveImage(getName(), getImage());
567567
RecordReplay.saveKernelInput(getName(), getImage());
@@ -839,6 +839,9 @@ Error GenericDeviceTy::deinit(GenericPluginTy &Plugin) {
839839
delete MemoryManager;
840840
MemoryManager = nullptr;
841841

842+
if (RecordReplay.isRecordingOrReplaying())
843+
RecordReplay.deinit();
844+
842845
if (RPCServer)
843846
if (auto Err = RPCServer->deinitDevice(*this))
844847
return Err;
@@ -855,7 +858,6 @@ Error GenericDeviceTy::deinit(GenericPluginTy &Plugin) {
855858

856859
return deinitImpl();
857860
}
858-
859861
Expected<DeviceImageTy *>
860862
GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
861863
const __tgt_device_image *InputTgtImage) {
@@ -890,8 +892,7 @@ GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
890892
return std::move(Err);
891893

892894
// Setup the global device memory pool if needed.
893-
if (!Plugin.getRecordAndReplay().isReplaying() &&
894-
shouldSetupDeviceMemoryPool()) {
895+
if (!RecordReplay.isReplaying() && shouldSetupDeviceMemoryPool()) {
895896
uint64_t HeapSize;
896897
auto SizeOrErr = getDeviceHeapSize(HeapSize);
897898
if (SizeOrErr) {
@@ -1306,8 +1307,8 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
13061307
TargetAllocTy Kind) {
13071308
void *Alloc = nullptr;
13081309

1309-
if (Plugin.getRecordAndReplay().isRecordingOrReplaying())
1310-
return Plugin.getRecordAndReplay().alloc(Size);
1310+
if (RecordReplay.isRecordingOrReplaying())
1311+
return RecordReplay.alloc(Size);
13111312

13121313
switch (Kind) {
13131314
case TARGET_ALLOC_DEFAULT:
@@ -1343,7 +1344,7 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
13431344

13441345
Error GenericDeviceTy::dataDelete(void *TgtPtr, TargetAllocTy Kind) {
13451346
// Free is a noop when recording or replaying.
1346-
if (Plugin.getRecordAndReplay().isRecordingOrReplaying())
1347+
if (RecordReplay.isRecordingOrReplaying())
13471348
return Plugin::success();
13481349

13491350
int Res;
@@ -1395,7 +1396,6 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs,
13951396
ptrdiff_t *ArgOffsets,
13961397
KernelArgsTy &KernelArgs,
13971398
__tgt_async_info *AsyncInfo) {
1398-
RecordReplayTy &RecordReplay = Plugin.getRecordAndReplay();
13991399
AsyncInfoWrapperTy AsyncInfoWrapper(
14001400
*this, RecordReplay.isRecordingOrReplaying() ? nullptr : AsyncInfo);
14011401

@@ -1495,9 +1495,6 @@ Error GenericPluginTy::init() {
14951495
RPCServer = new RPCServerTy(*this);
14961496
assert(RPCServer && "Invalid RPC server");
14971497

1498-
RecordReplay = new RecordReplayTy();
1499-
assert(RecordReplay && "Invalid Record and Replay handler");
1500-
15011498
return Plugin::success();
15021499
}
15031500

@@ -1511,19 +1508,13 @@ Error GenericPluginTy::deinit() {
15111508
assert(!Devices[DeviceId] && "Device was not deinitialized");
15121509
}
15131510

1514-
if (RecordReplay && RecordReplay->isRecordingOrReplaying())
1515-
RecordReplay->deinit();
1516-
15171511
// There is no global handler if no device is available.
15181512
if (GlobalHandler)
15191513
delete GlobalHandler;
15201514

15211515
if (RPCServer)
15221516
delete RPCServer;
15231517

1524-
if (RecordReplay)
1525-
delete RecordReplay;
1526-
15271518
// Perform last deinitializations on the plugin.
15281519
return deinitImpl();
15291520
}
@@ -1639,12 +1630,12 @@ int32_t GenericPluginTy::initialize_record_replay(int32_t DeviceId,
16391630
isRecord ? RecordReplayTy::RRStatusTy::RRRecording
16401631
: RecordReplayTy::RRStatusTy::RRReplaying;
16411632

1642-
if (auto Err = RecordReplay->init(&Device, MemorySize, VAddr, Status,
1643-
SaveOutput, ReqPtrArgOffset)) {
1633+
if (auto Err = RecordReplay.init(&Device, MemorySize, VAddr, Status,
1634+
SaveOutput, ReqPtrArgOffset)) {
16441635
REPORT("WARNING RR did not intialize RR-properly with %lu bytes"
16451636
"(Error: %s)\n",
16461637
MemorySize, toString(std::move(Err)).data());
1647-
RecordReplay->setStatus(RecordReplayTy::RRStatusTy::RRDeactivated);
1638+
RecordReplay.setStatus(RecordReplayTy::RRStatusTy::RRDeactivated);
16481639

16491640
if (!isRecord) {
16501641
return OFFLOAD_FAIL;
@@ -1993,8 +1984,8 @@ int32_t GenericPluginTy::get_global(__tgt_device_binary Binary, uint64_t Size,
19931984
assert(DevicePtr && "Invalid device global's address");
19941985

19951986
// Save the loaded globals if we are recording.
1996-
if (getRecordAndReplay().isRecording())
1997-
getRecordAndReplay().addEntry(Name, Size, *DevicePtr);
1987+
if (RecordReplay.isRecording())
1988+
RecordReplay.addEntry(Name, Size, *DevicePtr);
19981989

19991990
return OFFLOAD_SUCCESS;
20001991
}

0 commit comments

Comments
 (0)