@@ -362,8 +362,6 @@ struct RecordReplayTy {
362
362
}
363
363
};
364
364
365
- static RecordReplayTy RecordReplay;
366
-
367
365
// Extract the mapping of host function pointers to device function pointers
368
366
// from the entry table. Functions marked as 'indirect' in OpenMP will have
369
367
// offloading entries generated for them which map the host's function pointer
@@ -473,7 +471,8 @@ GenericKernelTy::getKernelLaunchEnvironment(
473
471
// Ctor/Dtor have no arguments, replaying uses the original kernel launch
474
472
// environment. Older versions of the compiler do not generate a kernel
475
473
// launch environment.
476
- if (isCtorOrDtor () || RecordReplay.isReplaying () ||
474
+ if (isCtorOrDtor () ||
475
+ GenericDevice.Plugin .getRecordAndReplay ().isReplaying () ||
477
476
Version < OMP_KERNEL_ARG_MIN_VERSION_WITH_DYN_PTR)
478
477
return nullptr ;
479
478
@@ -562,6 +561,7 @@ Error GenericKernelTy::launch(GenericDeviceTy &GenericDevice, void **ArgPtrs,
562
561
563
562
// Record the kernel description after we modified the argument count and num
564
563
// blocks/threads.
564
+ RecordReplayTy &RecordReplay = GenericDevice.Plugin .getRecordAndReplay ();
565
565
if (RecordReplay.isRecording ()) {
566
566
RecordReplay.saveImage (getName (), getImage ());
567
567
RecordReplay.saveKernelInput (getName (), getImage ());
@@ -839,8 +839,8 @@ Error GenericDeviceTy::deinit(GenericPluginTy &Plugin) {
839
839
delete MemoryManager;
840
840
MemoryManager = nullptr ;
841
841
842
- if (RecordReplay .isRecordingOrReplaying ())
843
- RecordReplay .deinit ();
842
+ if (Plugin. getRecordAndReplay () .isRecordingOrReplaying ())
843
+ Plugin. getRecordAndReplay () .deinit ();
844
844
845
845
if (RPCServer)
846
846
if (auto Err = RPCServer->deinitDevice (*this ))
@@ -858,6 +858,7 @@ Error GenericDeviceTy::deinit(GenericPluginTy &Plugin) {
858
858
859
859
return deinitImpl ();
860
860
}
861
+
861
862
Expected<DeviceImageTy *>
862
863
GenericDeviceTy::loadBinary (GenericPluginTy &Plugin,
863
864
const __tgt_device_image *InputTgtImage) {
@@ -892,7 +893,8 @@ GenericDeviceTy::loadBinary(GenericPluginTy &Plugin,
892
893
return std::move (Err);
893
894
894
895
// Setup the global device memory pool if needed.
895
- if (!RecordReplay.isReplaying () && shouldSetupDeviceMemoryPool ()) {
896
+ if (!Plugin.getRecordAndReplay ().isReplaying () &&
897
+ shouldSetupDeviceMemoryPool ()) {
896
898
uint64_t HeapSize;
897
899
auto SizeOrErr = getDeviceHeapSize (HeapSize);
898
900
if (SizeOrErr) {
@@ -1307,8 +1309,8 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
1307
1309
TargetAllocTy Kind) {
1308
1310
void *Alloc = nullptr ;
1309
1311
1310
- if (RecordReplay .isRecordingOrReplaying ())
1311
- return RecordReplay .alloc (Size );
1312
+ if (Plugin. getRecordAndReplay () .isRecordingOrReplaying ())
1313
+ return Plugin. getRecordAndReplay () .alloc (Size );
1312
1314
1313
1315
switch (Kind) {
1314
1316
case TARGET_ALLOC_DEFAULT:
@@ -1344,7 +1346,7 @@ Expected<void *> GenericDeviceTy::dataAlloc(int64_t Size, void *HostPtr,
1344
1346
1345
1347
Error GenericDeviceTy::dataDelete (void *TgtPtr, TargetAllocTy Kind) {
1346
1348
// Free is a noop when recording or replaying.
1347
- if (RecordReplay .isRecordingOrReplaying ())
1349
+ if (Plugin. getRecordAndReplay () .isRecordingOrReplaying ())
1348
1350
return Plugin::success ();
1349
1351
1350
1352
int Res;
@@ -1396,6 +1398,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs,
1396
1398
ptrdiff_t *ArgOffsets,
1397
1399
KernelArgsTy &KernelArgs,
1398
1400
__tgt_async_info *AsyncInfo) {
1401
+ RecordReplayTy &RecordReplay = Plugin.getRecordAndReplay ();
1399
1402
AsyncInfoWrapperTy AsyncInfoWrapper (
1400
1403
*this , RecordReplay.isRecordingOrReplaying () ? nullptr : AsyncInfo);
1401
1404
@@ -1495,6 +1498,9 @@ Error GenericPluginTy::init() {
1495
1498
RPCServer = new RPCServerTy (*this );
1496
1499
assert (RPCServer && " Invalid RPC server" );
1497
1500
1501
+ RecordReplay = new RecordReplayTy ();
1502
+ assert (RecordReplay && " Invalid Record and Replay handler" );
1503
+
1498
1504
return Plugin::success ();
1499
1505
}
1500
1506
@@ -1515,6 +1521,9 @@ Error GenericPluginTy::deinit() {
1515
1521
if (RPCServer)
1516
1522
delete RPCServer;
1517
1523
1524
+ if (RecordReplay)
1525
+ delete RecordReplay;
1526
+
1518
1527
// Perform last deinitializations on the plugin.
1519
1528
return deinitImpl ();
1520
1529
}
@@ -1630,12 +1639,12 @@ int32_t GenericPluginTy::initialize_record_replay(int32_t DeviceId,
1630
1639
isRecord ? RecordReplayTy::RRStatusTy::RRRecording
1631
1640
: RecordReplayTy::RRStatusTy::RRReplaying;
1632
1641
1633
- if (auto Err = RecordReplay .init (&Device, MemorySize, VAddr, Status,
1634
- SaveOutput, ReqPtrArgOffset)) {
1642
+ if (auto Err = getRecordAndReplay () .init (&Device, MemorySize, VAddr, Status,
1643
+ SaveOutput, ReqPtrArgOffset)) {
1635
1644
REPORT (" WARNING RR did not intialize RR-properly with %lu bytes"
1636
1645
" (Error: %s)\n " ,
1637
1646
MemorySize, toString (std::move (Err)).data ());
1638
- RecordReplay. setStatus (RecordReplayTy::RRStatusTy::RRDeactivated);
1647
+ RecordReplay-> setStatus (RecordReplayTy::RRStatusTy::RRDeactivated);
1639
1648
1640
1649
if (!isRecord) {
1641
1650
return OFFLOAD_FAIL;
@@ -1984,8 +1993,8 @@ int32_t GenericPluginTy::get_global(__tgt_device_binary Binary, uint64_t Size,
1984
1993
assert (DevicePtr && " Invalid device global's address" );
1985
1994
1986
1995
// Save the loaded globals if we are recording.
1987
- if (RecordReplay .isRecording ())
1988
- RecordReplay .addEntry (Name, Size , *DevicePtr);
1996
+ if (getRecordAndReplay () .isRecording ())
1997
+ getRecordAndReplay () .addEntry (Name, Size , *DevicePtr);
1989
1998
1990
1999
return OFFLOAD_SUCCESS;
1991
2000
}
0 commit comments