[SWDEV-431345][SWDEV-432633] toplevel cmake for hip samples

Change-Id: If22e7e96604f184458cc6ab6bb9945152f9359e0


[ROCm/hip-tests commit: 7481de706f]
Этот коммит содержится в:
Rahul Manocha
2023-11-13 19:12:54 +00:00
родитель 6259d20646
Коммит b821fdbfba
33 изменённых файлов: 461 добавлений и 89 удалений
+26
Просмотреть файл
@@ -0,0 +1,26 @@
# Copyright (c) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
add_custom_target(build_intro)
add_subdirectory(bit_extract)
add_subdirectory(module_api)
add_subdirectory(module_api_global)
add_subdirectory(square)
+10 -1
Просмотреть файл
@@ -47,9 +47,18 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(bit_extract bit_extract.cpp)
if(TARGET build_intro)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
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)
if(TARGET build_intro)
add_dependencies(build_intro bit_extract)
endif()
+14 -5
Просмотреть файл
@@ -41,15 +41,20 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(runKernel.hip.out runKernel.cpp)
add_executable(launchKernelHcc.hip.out launchKernelHcc.cpp)
add_executable(defaultDriver.hip.out defaultDriver.cpp)
if(TARGET build_intro)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(runKernel.hip.out ${EXCLUDE_OPTION} runKernel.cpp)
add_executable(launchKernelHcc.hip.out ${EXCLUDE_OPTION} launchKernelHcc.cpp)
add_executable(defaultDriver.hip.out ${EXCLUDE_OPTION} defaultDriver.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../vcpy_kernel.cpp -o vcpy_kernel.code
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ${CMAKE_CURRENT_SOURCE_DIR}/vcpy_kernel.cpp -o vcpy_kernel.code
COMMENT "codeobj generated"
)
@@ -61,3 +66,7 @@ add_dependencies(defaultDriver.hip.out codeobj)
target_link_libraries(runKernel.hip.out hip::host)
target_link_libraries(launchKernelHcc.hip.out hip::host)
target_link_libraries(defaultDriver.hip.out hip::host)
if(TARGET build_intro)
add_dependencies(build_intro runKernel.hip.out launchKernelHcc.hip.out defaultDriver.hip.out)
endif()
+16 -8
Просмотреть файл
@@ -39,19 +39,27 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(runKernel.hip.out runKernel.cpp)
if(TARGET build_intro)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(runKernel1.hip.out ${EXCLUDE_OPTION} runKernel.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../vcpy_kernel.cpp -o vcpy_kernel.code
COMMENT "codeobj generated"
codeobj1
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ${CMAKE_CURRENT_SOURCE_DIR}/vcpy_kernel.cpp -o vcpy_kernel.code
COMMENT "codeobj1 generated"
)
add_dependencies(runKernel.hip.out codeobj)
add_dependencies(runKernel1.hip.out codeobj1)
target_include_directories(runKernel.hip.out PRIVATE ../../common)
target_include_directories(runKernel1.hip.out PRIVATE ../../common)
# Link with HIP
target_link_libraries(runKernel.hip.out hip::host)
target_link_libraries(runKernel1.hip.out hip::host)
if(TARGET build_intro)
add_dependencies(build_intro runKernel1.hip.out)
endif()
+12 -2
Просмотреть файл
@@ -33,7 +33,8 @@ if(UNIX)
endif()
# create square.cpp
execute_process(COMMAND sh -c "${CMAKE_PREFIX_PATH}/bin/hipify-perl ../square.cu > ../square.cpp")
execute_process(COMMAND sh -c "${CMAKE_PREFIX_PATH}/bin/hipify-perl \
${CMAKE_CURRENT_SOURCE_DIR}/square.cu > ${CMAKE_CURRENT_BINARY_DIR}/square.cpp")
# Find hip
find_package(hip)
@@ -43,7 +44,16 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(square square.cpp)
if(TARGET build_intro)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(square ${EXCLUDE_OPTION} ${CMAKE_CURRENT_BINARY_DIR}/square.cpp)
# Link with HIP
target_link_libraries(square hip::host)
if(TARGET build_intro)
add_dependencies(build_intro square)
endif()
+22
Просмотреть файл
@@ -0,0 +1,22 @@
# Copyright (c) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
add_custom_target(build_utils)
add_subdirectory(hipDispatchLatency)
add_subdirectory(hipInfo)
+16 -8
Просмотреть файл
@@ -41,19 +41,23 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipDispatchLatency hipDispatchLatency.cpp)
add_executable(hipDispatchEnqueueRateMT hipDispatchEnqueueRateMT.cpp)
if(TARGET build_utils)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(hipDispatchLatency ${EXCLUDE_OPTION} hipDispatchLatency.cpp)
add_executable(hipDispatchEnqueueRateMT ${EXCLUDE_OPTION} hipDispatchEnqueueRateMT.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../test_kernel.cpp -o test_kernel.code
COMMENT "codeobj generated"
codeobj2
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ${CMAKE_CURRENT_SOURCE_DIR}/test_kernel.cpp -o test_kernel.code
COMMENT "codeobj2 generated"
)
add_dependencies(hipDispatchLatency codeobj)
add_dependencies(hipDispatchEnqueueRateMT codeobj)
add_dependencies(hipDispatchLatency codeobj2)
add_dependencies(hipDispatchEnqueueRateMT codeobj2)
# Link with HIP
target_link_libraries(hipDispatchLatency hip::host)
@@ -63,3 +67,7 @@ if(UNIX)
endif()
set_property(TARGET hipDispatchLatency PROPERTY CXX_STANDARD 11)
set_property(TARGET hipDispatchEnqueueRateMT PROPERTY CXX_STANDARD 11)
if(TARGET build_utils)
add_dependencies(build_utils hipDispatchLatency hipDispatchEnqueueRateMT)
endif()
+10 -1
Просмотреть файл
@@ -52,7 +52,12 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipInfo hipInfo.cpp)
if(TARGET build_utils)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(hipInfo ${EXCLUDE_OPTION} hipInfo.cpp)
# Link with HIP
target_link_libraries(hipInfo hip::host)
@@ -65,3 +70,7 @@ target_include_directories(hipInfo PRIVATE ../../common)
if (WIN32 AND HIPINFO_INTERNAL_BUILD)
install(FILES ${PROJECT_BINARY_DIR}/hipInfo.exe DESTINATION .)
endif()
if(TARGET build_utils)
add_dependencies(build_utils hipInfo)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(MatrixTranspose MatrixTranspose.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(MatrixTranspose ${EXCLUDE_OPTION} MatrixTranspose.cpp)
target_include_directories(MatrixTranspose PRIVATE ../../common)
# Link with HIP
target_link_libraries(MatrixTranspose hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook MatrixTranspose)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(inline_asm inline_asm.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(inline_asm ${EXCLUDE_OPTION} inline_asm.cpp)
target_include_directories(inline_asm PRIVATE ../../common)
# Link with HIP
target_link_libraries(inline_asm hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook inline_asm)
endif()
+14 -6
Просмотреть файл
@@ -39,19 +39,27 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(texture2dDrv texture2dDrv.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(texture2dDrv ${EXCLUDE_OPTION} texture2dDrv.cpp)
# Generate code object
add_custom_target(
codeobj
ALL
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ../tex2dKernel.cpp -o tex2dKernel.code
COMMENT "codeobj generated"
codeobj3
COMMAND ${HIP_HIPCC_EXECUTABLE} --genco ${CMAKE_CURRENT_SOURCE_DIR}/tex2dKernel.cpp -o tex2dKernel.code
COMMENT "codeobj3 generated"
)
add_dependencies(texture2dDrv codeobj)
add_dependencies(texture2dDrv codeobj3)
target_include_directories(texture2dDrv PRIVATE ../../common)
# Link with HIP
target_link_libraries(texture2dDrv hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook texture2dDrv)
endif()
+11 -2
Просмотреть файл
@@ -48,13 +48,18 @@ else()
endif()
set(MY_SOURCE_FILES MatrixTranspose.cpp)
set(MY_TARGET_NAME MatrixTranspose)
set(MY_TARGET_NAME MatrixTranspose1)
set(MY_HIPCC_OPTIONS)
set(MY_CLANG_OPTIONS)
set(MY_NVCC_OPTIONS)
set_source_files_properties(${MY_SOURCE_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_executable(${MY_TARGET_NAME} ${MY_SOURCE_FILES} HIPCC_OPTIONS ${MY_HIPCC_OPTIONS} CLANG_OPTIONS ${MY_CLANG_OPTIONS} NVCC_OPTIONS ${MY_NVCC_OPTIONS})
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
hip_add_executable(${MY_TARGET_NAME} ${EXCLUDE_OPTION} ${MY_SOURCE_FILES} HIPCC_OPTIONS ${MY_HIPCC_OPTIONS} CLANG_OPTIONS ${MY_CLANG_OPTIONS} NVCC_OPTIONS ${MY_NVCC_OPTIONS})
target_include_directories(${MY_TARGET_NAME} PRIVATE ../../common)
@@ -65,3 +70,7 @@ if(TARGET hip::host)
message(STATUS "Found hip::host at ${hip_DIR}")
target_link_libraries(${MY_TARGET_NAME} hip::host)
endif()
if(TARGET build_cookbook)
add_dependencies(build_cookbook ${MY_TARGET_NAME})
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(occupancy occupancy.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(occupancy ${EXCLUDE_OPTION} occupancy.cpp)
target_include_directories(occupancy PRIVATE ../../common)
# Link with HIP
target_link_libraries(occupancy hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook occupancy)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(gpuarch gpuarch.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(gpuarch ${EXCLUDE_OPTION} gpuarch.cpp)
target_include_directories(gpuarch PRIVATE ../../common)
# Link with HIP
target_link_libraries(gpuarch hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook gpuarch)
endif()
+14 -5
Просмотреть файл
@@ -27,33 +27,42 @@ set(CMAKE_BUILD_TYPE Release)
# Turn static library generation ON
option(BUILD_SHARED_LIBS "Build as a shared library" OFF)
set(CPP_SOURCES hipDevice.cpp)
set(CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hipDevice.cpp)
# For windows, We need to tell cmake how to create static library.
if (WIN32)
set (CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> /out:<TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
# Generate static lib libHipDevice.a
add_library(HipDevice STATIC ${CPP_SOURCES})
add_library(HipDevice ${EXCLUDE_OPTION} STATIC ${CPP_SOURCES})
target_compile_options(HipDevice PRIVATE -fgpu-rdc)
target_link_libraries(HipDevice PRIVATE -fgpu-rdc)
target_include_directories(HipDevice PRIVATE ${CMAKE_PREFIX_PATH}/hsa/include)
# Create test executable that uses libHipDevice.a
set(TEST_SOURCES ${CMAKE_SOURCE_DIR}/hipMain2.cpp)
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hipMain2.cpp)
add_executable(test_device_static ${TEST_SOURCES})
add_executable(test_device_static ${EXCLUDE_OPTION} ${TEST_SOURCES})
add_dependencies(test_device_static HipDevice)
target_compile_options(test_device_static PRIVATE -fgpu-rdc)
# For windows, Change in a way to pass lib details
if (WIN32)
target_link_libraries(test_device_static PRIVATE -lHipDevice -L${CMAKE_BINARY_DIR})
target_link_libraries(test_device_static PRIVATE -lHipDevice -L${CMAKE_CURRENT_BINARY_DIR})
else()
target_link_libraries(test_device_static PRIVATE HipDevice)
endif()
target_link_libraries(test_device_static PRIVATE -fgpu-rdc amdhip64 amd_comgr)
if(TARGET build_cookbook)
add_dependencies(build_cookbook HipDevice test_device_static)
endif()
+15 -6
Просмотреть файл
@@ -27,26 +27,32 @@ set(CMAKE_BUILD_TYPE Release)
# Turn static library generation ON
option(BUILD_SHARED_LIBS "Build as a shared library" OFF)
set(CPP_SOURCES hipOptLibrary.cpp)
set(CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hipOptLibrary.cpp)
# For windows, We need to tell cmake how to create static library.
if (WIN32)
set (CMAKE_CXX_CREATE_STATIC_LIBRARY "<CMAKE_AR> /out:<TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/hipMain1.cpp)
# Generate static lib libHipOptLibrary.a.
add_library(HipOptLibrary STATIC ${CPP_SOURCES})
add_library(HipOptLibrary ${EXCLUDE_OPTION} STATIC ${CPP_SOURCES})
# Set-up the correct flags to generate the static library.
target_link_options(HipOptLibrary PRIVATE --emit-static-lib)
target_include_directories(HipOptLibrary PRIVATE /opt/rocm/hsa/include)
# Create test executable that uses libHipOptLibrary.a
set(TEST_SOURCES ${CMAKE_SOURCE_DIR}/hipMain1.cpp)
add_executable(test_opt_static ${TEST_SOURCES})
add_executable(test_opt_static ${EXCLUDE_OPTION} ${TEST_SOURCES})
add_dependencies(test_opt_static HipOptLibrary)
target_link_libraries(test_opt_static PRIVATE -lHipOptLibrary -L${CMAKE_BINARY_DIR})
target_link_libraries(test_opt_static PRIVATE -lHipOptLibrary -L${CMAKE_CURRENT_BINARY_DIR})
if (WIN32)
target_link_libraries(test_opt_static PRIVATE amdhip64 amd_comgr)
@@ -54,3 +60,6 @@ else()
target_link_libraries(test_opt_static PRIVATE amdhip64 amd_comgr hsa-runtime64::hsa-runtime64)
endif()
if(TARGET build_cookbook)
add_dependencies(build_cookbook HipOptLibrary test_opt_static)
endif()
+13 -2
Просмотреть файл
@@ -32,13 +32,24 @@ if(UNIX)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
set(CMAKE_CXX_COMPILER "${ROCM_PATH}/llvm/bin/clang++")
# Find hip
find_package(hip REQUIRED)
# Create the excutable
add_executable(test_cpp square.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(test_cpp ${EXCLUDE_OPTION} square.cpp)
target_include_directories(test_cpp PRIVATE ../../common)
# Link with HIP
target_link_libraries(test_cpp hip::device)
target_link_libraries(test_cpp hip::device)
if(TARGET build_cookbook)
add_dependencies(build_cookbook test_cpp)
endif()
+15 -4
Просмотреть файл
@@ -12,14 +12,25 @@ if(UNIX)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
set(CMAKE_CXX_COMPILER "${ROCM_PATH}/llvm/bin/clang++")
find_package(hip REQUIRED)
add_executable(test_fortran TestFortran.F90)
add_executable(test_cpp MatrixTranspose.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(test_fortran ${EXCLUDE_OPTION} TestFortran.F90)
add_executable(test_cpp1 ${EXCLUDE_OPTION} MatrixTranspose.cpp)
target_link_libraries(test_cpp PUBLIC hip::device)
target_link_libraries(test_cpp1 PUBLIC hip::device)
target_include_directories(test_cpp PRIVATE ../../common)
target_include_directories(test_cpp1 PRIVATE ../../common)
# Assuming to build a C/C++-to-Fortran library binding.
target_link_libraries(test_fortran PUBLIC hip::device)
if(TARGET build_cookbook)
add_dependencies(build_cookbook test_cpp1 test_fortran)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(hipEvent hipEvent.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(hipEvent ${EXCLUDE_OPTION} hipEvent.cpp)
target_include_directories(hipEvent PRIVATE ../../common)
# Link with HIP
target_link_libraries(hipEvent hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook hipEvent)
endif()
+3 -2
Просмотреть файл
@@ -43,8 +43,6 @@ if (WIN32 AND HIPINFO_INTERNAL_BUILD)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${CMAKE_PREFIX_PATH}")
endif()
# Find hip
find_package(hip REQUIRED)
if (WIN32)
@@ -96,3 +94,6 @@ else (WIN32)
target_link_libraries(hipVulkan hip::host vulkan glfw)
endif (WIN32)
if(TARGET build_cookbook)
add_dependencies(build_cookbook hipVulkan)
endif()
+14 -3
Просмотреть файл
@@ -32,13 +32,24 @@ if(UNIX)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
set(CMAKE_CXX_COMPILER "${ROCM_PATH}/llvm/bin/clang++")
# Find HIP
find_package(hip REQUIRED)
# Create the excutable
add_executable(square square.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(square1 ${EXCLUDE_OPTION} square.cpp)
target_include_directories(square PRIVATE ../../common)
target_include_directories(square1 PRIVATE ../../common)
# Link with HIP
target_link_libraries(square hip::device)
target_link_libraries(square1 hip::device)
if(TARGET build_cookbook)
add_dependencies(build_cookbook square1)
endif()
+26 -3
Просмотреть файл
@@ -20,10 +20,33 @@
cmake_minimum_required(VERSION 3.21.3)
if(UNIX)
if(NOT DEFINED ROCM_PATH)
set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.")
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
endif()
if( NOT DEFINED CMAKE_HIP_COMPILER_ROCM)
set(CMAKE_HIP_COMPILER_ROCM_ROOT ${ROCM_PATH})
endif()
set(CMAKE_HIP_ARCHITECTURES OFF)
project(cmake_hip_lang_support VERSION 1.0
DESCRIPTION "HIP Language Support with upstream CMake"
LANGUAGES HIP)
# Create the executable
add_executable(square square.hip)
target_include_directories(square PRIVATE ../../common)
# Create the executable
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(square2 ${EXCLUDE_OPTION} square.hip)
target_include_directories(square2 PRIVATE ../../common)
if(TARGET build_cookbook)
add_dependencies(build_cookbook square2)
endif()
+12 -1
Просмотреть файл
@@ -30,13 +30,20 @@ if(UNIX)
list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH})
endif()
set(CMAKE_CXX_COMPILER "${ROCM_PATH}/llvm/bin/clang++")
# Find hiprtc
find_package(hiprtc REQUIRED)
# Find hip
find_package(hip REQUIRED)
# Create the excutable
add_executable(test saxpy.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(test ${EXCLUDE_OPTION} saxpy.cpp)
# Link with HIPRTC
target_link_libraries(test hiprtc::hiprtc)
@@ -44,3 +51,7 @@ target_link_libraries(test hiprtc::hiprtc)
target_link_libraries(test hip::device)
target_include_directories(test PRIVATE ../../common)
if(TARGET build_cookbook)
add_dependencies(build_cookbook test)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(sharedMemory sharedMemory.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(sharedMemory ${EXCLUDE_OPTION} sharedMemory.cpp)
target_include_directories(sharedMemory PRIVATE ../../common)
# Link with HIP
target_link_libraries(sharedMemory hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook sharedMemory)
endif()
+10 -1
Просмотреть файл
@@ -39,9 +39,18 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_BUILD_TYPE Release)
# Create the excutable
add_executable(shfl shfl.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(shfl ${EXCLUDE_OPTION} shfl.cpp)
target_include_directories(shfl PRIVATE ../../common)
# Link with HIP
target_link_libraries(shfl hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook shfl)
endif()
+10 -1
Просмотреть файл
@@ -38,9 +38,18 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(2dshfl 2dshfl.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(2dshfl ${EXCLUDE_OPTION} 2dshfl.cpp)
target_include_directories(2dshfl PRIVATE ../../common)
# Link with HIP
target_link_libraries(2dshfl hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook 2dshfl)
endif()
+10 -1
Просмотреть файл
@@ -40,9 +40,18 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(dynamic_shared dynamic_shared.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(dynamic_shared ${EXCLUDE_OPTION} dynamic_shared.cpp)
target_include_directories(dynamic_shared PRIVATE ../../common)
# Link with HIP
target_link_libraries(dynamic_shared hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook dynamic_shared)
endif()
+10 -1
Просмотреть файл
@@ -38,9 +38,18 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(stream stream.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(stream ${EXCLUDE_OPTION} stream.cpp)
target_include_directories(stream PRIVATE ../../common)
# Link with HIP
target_link_libraries(stream hip::host)
if(TARGET cookbook)
add_dependencies(build_cookbook stream)
endif()
+10 -1
Просмотреть файл
@@ -37,7 +37,16 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(peer2peer peer2peer.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(peer2peer ${EXCLUDE_OPTION} peer2peer.cpp)
# Link with HIP
target_link_libraries(peer2peer hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook peer2peer)
endif()
+10 -1
Просмотреть файл
@@ -38,9 +38,18 @@ set(CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE})
set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE})
# Create the excutable
add_executable(unroll unroll.cpp)
if(TARGET build_cookbook)
set(EXCLUDE_OPTION EXCLUDE_FROM_ALL)
else()
set(EXCLUDE_OPTION )
endif()
add_executable(unroll ${EXCLUDE_OPTION} unroll.cpp)
target_include_directories(unroll PRIVATE ../../common)
# Link with HIP
target_link_libraries(unroll hip::host)
if(TARGET build_cookbook)
add_dependencies(build_cookbook unroll)
endif()
+44
Просмотреть файл
@@ -0,0 +1,44 @@
# Copyright (c) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
add_custom_target(build_cookbook)
add_subdirectory(0_MatrixTranspose)
add_subdirectory(1_hipEvent)
add_subdirectory(3_shared_memory)
add_subdirectory(4_shfl)
add_subdirectory(5_2dshfl)
add_subdirectory(6_dynamic_shared)
add_subdirectory(7_streams)
add_subdirectory(8_peer2peer)
add_subdirectory(9_unroll)
add_subdirectory(10_inline_asm)
add_subdirectory(11_texture_driver)
add_subdirectory(12_cmake_hip_add_executable)
add_subdirectory(13_occupancy)
add_subdirectory(14_gpu_arch)
add_subdirectory(15_static_library/device_functions)
add_subdirectory(15_static_library/host_functions)
#add_subdirectory(16_assembly_to_executable)
#add_subdirectory(17_llvm_ir_to_executable)
add_subdirectory(18_cmake_hip_device)
add_subdirectory(19_cmake_lang)
#add_subdirectory(20_hip_vulkan)
add_subdirectory(21_cmake_hip_cxx_clang)
#add_subdirectory(22_cmake_hip_lang)
add_subdirectory(23_cmake_hiprtc)
+11
Просмотреть файл
@@ -75,6 +75,17 @@ endif()
#TODO add instructions to build samples at once
set(CMAKE_CXX_EXTENSIONS OFF)
add_custom_target(build_samples
COMMAND make build_intro build_utils build_cookbook
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
add_subdirectory(0_Intro )
add_subdirectory(1_Utils )
add_subdirectory(2_Cookbook)
# make package_samples to generate packages for samples
set(SAMPLES_SRC ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(packaging)
+23 -18
Просмотреть файл
@@ -1,37 +1,42 @@
Build procedure
The CMakeLists.txt at hip-tests/samples folder is currently used for packaging purpose.
We provide Makefile and CMakeLists.txt to build the samples seperately.
The CMakeLists.txt at hip-tests/samples folder can be used for building and packaging samples.
1.Makefile supports shared lib of hip-rocclr runtime and nvcc.
To build a sample, just type in sample folder,
make
2.CMakeLists.txt can support shared and static libs of hip-rocclr runtime.
CMakeLists.txt can support shared and static libs of hip-rocclr runtime.
The same steps can be followed for both.
To build a sample, run in the sample folder,
1. To build a specific sample (e.g. 0_Intro/bit_extract) run ..
cd samples/0_Intro/bit_extract
mkdir -p build && cd build
cmake ..
make all
2. To build all samples together run ..
cd hip-tests
mkdir -p build && cd build
rm -rf * (to clear up)
cmake ..
cmake ../samples
Then run,
make build_samples
make
In order to build specific samples (Intro, Utils or Cookbook) run ..
make build_intro
make build_utils
make build_cookbook
Note that if you want debug version, add "-DCMAKE_BUILD_TYPE=Debug" in cmake cmd.
3.To package samples and generate packages. From hip-tests/build
3. To package samples and generate packages. From hip-tests/build
cmake ../samples
make package_samples