Files
TheRock/rocm-libraries/projects/rocrand/benchmark/CMakeLists.txt
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

159 lines
5.9 KiB
CMake

# MIT License
#
# Copyright (c) 2022-2026 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.
# Get the current branch, or fall back to DETACHED
execute_process(
COMMAND ${GIT_EXECUTABLE} symbolic-ref -q --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE BRANCH_NAME
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(BRANCH_NAME STREQUAL "")
set(BRANCH_NAME "DETACHED")
endif()
# Get the short commit hash
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Register a benchmark target
function(add_benchmark benchmark_src)
get_filename_component(BENCHMARK_TARGET ${benchmark_src} NAME_WE)
add_executable(${BENCHMARK_TARGET} ${benchmark_src})
if(HIP_COMPILER STREQUAL "nvcc")
set_property(TARGET ${BENCHMARK_TARGET} PROPERTY CUDA_STANDARD 17)
set_source_files_properties(${benchmark_src} PROPERTIES LANGUAGE CUDA)
target_compile_options(${BENCHMARK_TARGET}
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda>
)
target_link_libraries(${BENCHMARK_TARGET} PRIVATE ${CUDA_curand_LIBRARY})
else()
target_link_libraries(${BENCHMARK_TARGET} PRIVATE rocrand hip::device)
endif()
target_include_directories(${BENCHMARK_TARGET} PRIVATE
"${PROJECT_SOURCE_DIR}/library/src"
"${PROJECT_SOURCE_DIR}/../../shared/primbench")
target_compile_definitions(${BENCHMARK_TARGET} PUBLIC BRANCH_NAME="${BRANCH_NAME}")
target_compile_definitions(${BENCHMARK_TARGET} PUBLIC COMMIT_HASH="${COMMIT_HASH}")
if(WIN32)
target_compile_definitions(${BENCHMARK_TARGET} PRIVATE PRIMBENCH_NO_MONITORING)
elseif(HIP_COMPILER STREQUAL "nvcc")
target_link_libraries(${BENCHMARK_TARGET} PRIVATE nvidia-ml)
else()
target_link_libraries(${BENCHMARK_TARGET} PRIVATE amd_smi)
endif()
set_target_properties(${BENCHMARK_TARGET}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/benchmark"
)
rocm_install(TARGETS ${BENCHMARK_TARGET} COMPONENT benchmarks)
if (WIN32 AND NOT DEFINED DLLS_COPIED_BENCHMARKS)
set(DLLS_COPIED_BENCHMARKS "YES")
set(DLLS_COPIED_BENCHMARKS ${DLLS_COPIED_BENCHMARKS} PARENT_SCOPE)
# for now adding in all .dll as dependency chain is not cmake based on win32
file( GLOB third_party_dlls
LIST_DIRECTORIES ON
CONFIGURE_DEPENDS
${HIP_DIR}/bin/*.dll
${CMAKE_SOURCE_DIR}/rtest.*
)
foreach( file_i ${third_party_dlls})
add_custom_command(
TARGET ${BENCHMARK_TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${file_i} ${PROJECT_BINARY_DIR}/benchmark
COMMENT "Synchronizing ${file_i} to benchmark output directory"
)
endforeach( file_i )
endif()
endfunction()
add_benchmark("benchmark_device_api.cpp")
add_benchmark("benchmark_host_api.cpp")
if(BUILD_BENCHMARK_TUNING)
if(HIP_COMPILER STREQUAL "nvcc")
message(FATAL_ERROR "Configuration tuning is currently supported for AMD GPUs only")
endif()
set(CMAKE_CXX_STANDARD 17)
add_executable(benchmark_rocrand_tuning
tuning_host_api.cpp
tuning/lfsr113.cpp
tuning/mrg31k3p.cpp
tuning/mrg32k3a.cpp
tuning/mt19937.cpp
tuning/mtgp32.cpp
tuning/philox.cpp
tuning/threefry2x32_20.cpp
tuning/threefry2x64_20.cpp
tuning/threefry4x32_20.cpp
tuning/threefry4x64_20.cpp
tuning/xorwow.cpp
)
target_link_libraries(benchmark_rocrand_tuning PRIVATE rocrand hip::device)
target_include_directories(benchmark_rocrand_tuning PRIVATE
"${CMAKE_BINARY_DIR}/benchmark"
"${PROJECT_SOURCE_DIR}/benchmark"
"${PROJECT_SOURCE_DIR}/library/src"
"${PROJECT_SOURCE_DIR}/../../shared/primbench")
set(BENCHMARK_TUNING_MIN_GRID_SIZE 32768 CACHE STRING
"Configurations with fewer total number of threads are omitted")
set(BENCHMARK_TUNING_THREAD_OPTIONS "64, 128, 256, 512, 1024" CACHE STRING
"Comma-separated list of benchmarked block sizes")
set(BENCHMARK_TUNING_BLOCK_OPTIONS "64, 128, 256, 512, 1024, 2048" CACHE STRING
"Comma-separated list of benchmarked grid sizes")
target_compile_definitions(benchmark_rocrand_tuning PRIVATE
BENCHMARK_TUNING_MIN_GRID_SIZE=${BENCHMARK_TUNING_MIN_GRID_SIZE}
BENCHMARK_TUNING_THREAD_OPTIONS=${BENCHMARK_TUNING_THREAD_OPTIONS}
BENCHMARK_TUNING_BLOCK_OPTIONS=${BENCHMARK_TUNING_BLOCK_OPTIONS}
)
target_compile_definitions(benchmark_rocrand_tuning PUBLIC BRANCH_NAME="${BRANCH_NAME}")
target_compile_definitions(benchmark_rocrand_tuning PUBLIC COMMIT_HASH="${COMMIT_HASH}")
if(WIN32)
target_compile_definitions(benchmark_rocrand_tuning PRIVATE PRIMBENCH_NO_MONITORING)
else()
target_link_libraries(benchmark_rocrand_tuning PRIVATE amd_smi)
endif()
if(NOT WIN32)
foreach(amdgpu_target ${AMDGPU_TARGETS})
target_compile_options(rocrand PRIVATE --offload-arch=${amdgpu_target})
endforeach()
endif()
endif()