From 50dce67f334690dd7a5a525253c0d237e6844389 Mon Sep 17 00:00:00 2001 From: zjgarvey Date: Tue, 9 Jun 2026 12:22:53 -0700 Subject: [PATCH] test: libamdhip64 exports the extended HIP entry points GPU-free ABI-surface check: dlopen libamdhip64 under test and assert it exports the recent extended HIP entry points (hipDrvLaunchKernelEx@hip_6.5, hipGetFuncBySymbol, hipStreamBatchMemOp, hipMemGetHandleForAddressRange, hipMemcpyBatchAsync, and the external-memory trio). Presence only: the symbols are not called, since their argument contracts differ and on a real implementation invoking them generically would be undefined behavior. Co-Authored-By: Claude Opus 4.8 (1M context) Signed-off-by: zjgarvey --- tests/CMakeLists.txt | 5 +- tests/nightly_symbols/CMakeLists.txt | 9 ++++ .../nightly_symbols/nightly_symbols_test.cpp | 52 +++++++++++++++++++ 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 tests/nightly_symbols/CMakeLists.txt create mode 100644 tests/nightly_symbols/nightly_symbols_test.cpp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f632a71..1d89c5b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,4 +24,7 @@ add_subdirectory(kernel_smoke) add_subdirectory(multithread) # Graph API: -add_subdirectory(graph) \ No newline at end of file +add_subdirectory(graph) + +# Nightly ROCm bring-up regression tests: +add_subdirectory(nightly_symbols) \ No newline at end of file diff --git a/tests/nightly_symbols/CMakeLists.txt b/tests/nightly_symbols/CMakeLists.txt new file mode 100644 index 0000000..0c0f6c4 --- /dev/null +++ b/tests/nightly_symbols/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright 2026 The IREE Authors +# +# Licensed under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +add_hip_cts_test(nightly_symbols_test + SOURCES nightly_symbols_test.cpp +) diff --git a/tests/nightly_symbols/nightly_symbols_test.cpp b/tests/nightly_symbols/nightly_symbols_test.cpp new file mode 100644 index 0000000..aea43b7 --- /dev/null +++ b/tests/nightly_symbols/nightly_symbols_test.cpp @@ -0,0 +1,52 @@ +// Copyright 2026 The IREE Authors +// +// Licensed under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +// ABI-surface check: a libamdhip64 targeting the recent HIP ABI must export +// these extended entry points. They were added across HIP versions +// (hipDrvLaunchKernelEx is versioned @hip_6.5) and are absent from older +// builds, so a runtime or a downstream library linked against the newer +// symbols fails to load if any is missing. +// +// Presence only: the test does not call them. Their argument contracts differ +// and a real implementation would dereference the (here absent) arguments, so +// invoking them generically would be undefined behavior. This is GPU-free: it +// dlopens the library under test and resolves each symbol. + +#include + +#include +#include "hip_loader.hpp" + +namespace { +const char* const kExtendedSymbols[] = { + "hipDrvLaunchKernelEx", // versioned @hip_6.5 + "hipGetFuncBySymbol", + "hipStreamBatchMemOp", + "hipMemGetHandleForAddressRange", + "hipMemcpyBatchAsync", + "hipImportExternalMemory", + "hipExternalMemoryGetMappedBuffer", + "hipDestroyExternalMemory", +}; +} // namespace + +TEST_CASE("libamdhip64 exports the extended HIP entry points", + "[symbols][nightly]") { + // Re-open the same binary the loader resolved (RTLD_NOW forces every + // relocation). + const std::string& lib = HipLoader::instance().libraryPath(); + void* handle = dlopen(lib.c_str(), RTLD_NOW | RTLD_LOCAL); + REQUIRE(handle != nullptr); + + for (const char* name : kExtendedSymbols) { + INFO("symbol: " << name); + // A -fvisibility regression or a version script that re-hides these would + // fail here. + REQUIRE(dlsym(handle, name) != nullptr); + } + + dlclose(handle); +}