From 5575cc29ba526709a82f470f3343f27fde96124e Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Wed, 16 Sep 2020 16:19:34 +0530 Subject: [PATCH] Changes for compiling bandwidth test on rocm --- rocm/1_Utilities/bandwidthTest/CMakeLists.txt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/rocm/1_Utilities/bandwidthTest/CMakeLists.txt b/rocm/1_Utilities/bandwidthTest/CMakeLists.txt index 7ac9db8..2505fe8 100644 --- a/rocm/1_Utilities/bandwidthTest/CMakeLists.txt +++ b/rocm/1_Utilities/bandwidthTest/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.10) +list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm/ /opt/rocm/llvm ) + if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed") @@ -11,22 +13,35 @@ set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) project(bandwidthTest) -find_package(HIP QUIET) -if(HIP_FOUND) +find_package(HIP) +#since we are giving away with hip_add_executable & trying standard way of add_executable, we shall look for normal hip.cofig & hipTraget +find_package(hip) +if(hip_FOUND) message(STATUS "Found HIP: " ${HIP_VERSION}) else() message(FATAL_ERROR "Could not find HIP. Ensure that HIP is either installed in /opt/rocm/hip or the variable HIP_PATH is set to point to the right location.") endif() + +#Specifying clearly that we should be using hipcc for compilaint & not the /usr/bin/c++ +set(CXX "/opt/rocm/bin/hipcc") + set(TEST_SOURCE_FILES bandwidthTest.cpp) set(TEST_TARGET_NAME bandwidthTest) + set(CMAKE_INCLUDE_PATH ../../Common/) set(COMMON_DIRECTORY ../../Common/) + set_source_files_properties(${TEST_SOURCE_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1) -hip_add_executable(${TEST_TARGET_NAME} ${TEST_SOURCE_FILES}) +add_executable(${TEST_TARGET_NAME} ${TEST_SOURCE_FILES}) + +#Telling the compiler that this code has CPP14 directives so use that +target_compile_options(${TEST_TARGET_NAME} PUBLIC -std=c++14) +target_include_directories( ${TEST_TARGET_NAME} PUBLIC $ ) +#Finally just link with hip::device & pull up all the dependecies from hipTargerXXX.cmake +target_link_libraries(${TEST_TARGET_NAME} hip::device ) -target_include_directories( ${TEST_TARGET_NAME} PUBLIC $)