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