1+ # Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+ # See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+ # All rights not expressly granted are reserved.
4+ #
5+ # This software is distributed under the terms of the GNU General Public
6+ # License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+ #
8+ # In applying this license CERN does not waive the privileges and immunities
9+ # granted to it by virtue of its status as an Intergovernmental Organization
10+ # or submit itself to any jurisdiction.
11+
12+ message (STATUS "Building GPU HIP benchmark" )
13+ # Hipify-perl to generate HIP sources
14+ set (HIPIFY_EXECUTABLE "/opt/rocm/bin/hipify-perl" )
15+ file (GLOB CUDA_SOURCES_FULL_PATH "../cuda/*.cu" )
16+ foreach (file ${CUDA_SOURCES_FULL_PATH} )
17+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${file} )
18+ get_filename_component (CUDA_SOURCE ${file} NAME )
19+ string (REPLACE ".cu" "" CUDA_SOURCE_NAME ${CUDA_SOURCE} )
20+ add_custom_command (
21+ OUTPUT ${CMAKE_CURRENT_SOURCE_DIR } /${CUDA_SOURCE_NAME}.hip.cxx
22+ COMMAND ${HIPIFY_EXECUTABLE} --quiet-warnings ${CMAKE_CURRENT_SOURCE_DIR } /../cuda/${CUDA_SOURCE} | sed '1{/ \#include \"hip\\/hip_runtime.h\"/d}' > ${CMAKE_CURRENT_SOURCE_DIR}/${CUDA_SOURCE_NAME}.hip.cxx
23+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR } /../cuda/${CUDA_SOURCE}
24+ )
25+ endforeach ()
26+
27+ set (CMAKE_CXX_COMPILER ${HIP_HIPCC_EXECUTABLE} )
28+ set (CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE} )
29+ set (CMAKE_CXX_EXTENSIONS OFF )
30+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS } ${O2_HIP_CMAKE_CXX_FLAGS} -fgpu-rdc" )
31+ o2_add_executable (gpu-memory-benchmark-hip
32+ SOURCES benchmark.hip.cxx
33+ Kernels.hip.cxx
34+ PUBLIC_LINK_LIBRARIES hip::host
35+ Boost::program_options
36+ ROOT::Tree
37+ TARGETVARNAME targetName )
38+ if (HIP_AMDGPUTARGET)
39+ # Need to add gpu target also to link flags due to gpu-rdc option
40+ target_link_options (${targetName} PUBLIC --amdgpu-target=${HIP_AMDGPUTARGET} )
41+ endif ()
0 commit comments