Commit 848d7edb authored by Ashutosh Mishra's avatar Ashutosh Mishra
Browse files

Failsafe find_package(hsa

In case old has is being used & find package is not working
We fall back to old method of descorving the libraries
and headers to make this RBT compile and make package
parent 96295afe
...@@ -109,12 +109,8 @@ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86") ...@@ -109,12 +109,8 @@ elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif() endif()
find_package(hsa-runtime64 REQUIRED
PATHS /opt/rocm
)
message( " hsa-runtime64 found @ ${hsa-runtime64_DIR} " )
# Set project requirements # Set project requirements
set(ROC_THUNK_NAME "hsakmt")
set(CORE_RUNTIME_NAME "hsa-runtime") set(CORE_RUNTIME_NAME "hsa-runtime")
set(CORE_RUNTIME_TARGET "${CORE_RUNTIME_NAME}64") set(CORE_RUNTIME_TARGET "${CORE_RUNTIME_NAME}64")
...@@ -125,6 +121,23 @@ if(NOT DEFINED CMAKE_MODULE_PATH) ...@@ -125,6 +121,23 @@ if(NOT DEFINED CMAKE_MODULE_PATH)
endif() endif()
include(utils) include(utils)
#making find_package(has-runtime64 Optional as it can fail when building old hsa
#When find_package fails, then using old method of find_libraries for
#searching the required libs for building RBT
find_package(hsa-runtime64
PATHS /opt/rocm )
if(${hsa-runtime64_FOUND})
message( " hsa-runtime64 found @ ${hsa-runtime64_DIR} " )
else()
message(" hsa-runtime64 NOT found Resolving to OLD Way" )
find_path(ROCR_HDR hsa.h PATHS "/opt/rocm" PATH_SUFFIXES include/hsa REQUIRED )
INCLUDE_DIRECTORIES(${ROCR_HDR})
# Search for ROCr library file
find_library(ROCR_LIB ${CORE_RUNTIME_TARGET} PATHS "/opt/rocm" PATH_SUFFIXES lib lib64 REQUIRED)
# Search for ROCt library file
find_library(ROCT_LIB ${ROC_THUNK_NAME} PATHS "/opt/rocm" PATH_SUFFIXES lib lib64 REQUIRED)
endif()
# #
# Set the package version for the test. It is critical that this # Set the package version for the test. It is critical that this
# value track what is used in the test source. The code from utils # value track what is used in the test source. The code from utils
...@@ -152,7 +165,11 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Src) ...@@ -152,7 +165,11 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} Src)
# Build and link the test program # Build and link the test program
add_executable(${TEST_NAME} ${Src}) add_executable(${TEST_NAME} ${Src})
target_link_libraries(${TEST_NAME} PRIVATE hsa-runtime64::hsa-runtime64) if(${hsa-runtime64_FOUND})
target_link_libraries(${TEST_NAME} PRIVATE hsa-runtime64::hsa-runtime64)
else()
target_link_libraries(${TEST_NAME} PRIVATE ${ROCR_LIB} ${ROCT_LIB} )
endif()
target_link_libraries(${TEST_NAME} PRIVATE c stdc++ dl pthread rt) target_link_libraries(${TEST_NAME} PRIVATE c stdc++ dl pthread rt)
# Update linker flags to include RPATH # Update linker flags to include RPATH
......
...@@ -31,16 +31,23 @@ The following simply lists the steps to build RocBandwidthTest ...@@ -31,16 +31,23 @@ The following simply lists the steps to build RocBandwidthTest
The argument for cmake should be the root folder of RocBandwidthTest The argument for cmake should be the root folder of RocBandwidthTest
test suite test suite
// Assume that Roc Runtime has its libraries & headers are located in the path :
// libraries : _ABSOLUTE_PATH_TO_ROCR_LIBS_/lib
// headers : _ABSOLUTE_PATH_TO_ROCR_LIBS_/include/hsa
// Note : Observe that both include & lib folder are under common path (_ABSOLUTE_PATH_TO_ROCR_LIBS_)
// Builds Debug version // Builds Debug version
// Assumes pwd is .../roc_bandwidth_test/build // Assumes pwd is _ABSOLUTE_PATH_TO_RBT/roc_bandwidth_test/build
e.g. cmake -DROCR_LIB_DIR="Path of ROC Runtime Library Files" \
-DROCR_INC_DIR="Path of ROC Runtime Header Files" \ e.g. cmake -DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_BUILD_TYPE:STRING=Debug .. -DCMAKE_MODULE_PATH="_ABSOLUTE_PATH_TO_RBT/roc_bandwidth_test/cmake_modules" \
-DCMAKE_PREFIX_PATH="_ABSOLUTE_PATH_TO_ROCR_LIBS_"
..
// Builds Release version - default // Builds Release version - default
// Assumes pwd is .../roc_bandwidth_test/build // Assumes pwd is _ABSOLUTE_PATH_TO_RBT/roc_bandwidth_test/build
e.g. cmake -DROCR_LIB_DIR="Path of ROC Runtime Library Files" \ e.g. cmake -DCMAKE_MODULE_PATH="_ABSOLUTE_PATH_TO_RBT/roc_bandwidth_test/cmake_modules" \
-DROCR_INC_DIR="Path of ROC Runtime Header Files" \ -DCMAKE_PREFIX_PATH="_ABSOLUTE_PATH_TO_ROCR_LIBS_"
.. ..
--- Invoke the native build rules generated by cmake to build the various --- Invoke the native build rules generated by cmake to build the various
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment