From 76d8115dbb5f29932e4bbc6b1eeb5296bad32930 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Mon, 20 Apr 2020 13:14:53 -0500 Subject: [PATCH] adding GPU targets variable Change-Id: I46849cb7a8bf769379bc14be0f8dcb782ae65a37 --- cmake_modules/env.cmake | 66 ++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/cmake_modules/env.cmake b/cmake_modules/env.cmake index ec548ffc30..9e7b13d8ab 100644 --- a/cmake_modules/env.cmake +++ b/cmake_modules/env.cmake @@ -1,3 +1,25 @@ +################################################################################ +# Copyright (c) 2018 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. +################################################################################ + ## Build is not supported on Windows plaform if ( WIN32 ) message ( FATAL_ERROR "Windows build is not supported." ) @@ -67,15 +89,18 @@ if ( DEFINED ENV{CMAKE_LD_AQLPROFILE} ) add_definitions ( -DROCP_LD_AQLPROFILE=1 ) endif() -## Make env vars +## Build type if ( NOT DEFINED CMAKE_BUILD_TYPE OR "${CMAKE_BUILD_TYPE}" STREQUAL "" ) if ( DEFINED ENV{CMAKE_BUILD_TYPE} ) set ( CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE} ) endif() endif() + +## Installation prefix path if ( NOT DEFINED CMAKE_PREFIX_PATH AND DEFINED ENV{CMAKE_PREFIX_PATH} ) set ( CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH} ) endif() +set ( ENV{CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ) set ( HCC_HOME "/opt/rocm/hcc" ) set ( HIP_PATH "/opt/rocm/hip" ) @@ -111,31 +136,44 @@ endif () ## Find hsa-runtime headers/lib find_file ( HSA_RUNTIME_INC "hsa/hsa.h" ) find_library ( HSA_RUNTIME_LIB "libhsa-runtime${NBIT}.so" ) -get_filename_component ( HSA_RUNTIME_INC_PATH ${HSA_RUNTIME_INC} DIRECTORY ) -get_filename_component ( HSA_RUNTIME_LIB_PATH ${HSA_RUNTIME_LIB} DIRECTORY ) - -if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" ) - message ( WARNING "HSA headers not found" ) -else () - set ( HSA_RUNTIME_HSA_INC_PATH ${HSA_RUNTIME_INC_PATH}/.. ) -endif () +get_filename_component ( HSA_RUNTIME_INC_PATH "${HSA_RUNTIME_INC}" DIRECTORY ) +get_filename_component ( HSA_RUNTIME_LIB_PATH "${HSA_RUNTIME_LIB}" DIRECTORY ) find_library ( HSA_KMT_LIB "libhsakmt.so" ) -get_filename_component ( HSA_KMT_LIB_PATH ${HSA_KMT_LIB} DIRECTORY ) +get_filename_component ( HSA_KMT_LIB_PATH "${HSA_KMT_LIB}" DIRECTORY ) +get_filename_component ( ROCM_ROOT_DIR "${HSA_KMT_LIB_PATH}" DIRECTORY ) + set ( HSA_KMT_INC_PATH "${HSA_KMT_LIB_PATH}/../include" ) -set ( ROCM_INC_PATH ${HSA_KMT_INC_PATH} ) +set ( ROCM_INC_PATH "${HSA_KMT_INC_PATH}" ) ## Basic Tool Chain Information -message ( "----------------NBIT: ${NBIT}" ) -message ( "-----------BuildType: ${CMAKE_BUILD_TYPE}" ) +message ( "----------------NBit: ${NBIT}" ) +message ( "----------Build-Type: ${CMAKE_BUILD_TYPE}" ) message ( "------------Compiler: ${CMAKE_CXX_COMPILER}" ) message ( "----Compiler-Version: ${CMAKE_CXX_COMPILER_VERSION}" ) message ( "-----HSA-Runtime-Inc: ${HSA_RUNTIME_INC_PATH}" ) message ( "-HSA-Runtime-HSA-Inc: ${HSA_RUNTIME_HSA_INC_PATH}" ) message ( "-----HSA-Runtime-Lib: ${HSA_RUNTIME_LIB_PATH}" ) +message ( "----HSA_KMT_LIB_PATH: ${HSA_KMT_LIB_PATH}" ) +message ( "-------ROCM_ROOT_DIR: ${ROCM_ROOT_DIR}" ) +message ( "-------------KFD-Inc: ${HSA_KMT_INC_PATH}" ) message ( "-------------HCC-Inc: ${HCC_INC_DIR}" ) message ( "-------------HIP-Inc: ${HIP_INC_DIR}" ) -message ( "-------------KFD-Inc: ${HSA_KMT_INC_PATH}" ) message ( "-------------HIP-VDI: ${HIP_VDI}" ) message ( "-----CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}" ) message ( "---CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}" ) +message ( "---------GPU_TARGETS: ${GPU_TARGETS}" ) + +## Check the ROCm pathes +if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" ) + message ( FATAL_ERROR "HSA_RUNTIME_INC_PATH is not found." ) +endif () +if ( "${HSA_RUNTIME_LIB_PATH}" STREQUAL "" ) + message ( FATAL_ERROR "HSA_RUNTIME_LIB_PATH is not found." ) +endif () +if ( "${HSA_KMT_LIB_PATH}" STREQUAL "" ) + message ( FATAL_ERROR "HSA_KMT_LIB_PATH is not found." ) +endif () +if ( "${ROCM_ROOT_DIR}" STREQUAL "" ) + message ( FATAL_ERROR "ROCM_ROOT_DIR is not found." ) +endif ()