[Openmp-commits] [openmp] [openmp] Add memory diff dump for kernel record-replay (PR #70667)
via Openmp-commits
openmp-commits at lists.llvm.org
Mon Oct 30 08:17:43 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 6a62707c048e16ce9bad37ed8e3520799139436b 153c6d812939cd23bb71e53c71378117ed5b23c7 -- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
index 8469e8eaf159..062165112317 100644
--- a/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ b/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -93,58 +93,58 @@ private:
MemoryStart, MemorySize, nullptr);
if (Err)
report_fatal_error("Error retrieving data for target pointer");
-
- std::error_code EC;
- raw_fd_ostream OS(Filename, EC);
- if(EC)
+
+ std::error_code EC;
+ raw_fd_ostream OS(Filename, EC);
+ if (EC)
report_fatal_error("Error dumping memory to file " + Filename + " :" +
EC.message());
-
- if (saveDiff){
- //Get the pre-record memory filename
+
+ 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())
+ // 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)
+
+ StringRef InputBufferContents = (*InputFileBuffer)->getBuffer();
+ if (InputBufferContents.size() != MemorySize)
report_fatal_error("Error: Pre-record device memory size mismatch");
-
- //get current memory contents
+
+ // get current memory contents
StringRef DeviceMemoryContents(DeviceMemoryMB.get()->getBuffer().data(),
DeviceMemoryMB.get()->getBuffer().size());
-
- //compare pre-record memorydump to current contents
+
+ // compare pre-record memorydump to current contents
size_t i = 0;
- while(i < MemorySize){
- //if mismatch found, create a new diff line
- //current format - location, size, differences ...
- if(InputBufferContents[i] != DeviceMemoryContents[i]){
- OS << i << " "; //marks the start offset
- SmallVector<uint8_t, 128> modified;
+ while (i < MemorySize) {
+ // if mismatch found, create a new diff line
+ // current format - location, size, differences ...
+ if (InputBufferContents[i] != DeviceMemoryContents[i]) {
+ OS << i << " "; // marks the start offset
+ SmallVector<uint8_t, 128> modified;
modified.push_back(DeviceMemoryContents[i]);
size_t j = 1;
- //loop until next match is found
- while(InputBufferContents[i+j] != DeviceMemoryContents[i+j]){
- modified.push_back(DeviceMemoryContents[i+j]);
+ // loop until next match is found
+ while (InputBufferContents[i + j] != DeviceMemoryContents[i + j]) {
+ modified.push_back(DeviceMemoryContents[i + j]);
j++;
}
- OS << j << " "; //marks the length of the mismatching sequence
- for(const auto &value : modified)
+ OS << j << " "; // marks the length of the mismatching sequence
+ for (const auto &value : modified)
OS << value << " ";
- OS << "\n";
- i+=j+1;
- }
- else i++;
+ OS << "\n";
+ i += j + 1;
+ } else
+ i++;
}
- }
- else {
- StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(), MemorySize);
+ } else {
+ StringRef DeviceMemory(DeviceMemoryMB.get()->getBufferStart(),
+ MemorySize);
OS << DeviceMemory;
}
- OS.close();
+ OS.close();
}
public:
@@ -1350,7 +1350,7 @@ Error GenericDeviceTy::launchKernel(void *EntryPtr, void **ArgPtrs,
GenericKernel.getName(), GenericKernel.getImage(), ArgPtrs, ArgOffsets,
KernelArgs.NumArgs, KernelArgs.NumTeams[0], KernelArgs.ThreadLimit[0],
KernelArgs.Tripcount);
-
+
if (RecordReplay.isRecording())
RecordReplay.saveImage(GenericKernel.getName(), GenericKernel.getImage());
``````````
</details>
https://github.com/llvm/llvm-project/pull/70667
More information about the Openmp-commits
mailing list