[flang-commits] [llvm] [compiler-rt] [clang] [openmp] [lldb] [libcxx] [flang] [clang-tools-extra] [OpenMP] Add memory diff dump for kernel record-replay (PR #70667)

Giorgis Georgakoudis via flang-commits flang-commits at lists.llvm.org
Tue Oct 31 13:53:14 PDT 2023


================
@@ -141,13 +141,56 @@ struct RecordReplayTy {
     if (Err)
       report_fatal_error("Error retrieving data for target pointer");
 
-    StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize);
     std::error_code EC;
     raw_fd_ostream OS(Filename, EC);
     if (EC)
       report_fatal_error("Error dumping memory to file " + Filename + " :" +
                          EC.message());
-    OS << DeviceMemory;
+
+    if (saveDiff) {
+      // Get the pre-record memory filename
+      SmallString<128> InputFilename = {Filename.split('.').first, ".memory"};
+      // read the pre-record memorydump
+      auto InputFileBuffer = MemoryBuffer::getFileOrSTDIN(InputFilename);
+      if (std::error_code EC = InputFileBuffer.getError())
+        report_fatal_error("Error reading pre-record device memory");
+
+      StringRef InputBufferContents = (*InputFileBuffer)->getBuffer();
+      if (InputBufferContents.size() != MemorySize)
+        report_fatal_error("Error: Pre-record device memory size mismatch");
+
+      // get current memory contents
+      StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(),
+                                     DeviceMemoryMB.get()->getBuffer().size());
+
+      // compare pre-record memorydump to current contents
+      size_t i = 0;
----------------
ggeorgakoudis wrote:

rename i -> I

https://github.com/llvm/llvm-project/pull/70667


More information about the flang-commits mailing list