Skip to content

Commit 763fdb1

Browse files
committed
[OpenMP][Plugin] Update the global address calculation
Current global address caculation doesn't work for AMDGPU in some cases (https://reviews.llvm.org/D142569#4506212). The root cause is the `sh_addr` is not substracted when caculating the address. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D155886
1 parent 5da317a commit 763fdb1

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,22 +2583,6 @@ struct AMDGPUGlobalHandlerTy final : public GenericGlobalHandlerTy {
25832583
// Store the symbol address on the device global metadata.
25842584
DeviceGlobal.setPtr(reinterpret_cast<void *>(SymbolAddr));
25852585

2586-
return Plugin::success();
2587-
}
2588-
2589-
private:
2590-
/// Extract the global's information from the ELF image, section, and symbol.
2591-
Error getGlobalMetadataFromELF(const DeviceImageTy &Image,
2592-
const ELF64LE::Sym &Symbol,
2593-
const ELF64LE::Shdr &Section,
2594-
GlobalTy &ImageGlobal) override {
2595-
// The global's address in AMDGPU is computed as the image begin + the ELF
2596-
// symbol value. Notice we do not add the ELF section offset.
2597-
ImageGlobal.setPtr(advanceVoidPtr(Image.getStart(), Symbol.st_value));
2598-
2599-
// Set the global's size.
2600-
ImageGlobal.setSize(Symbol.st_size);
2601-
26022586
return Plugin::success();
26032587
}
26042588
};

openmp/libomptarget/plugins-nextgen/common/PluginInterface/GlobalHandler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Error GenericGlobalHandlerTy::getGlobalMetadataFromELF(
5353

5454
// The global's address is computed as the image begin + the ELF section
5555
// offset + the ELF symbol value.
56-
ImageGlobal.setPtr(
57-
advanceVoidPtr(Image.getStart(), Section.sh_offset + Symbol.st_value));
56+
ImageGlobal.setPtr(advanceVoidPtr(
57+
Image.getStart(), Section.sh_offset - Section.sh_addr + Symbol.st_value));
5858

5959
// Set the global's size.
6060
ImageGlobal.setSize(Symbol.st_size);

0 commit comments

Comments
 (0)