Files
rocm-systems/projects/rocprofiler/cmake_modules/env.cmake
T

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