[Openmp-commits] [openmp] [openmp] Fixed Support for VA for record-replay. (PR #70396)
Johannes Doerfert via Openmp-commits
openmp-commits at lists.llvm.org
Sat Oct 28 11:18:13 PDT 2023
================
@@ -49,40 +49,88 @@ struct RecordReplayTy {
void *MemoryStart;
void *MemoryPtr;
size_t MemorySize;
+ size_t TotalSize;
GenericDeviceTy *Device;
std::mutex AllocationLock;
RRStatusTy Status;
bool ReplaySaveOutput;
- uint64_t DeviceMemorySize;
-
- // Record/replay pre-allocates the largest possible device memory using the
- // default kind.
- // TODO: Expand allocation to include other kinds (device, host, shared) and
- // possibly use a MemoryManager to track (de-)allocations for
- // storing/retrieving when recording/replaying.
- Error preallocateDeviceMemory(uint64_t DeviceMemorySize) {
- // Pre-allocate memory on device. Starts with 64GB and subtracts in steps
- // of 1GB until allocation succeeds.
- const size_t MAX_MEMORY_ALLOCATION = DeviceMemorySize;
+
+ void *suggestAddress(uint64_t MaxMemoryAllocation) {
+ // Get a valid pointer address for this system
+ void *Addr =
+ Device->allocate(1024, /* HstPtr */ nullptr, TARGET_ALLOC_DEFAULT);
+ Device->free(Addr);
+ // Align Address to MaxMemoryAllocation
+ Addr = (void *)alignPtr((Addr), MaxMemoryAllocation);
+ return Addr;
+ }
+
+ Error preAllocateVAMemory(uint64_t MaxMemoryAllocation, void *VAddr) {
+ size_t ASize = MaxMemoryAllocation;
+
+ if (!VAddr && isRecording()) {
+ VAddr = suggestAddress(MaxMemoryAllocation);
+ }
----------------
jdoerfert wrote:
Nit: We usually drop the braces around single line conditionals.
https://github.com/llvm/llvm-project/pull/70396
More information about the Openmp-commits
mailing list