SWDEV-561273 - hip samples on TheRock build using HIP LANGUAGE and hip-lang package. (#1794)

This commit is contained in:
Jaydeep
2026-01-29 13:45:58 +05:30
committed by GitHub
parent fa6f071751
commit 190d9a8e27
30 changed files with 740 additions and 430 deletions
@@ -18,9 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
project(bit_extract)
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.21)
if(NOT WIN32 AND NOT DEFINED __HIP_ENABLE_PCH)
set(__HIP_ENABLE_PCH ON CACHE BOOL "enable/disable pre-compiled hip headers")
@@ -40,14 +38,10 @@ if(UNIX)
endif()
# Search for rocm in common locations
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
# Find hip
find_package(hip)
# Set compiler and linker
set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
project(bit_extract LANGUAGES CXX HIP)
# Create the excutable
if(TARGET build_intro)
@@ -55,13 +49,22 @@ set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
# Mark source file as HIP code (contains __global__ kernels)
set_source_files_properties(bit_extract.cpp PROPERTIES LANGUAGE HIP)
add_executable(bit_extract ${EXCLUDE_OPTION} bit_extract.cpp)
target_include_directories(bit_extract PRIVATE ../../common)
# Link with HIP
target_link_libraries(bit_extract hip::host)
# Set RPATH so executable can find HIP libraries at runtime
if(UNIX)
set_target_properties(bit_extract PROPERTIES
BUILD_RPATH "${ROCM_PATH}/lib"
INSTALL_RPATH "${ROCM_PATH}/lib"
)
endif()
if(TARGET build_intro)
add_dependencies(build_intro bit_extract)
endif()
endif()