rocrtst: Updated CMakeFiles to find_package instead of hardcoded (#2095)
* rocrtst: Updated CMakeFiles to find_package instead of hardcoded This is to support TheROCK build environment * rocrtst: Fix CMake to use find_package() instead of hardcoded ENV paths Fixed CMake style issues from previos first commit's code review * rocrtst: Fix rocrtst NUMA dependency detection to use find_package Also added handling of missing headers * rocrtst: Fix NUMA and hwloc detection for cross-platform builds --------- Co-authored-by: Shweta Khatri <shweta.khatri@amd.com>
This commit is contained in:
@@ -115,19 +115,66 @@ else()
|
||||
set(ISDEBUG 1)
|
||||
endif()
|
||||
|
||||
find_path(BITCODE_DIR NAMES "opencl.bc" "opencl.amdgcn.bc"
|
||||
PATHS
|
||||
"${ROCM_DIR}/amdgcn/bitcode"
|
||||
"${ROCM_DIR}/lib/bitcode"
|
||||
"${ROCM_DIR}/lib"
|
||||
"${ROCM_DIR}/lib/x86_64/bitcode"
|
||||
"${OPENCL_DIR}/amdgcn/bitcode"
|
||||
"${OPENCL_DIR}/lib/x86_64/bitcode"
|
||||
"${LLVM_DIR}/../lib/bitcode"
|
||||
"${CMAKE_PREFIX_PATH}/amdgcn/bitcode"
|
||||
"${CMAKE_PREFIX_PATH}/lib/bitcode"
|
||||
"${CMAKE_PREFIX_PATH}/lib/x86_64/bitcode")
|
||||
# Find AMD Device Libraries (bitcode files) using find_package or manual search
|
||||
find_package(AMDDeviceLibs QUIET CONFIG)
|
||||
|
||||
if(AMDDeviceLibs_FOUND)
|
||||
# Use the package-provided location
|
||||
message(STATUS "Found AMDDeviceLibs via CONFIG")
|
||||
# Try to get the bitcode directory from any target
|
||||
if(TARGET AMDDeviceLibs::oclc_isa_version_803)
|
||||
get_target_property(DEVICE_LIBS_LOCATION AMDDeviceLibs::oclc_isa_version_803 IMPORTED_LOCATION)
|
||||
get_filename_component(BITCODE_DIR "${DEVICE_LIBS_LOCATION}" DIRECTORY)
|
||||
elseif(TARGET AMDDeviceLibs::oclc_isa_version_900)
|
||||
get_target_property(DEVICE_LIBS_LOCATION AMDDeviceLibs::oclc_isa_version_900 IMPORTED_LOCATION)
|
||||
get_filename_component(BITCODE_DIR "${DEVICE_LIBS_LOCATION}" DIRECTORY)
|
||||
else()
|
||||
# Fallback to manual search even if package was found
|
||||
set(AMDDeviceLibs_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT AMDDeviceLibs_FOUND)
|
||||
# Fallback: search relative to LLVM installation
|
||||
message(STATUS "Searching for AMD Device Libraries manually...")
|
||||
# First try to find LLVM if not already found
|
||||
if(NOT DEFINED LLVM_LIBRARY_DIR)
|
||||
find_package(LLVM QUIET CONFIG)
|
||||
if(LLVM_FOUND)
|
||||
message(STATUS "Found LLVM: ${LLVM_PACKAGE_VERSION}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_path(BITCODE_DIR
|
||||
NAMES "opencl.bc" "opencl.amdgcn.bc" "oclc_isa_version_803.bc"
|
||||
HINTS
|
||||
"${LLVM_LIBRARY_DIR}/amdgcn/bitcode"
|
||||
"${LLVM_LIBRARY_DIR}/../amdgcn/bitcode"
|
||||
"${CMAKE_INSTALL_PREFIX}/amdgcn/bitcode"
|
||||
"${CMAKE_INSTALL_PREFIX}/lib/amdgcn/bitcode"
|
||||
"${CMAKE_PREFIX_PATH}/amdgcn/bitcode"
|
||||
"${CMAKE_PREFIX_PATH}/lib/amdgcn/bitcode"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
if(NOT BITCODE_DIR)
|
||||
message(FATAL_ERROR
|
||||
"AMD Device Libraries (bitcode) not found!\n"
|
||||
"Searched locations:\n"
|
||||
" ${LLVM_LIBRARY_DIR}/amdgcn/bitcode\n"
|
||||
" ${LLVM_LIBRARY_DIR}/../amdgcn/bitcode\n"
|
||||
" ${CMAKE_INSTALL_PREFIX}/amdgcn/bitcode\n"
|
||||
" ${CMAKE_INSTALL_PREFIX}/lib/amdgcn/bitcode\n"
|
||||
"Please ensure device-libs are built and installed.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "Samples - Found Device Libraries: ${BITCODE_DIR}")
|
||||
|
||||
# Validate bitcode files exist
|
||||
if(NOT EXISTS "${BITCODE_DIR}")
|
||||
message(FATAL_ERROR "BITCODE_DIR does not exist: ${BITCODE_DIR}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Print out the build configuration being used:
|
||||
|
||||
Reference in New Issue
Block a user