aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Lacerda <leandrolcampos@yahoo.com.br>2025-09-09 22:27:55 -0300
committerGitHub <noreply@github.com>2025-09-09 20:27:55 -0500
commit99b0261be0c439b30d85e506706bc69928da4535 (patch)
tree2c5170aa35a4c9f3bc77294cc927f8da3619095a
parent0dc73458802c21831a4611b49dd3657208222654 (diff)
downloadllvm-users/RossBrunton/newMemInfo1.zip
llvm-users/RossBrunton/newMemInfo1.tar.gz
llvm-users/RossBrunton/newMemInfo1.tar.bz2
[Offload][Conformance] Update olMemFree calls in conformance tests (#157773)users/RossBrunton/newMemInfo1
This PR is a follow-up to the change introduced in #157478, which added a `platform` parameter to the `olMemFree` function.
-rw-r--r--offload/unittests/Conformance/include/mathtest/DeviceContext.hpp9
-rw-r--r--offload/unittests/Conformance/include/mathtest/DeviceResources.hpp7
-rw-r--r--offload/unittests/Conformance/include/mathtest/GpuMathTest.hpp4
-rw-r--r--offload/unittests/Conformance/lib/DeviceContext.cpp28
4 files changed, 14 insertions, 34 deletions
diff --git a/offload/unittests/Conformance/include/mathtest/DeviceContext.hpp b/offload/unittests/Conformance/include/mathtest/DeviceContext.hpp
index 7a11798..95e9013 100644
--- a/offload/unittests/Conformance/include/mathtest/DeviceContext.hpp
+++ b/offload/unittests/Conformance/include/mathtest/DeviceContext.hpp
@@ -57,13 +57,13 @@ public:
explicit DeviceContext(llvm::StringRef Platform, std::size_t DeviceId = 0);
template <typename T>
- ManagedBuffer<T> createManagedBuffer(std::size_t Size) noexcept {
+ ManagedBuffer<T> createManagedBuffer(std::size_t Size) const noexcept {
void *UntypedAddress = nullptr;
detail::allocManagedMemory(DeviceHandle, Size * sizeof(T), &UntypedAddress);
T *TypedAddress = static_cast<T *>(UntypedAddress);
- return ManagedBuffer<T>(getPlatformHandle(), TypedAddress, Size);
+ return ManagedBuffer<T>(PlatformHandle, TypedAddress, Size);
}
[[nodiscard]] llvm::Expected<std::shared_ptr<DeviceImage>>
@@ -120,9 +120,6 @@ public:
[[nodiscard]] llvm::StringRef getPlatform() const noexcept;
- [[nodiscard]] llvm::Expected<ol_platform_handle_t>
- getPlatformHandle() noexcept;
-
private:
[[nodiscard]] llvm::Expected<ol_symbol_handle_t>
getKernelHandle(ol_program_handle_t ProgramHandle,
@@ -134,7 +131,7 @@ private:
std::size_t GlobalDeviceId;
ol_device_handle_t DeviceHandle;
- ol_platform_handle_t PlatformHandle = nullptr;
+ ol_platform_handle_t PlatformHandle;
};
} // namespace mathtest
diff --git a/offload/unittests/Conformance/include/mathtest/DeviceResources.hpp b/offload/unittests/Conformance/include/mathtest/DeviceResources.hpp
index 6084732b..d6d9be6 100644
--- a/offload/unittests/Conformance/include/mathtest/DeviceResources.hpp
+++ b/offload/unittests/Conformance/include/mathtest/DeviceResources.hpp
@@ -47,7 +47,8 @@ public:
ManagedBuffer &operator=(const ManagedBuffer &) = delete;
ManagedBuffer(ManagedBuffer &&Other) noexcept
- : Address(Other.Address), Size(Other.Size) {
+ : Platform(Other.Platform), Address(Other.Address), Size(Other.Size) {
+ Other.Platform = nullptr;
Other.Address = nullptr;
Other.Size = 0;
}
@@ -59,9 +60,11 @@ public:
if (Address)
detail::freeDeviceMemory(Platform, Address);
+ Platform = Other.Platform;
Address = Other.Address;
Size = Other.Size;
+ Other.Platform = nullptr;
Other.Address = nullptr;
Other.Size = 0;
@@ -89,7 +92,7 @@ private:
std::size_t Size) noexcept
: Platform(Platform), Address(Address), Size(Size) {}
- ol_platform_handle_t Platform;
+ ol_platform_handle_t Platform = nullptr;
T *Address = nullptr;
std::size_t Size = 0;
};
diff --git a/offload/unittests/Conformance/include/mathtest/GpuMathTest.hpp b/offload/unittests/Conformance/include/mathtest/GpuMathTest.hpp
index fdf30d5..b88d6e9 100644
--- a/offload/unittests/Conformance/include/mathtest/GpuMathTest.hpp
+++ b/offload/unittests/Conformance/include/mathtest/GpuMathTest.hpp
@@ -75,7 +75,7 @@ public:
ResultType run(GeneratorType &Generator,
std::size_t BufferSize = DefaultBufferSize,
- uint32_t GroupSize = DefaultGroupSize) noexcept {
+ uint32_t GroupSize = DefaultGroupSize) const noexcept {
assert(BufferSize > 0 && "Buffer size must be a positive value");
assert(GroupSize > 0 && "Group size must be a positive value");
@@ -128,7 +128,7 @@ private:
return *ExpectedKernel;
}
- [[nodiscard]] auto createBuffers(std::size_t BufferSize) {
+ [[nodiscard]] auto createBuffers(std::size_t BufferSize) const {
auto InBuffersTuple = std::apply(
[&](auto... InTypeIdentities) {
return std::make_tuple(
diff --git a/offload/unittests/Conformance/lib/DeviceContext.cpp b/offload/unittests/Conformance/lib/DeviceContext.cpp
index d72f56c..987d784 100644
--- a/offload/unittests/Conformance/lib/DeviceContext.cpp
+++ b/offload/unittests/Conformance/lib/DeviceContext.cpp
@@ -103,6 +103,7 @@ getPlatformBackend(ol_platform_handle_t PlatformHandle) noexcept {
struct Device {
ol_device_handle_t Handle;
+ ol_platform_handle_t PlatformHandle;
std::string Name;
std::string Platform;
ol_platform_backend_t Backend;
@@ -124,7 +125,7 @@ const std::vector<Device> &getDevices() {
auto Platform = getPlatformName(PlatformHandle);
static_cast<std::vector<Device> *>(Data)->push_back(
- {DeviceHandle, Name, Platform, Backend});
+ {DeviceHandle, PlatformHandle, Name, Platform, Backend});
}
return true;
@@ -175,6 +176,7 @@ DeviceContext::DeviceContext(std::size_t GlobalDeviceId)
llvm::Twine(Devices.size()));
DeviceHandle = Devices[GlobalDeviceId].Handle;
+ PlatformHandle = Devices[GlobalDeviceId].PlatformHandle;
}
DeviceContext::DeviceContext(llvm::StringRef Platform, std::size_t DeviceId)
@@ -210,6 +212,7 @@ DeviceContext::DeviceContext(llvm::StringRef Platform, std::size_t DeviceId)
GlobalDeviceId = *FoundGlobalDeviceId;
DeviceHandle = Devices[GlobalDeviceId].Handle;
+ PlatformHandle = Devices[GlobalDeviceId].PlatformHandle;
}
[[nodiscard]] llvm::Expected<std::shared_ptr<DeviceImage>>
@@ -286,29 +289,6 @@ DeviceContext::getKernelHandle(ol_program_handle_t ProgramHandle,
return Handle;
}
-llvm::Expected<ol_platform_handle_t>
-DeviceContext::getPlatformHandle() noexcept {
- if (!PlatformHandle) {
- const ol_result_t OlResult =
- olGetDeviceInfo(DeviceHandle, OL_DEVICE_INFO_PLATFORM,
- sizeof(PlatformHandle), &PlatformHandle);
-
- if (OlResult != OL_SUCCESS) {
- PlatformHandle = nullptr;
- llvm::StringRef Details =
- OlResult->Details ? OlResult->Details : "No details provided";
-
- // clang-format off
- return llvm::createStringError(
- llvm::Twine(Details) +
- " (code " + llvm::Twine(OlResult->Code) + ")");
- // clang-format on
- }
- }
-
- return PlatformHandle;
-}
-
void DeviceContext::launchKernelImpl(
ol_symbol_handle_t KernelHandle, uint32_t NumGroups, uint32_t GroupSize,
const void *KernelArgs, std::size_t KernelArgsSize) const noexcept {