Files
rocm-systems/cmake_modules/env.cmake
T

80 lines
3.4 KiB
CMake
Raw Normal View History

2018-06-25 19:22:36 -05:00
################################################################################
2018-08-19 04:11:04 -05:00
# 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.
2018-06-25 19:22:36 -05:00
################################################################################
2017-11-09 17:26:19 -06:00
## Linux Compiler options
2023-02-03 12:31:39 -06:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
2017-11-09 17:26:19 -06:00
2019-05-31 20:20:28 -05:00
add_definitions ( -DNEW_TRACE_API=1 )
2017-11-09 17:26:19 -06:00
## CLANG options
2023-02-03 12:31:39 -06:00
if("$ENV{CXX}" STREQUAL "/usr/bin/clang++")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=1000000")
2017-11-09 17:26:19 -06:00
endif()
## Enable debug trace
if ( DEFINED ENV{CMAKE_DEBUG_TRACE} )
add_definitions ( -DDEBUG_TRACE=1 )
endif()
2018-06-26 16:05:39 -05:00
## Enable AQL-profile new API
if ( NOT DEFINED ENV{CMAKE_CURR_API} )
add_definitions ( -DAQLPROF_NEW_API=1 )
endif()
2018-01-04 20:11:30 -06:00
## Enable direct loading of AQL-profile HSA extension
if ( DEFINED ENV{CMAKE_LD_AQLPROFILE} )
add_definitions ( -DROCP_LD_AQLPROFILE=1 )
endif()
## Find hsa-runtime
2023-03-03 02:22:38 +00:00
find_package(hsa-runtime64 CONFIG REQUIRED HINTS ${CMAKE_PREFIX_PATH} PATHS /opt/rocm PATH_SUFFIXES lib/cmake/hsa-runtime64 )
2017-11-09 17:26:19 -06:00
# find KFD thunk
2023-03-03 02:22:38 +00:00
find_package(hsakmt CONFIG REQUIRED HINTS ${CMAKE_PREFIX_PATH} PATHS /opt/rocm PATH_SUFFIXES lib/cmake/hsakmt )
## Find ROCm
## TODO: Need a better method to find the ROCm path
2023-03-03 02:22:38 +00:00
find_path ( HSA_KMT_INC_PATH "hsakmt/hsakmt.h" HINTS ${CMAKE_PREFIX_PATH} PATHS /opt/rocm PATH_SUFFIXES include )
if ( "${HSA_KMT_INC_PATH}" STREQUAL "" )
get_target_property(HSA_KMT_INC_PATH hsakmt::hsakmt INTERFACE_INCLUDE_DIRECTORIES)
2021-04-27 12:14:17 -04:00
endif()
## Include path: /opt/rocm-ver/include. Go up one level to get ROCm path
get_filename_component ( ROCM_ROOT_DIR "${HSA_KMT_INC_PATH}" DIRECTORY )
2017-11-09 17:26:19 -06:00
## Basic Tool Chain Information
2018-08-20 02:51:26 -05:00
message ( "----------Build-Type: ${CMAKE_BUILD_TYPE}" )
2017-11-09 17:26:19 -06:00
message ( "------------Compiler: ${CMAKE_CXX_COMPILER}" )
message ( "----Compiler-Version: ${CMAKE_CXX_COMPILER_VERSION}" )
2020-03-19 01:27:06 -05:00
message ( "-------ROCM_ROOT_DIR: ${ROCM_ROOT_DIR}" )
2020-04-21 00:24:11 -05:00
message ( "-----CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}" )
2017-11-09 17:26:19 -06:00
message ( "---CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}" )
2020-03-19 01:27:06 -05:00
message ( "---------GPU_TARGETS: ${GPU_TARGETS}" )
if ( "${ROCM_ROOT_DIR}" STREQUAL "" )
message ( FATAL_ERROR "ROCM_ROOT_DIR is not found." )
endif ()
2023-06-13 15:09:11 +00:00
find_library(FIND_AQL_PROFILE_LIB "libhsa-amd-aqlprofile64.so" HINTS ${CMAKE_PREFIX_PATH} PATHS ${ROCM_ROOT_DIR} PATH_SUFFIXES lib REQUIRED)
if(NOT FIND_AQL_PROFILE_LIB)
message("AQL_PROFILE not installed. Please install AQL_PROFILE")
endif()