From b821fdbfbad080a6a5f2f5ae38111b08f89d7c4e Mon Sep 17 00:00:00 2001 From: Rahul Manocha Date: Mon, 13 Nov 2023 19:12:54 +0000 Subject: [PATCH] [SWDEV-431345][SWDEV-432633] toplevel cmake for hip samples Change-Id: If22e7e96604f184458cc6ab6bb9945152f9359e0 [ROCm/hip-tests commit: 7481de706fd675000975ac51a09acfde416e41f4] --- .../hip-tests/samples/0_Intro/CMakeLists.txt | 26 +++++++++++ .../0_Intro/bit_extract/CMakeLists.txt | 11 ++++- .../samples/0_Intro/module_api/CMakeLists.txt | 19 +++++--- .../0_Intro/module_api_global/CMakeLists.txt | 24 ++++++---- .../samples/0_Intro/square/CMakeLists.txt | 14 +++++- .../hip-tests/samples/1_Utils/CMakeLists.txt | 22 ++++++++++ .../1_Utils/hipDispatchLatency/CMakeLists.txt | 24 ++++++---- .../samples/1_Utils/hipInfo/CMakeLists.txt | 11 ++++- .../0_MatrixTranspose/CMakeLists.txt | 11 ++++- .../2_Cookbook/10_inline_asm/CMakeLists.txt | 11 ++++- .../11_texture_driver/CMakeLists.txt | 20 ++++++--- .../CMakeLists.txt | 13 +++++- .../2_Cookbook/13_occupancy/CMakeLists.txt | 11 ++++- .../2_Cookbook/14_gpu_arch/CMakeLists.txt | 11 ++++- .../device_functions/CMakeLists.txt | 19 +++++--- .../host_functions/CMakeLists.txt | 21 ++++++--- .../18_cmake_hip_device/CMakeLists.txt | 15 ++++++- .../2_Cookbook/19_cmake_lang/CMakeLists.txt | 19 ++++++-- .../2_Cookbook/1_hipEvent/CMakeLists.txt | 11 ++++- .../2_Cookbook/20_hip_vulkan/CMakeLists.txt | 5 ++- .../21_cmake_hip_cxx_clang/CMakeLists.txt | 17 +++++-- .../22_cmake_hip_lang/CMakeLists.txt | 29 ++++++++++-- .../2_Cookbook/23_cmake_hiprtc/CMakeLists.txt | 13 +++++- .../2_Cookbook/3_shared_memory/CMakeLists.txt | 11 ++++- .../samples/2_Cookbook/4_shfl/CMakeLists.txt | 11 ++++- .../2_Cookbook/5_2dshfl/CMakeLists.txt | 11 ++++- .../6_dynamic_shared/CMakeLists.txt | 11 ++++- .../2_Cookbook/7_streams/CMakeLists.txt | 11 ++++- .../2_Cookbook/8_peer2peer/CMakeLists.txt | 11 ++++- .../2_Cookbook/9_unroll/CMakeLists.txt | 11 ++++- .../samples/2_Cookbook/CMakeLists.txt | 44 +++++++++++++++++++ projects/hip-tests/samples/CMakeLists.txt | 11 +++++ projects/hip-tests/samples/README.md | 41 +++++++++-------- 33 files changed, 461 insertions(+), 89 deletions(-) create mode 100644 projects/hip-tests/samples/0_Intro/CMakeLists.txt create mode 100644 projects/hip-tests/samples/1_Utils/CMakeLists.txt create mode 100644 projects/hip-tests/samples/2_Cookbook/CMakeLists.txt diff --git a/projects/hip-tests/samples/0_Intro/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/CMakeLists.txt new file mode 100644 index 0000000000..6704c1b5c1 --- /dev/null +++ b/projects/hip-tests/samples/0_Intro/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt index de13dfdd07..602b43297d 100644 --- a/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt index 75f1cfa01a..be1855f521 100644 --- a/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt index 3d4fc31413..4f9cc60b8d 100644 --- a/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt index 5cc2edbd7b..71d01e41c0 100644 --- a/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/1_Utils/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/CMakeLists.txt new file mode 100644 index 0000000000..714316ed95 --- /dev/null +++ b/projects/hip-tests/samples/1_Utils/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt index a077044e26..2019ceeac6 100644 --- a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt index 368b5da0e8..301649761d 100644 --- a/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt index 6970f457c3..6b5e4a24bd 100644 --- a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt index 1b17cdf470..0736bacf0d 100644 --- a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt index 68b9531139..83d87a184f 100644 --- a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt index 2cfbed261f..b7114d5853 100644 --- a/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt index 8b98de9e7e..041f4e2663 100644 --- a/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt index 4e794a1dd1..c22bd63e37 100644 --- a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt index 26ea3792cb..fc88defbb2 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt @@ -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 " /out: ") 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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt index 9364c7243d..23501f6ddf 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt @@ -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 " /out: ") 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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt index a1167548d7..2bf28bef37 100644 --- a/projects/hip-tests/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt @@ -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) \ No newline at end of file +target_link_libraries(test_cpp hip::device) + +if(TARGET build_cookbook) +add_dependencies(build_cookbook test_cpp) +endif() diff --git a/projects/hip-tests/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt index b1aea067e7..f6cfc93c3b 100644 --- a/projects/hip-tests/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt index 0fcd276e09..71837e05df 100644 --- a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt index fb0bfdb130..2063dda0ed 100644 --- a/projects/hip-tests/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt index 640c889b7b..79a8154c02 100644 --- a/projects/hip-tests/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/22_cmake_hip_lang/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/22_cmake_hip_lang/CMakeLists.txt index 3d047e88a3..93af7e2e5f 100644 --- a/projects/hip-tests/samples/2_Cookbook/22_cmake_hip_lang/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/22_cmake_hip_lang/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt index b89c55c95d..389c1bb6e9 100644 --- a/projects/hip-tests/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt index d4fd0ab4d9..f0edececb0 100644 --- a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt index 6ccfdbe49b..39688104f2 100644 --- a/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt index 741bd6628b..5a2be43d0e 100644 --- a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt index d0997d6b73..0431adacef 100644 --- a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt index 658a386184..9525fecf93 100644 --- a/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt index 14de32dd60..9f4e4225f0 100644 --- a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt index 6770496a84..be6b1e5644 100644 --- a/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt @@ -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() diff --git a/projects/hip-tests/samples/2_Cookbook/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/CMakeLists.txt new file mode 100644 index 0000000000..2a0983de8a --- /dev/null +++ b/projects/hip-tests/samples/2_Cookbook/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/projects/hip-tests/samples/CMakeLists.txt b/projects/hip-tests/samples/CMakeLists.txt index e20a167b7f..3ec12d121a 100644 --- a/projects/hip-tests/samples/CMakeLists.txt +++ b/projects/hip-tests/samples/CMakeLists.txt @@ -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) diff --git a/projects/hip-tests/samples/README.md b/projects/hip-tests/samples/README.md index 24bedafa18..bb7e8d29be 100644 --- a/projects/hip-tests/samples/README.md +++ b/projects/hip-tests/samples/README.md @@ -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 -