0c91ef919d
Move rocm_smi related function to rocm_smi folder. Move amd_smi to top level include/ and src/ folder. Remove obsolte oam folder. Change the CMakeLists.txt to update folder locations. Change-Id: I52e6be739e49f3b0545865f25364787f5985e9c3
237 lines
6.1 KiB
CMake
237 lines
6.1 KiB
CMake
#
|
|
# Minimum version of cmake required
|
|
#
|
|
cmake_minimum_required(VERSION 2.8.0)
|
|
|
|
#
|
|
# Required Defines on cmake command line
|
|
#
|
|
# 1) Set location of AMDSMI header files
|
|
#
|
|
# ROCM_DIR="Root for ROCM install"
|
|
#
|
|
# 2) Set AMDSMITST_BLD_TYPE to either "Debug" or "Release".
|
|
# If not set, the default value is "Debug" is bound.
|
|
#
|
|
# AMDSMITST_BLD_TYPE=Debug or AMDSMITST_BLD_TYPE=Release
|
|
#
|
|
# 3) Set AMDSMITST_BLD_BITS to either "32" or "64"
|
|
# If not set, the default value of "64" is bound.
|
|
#
|
|
# AMDSMITST_BLD_BITS=32 or AMDSMITST_BLD_BITS=64
|
|
#
|
|
# Building rocrtst Suite
|
|
#
|
|
#
|
|
# 1) Create build folder e.g. "rocrtst/build" - any name will do
|
|
# 2) Cd into build folder
|
|
# 3) Run "cmake .."
|
|
# 4) Run "make"
|
|
#
|
|
|
|
#
|
|
# Currently support for Windows platform is not present
|
|
#
|
|
|
|
#############################
|
|
# COMMON AREA
|
|
#############################
|
|
if(WIN32)
|
|
message("amdsmi library test suite is not supported on Windows platform")
|
|
return()
|
|
endif()
|
|
|
|
#
|
|
# Process input variables
|
|
#
|
|
|
|
# Required Defines first:
|
|
|
|
if(NOT DEFINED AMDSMI_INC_DIR)
|
|
set(AMDSMI_INC_DIR ${ROCM_DIR}/include)
|
|
endif()
|
|
|
|
if(NOT DEFINED AMDSMI_LIB_DIR)
|
|
set(AMDSMI_LIB_DIR ${ROCM_DIR}/lib)
|
|
endif()
|
|
#
|
|
# Determine AMDSMI Header files are present
|
|
# (no external source dependencies)
|
|
|
|
# Determine AMDSMI Library file is present
|
|
#
|
|
if("${AMDSMITST_BLD_BITS}" STREQUAL 32)
|
|
set (ONLY64STR "")
|
|
set (IS64BIT 0)
|
|
else()
|
|
set (ONLY64STR "64")
|
|
set (IS64BIT 1)
|
|
endif()
|
|
#
|
|
if (${IS64BIT} EQUAL 0)
|
|
if(NOT EXISTS ${AMDSMI_LIB_DIR}/libamd_smi32.so)
|
|
message("ERROR: ${AMDSMI_LIB_DIR}/libamd_smi32.so doesn't exist. Check value of ROCM_DIR define")
|
|
return()
|
|
endif()
|
|
else()
|
|
if(NOT EXISTS ${AMDSMI_LIB_DIR}/libamd_smi64.so)
|
|
message("ERROR: Define AMDSMI_LIB_DIR pointing to AMDSMI library is not set")
|
|
message(" missing: ${AMDSMI_LIB_DIR}/libamd_smi64.so")
|
|
return()
|
|
endif()
|
|
endif()
|
|
|
|
string(TOLOWER "${AMDSMITST_BLD_TYPE}" tmp)
|
|
if("${tmp}" STREQUAL release)
|
|
set(BUILD_TYPE "Release")
|
|
set(ISDEBUG 0)
|
|
else()
|
|
set(BUILD_TYPE "Debug")
|
|
set(ISDEBUG 1)
|
|
endif()
|
|
|
|
#
|
|
# Print out the build configuration being used:
|
|
#
|
|
# Build Src directory
|
|
# Build Binary directory
|
|
# Build Type: Debug Vs Release, 32 Vs 64
|
|
# Compiler Version, etc
|
|
#
|
|
message("")
|
|
message("Build Configuration:")
|
|
message("-------------IS64BIT: " ${IS64BIT})
|
|
message("-----------BuildType: " ${BUILD_TYPE})
|
|
message("------------Compiler: " ${CMAKE_CXX_COMPILER})
|
|
message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION})
|
|
message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR})
|
|
message("--------Proj Bld Dir: " ${PROJECT_BINARY_DIR})
|
|
message("--------Proj Lib Dir: " ${PROJECT_BINARY_DIR}/lib)
|
|
message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin)
|
|
message("--------AMDSMI Lib Dir: " ${AMDSMI_LIB_DIR})
|
|
message("")
|
|
|
|
#
|
|
# Set the build type based on user input
|
|
#
|
|
set(CMAKE_BUILD_TYPE ${BUILD_TYPE})
|
|
#
|
|
# Flag to enable / disable verbose output.
|
|
#
|
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
#
|
|
# Compiler pre-processor definitions.
|
|
#
|
|
# Define MACRO "DEBUG" if build type is "Debug"
|
|
if(${BUILD_TYPE} STREQUAL "Debug")
|
|
add_definitions(-DDEBUG)
|
|
endif()
|
|
|
|
add_definitions(-D__linux__)
|
|
add_definitions(-DLITTLEENDIAN_CPU=1)
|
|
|
|
#
|
|
# Linux Compiler options
|
|
#
|
|
set(CMAKE_CXX_FLAGS "-std=c++11 ")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-math-errno")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-threadsafe-statics")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmerge-all-constants")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fms-extensions")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
|
|
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
|
|
|
|
## Address Sanitize Flag
|
|
if (${ADDRESS_SANITIZER})
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -g")
|
|
set(CMAKE_EXE_LINKER_FLAGS -fsanitize=address)
|
|
|
|
if (BUILD_SHARED_LIBS})
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -shared-libsan" )
|
|
else ()
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libsan" )
|
|
endif ()
|
|
endif()
|
|
|
|
|
|
#
|
|
# Extend the compiler flags for 64-bit builds
|
|
#
|
|
if (IS64BIT)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -msse -msse2")
|
|
else()
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
|
|
endif()
|
|
|
|
#
|
|
# Add compiler flags to include symbol information for debug builds
|
|
#
|
|
if(ISDEBUG)
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0")
|
|
endif()
|
|
MESSAGE("ISDEBUG STEP:Done")
|
|
|
|
|
|
set(AMDSMITST_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
# Set Name for Google Test Framework and build it as a
|
|
# static library to be linked with user test programs
|
|
#
|
|
set(GOOGLE_TEST_FRWK_NAME "gtest")
|
|
add_subdirectory(${AMDSMITST_ROOT}/../rocm_smi_test/gtest "${PROJECT_BINARY_DIR}/gtest")
|
|
set (AMDSMITST_LIBS ${AMDSMITST_LIBS} ${GOOGLE_TEST_FRWK_NAME})
|
|
|
|
#
|
|
#
|
|
# Other source directories
|
|
aux_source_directory(${AMDSMITST_ROOT}/functional functionalSources)
|
|
|
|
#
|
|
# Specify the directory containing various libraries of ROCR
|
|
# to be linked against for building ROC Perf applications
|
|
#
|
|
LINK_DIRECTORIES(${AMDSMI_LIB_DIR} ${GTEST_LIB_DIR})
|
|
|
|
#
|
|
# Extend the list of libraries to be used for linking amdsmi apps
|
|
#
|
|
if (IS64BIT)
|
|
set(AMDSMITST_LIBS ${AMDSMITST_LIBS} amd_smi64)
|
|
set(AMDSMITST "amdsmitst64")
|
|
else()
|
|
set(AMDSMITST_LIBS ${AMDSMITST_LIBS} amd_smi32)
|
|
set(AMDSMITST "amdsmitst")
|
|
endif()
|
|
|
|
|
|
#
|
|
# Source files for building rocrtst
|
|
#
|
|
aux_source_directory(${AMDSMITST_ROOT} amdsmitstSources)
|
|
|
|
# Header file include path
|
|
|
|
include_directories(${AMDSMI_INC_DIR})
|
|
include_directories(${AMDSMITST_ROOT}/..)
|
|
include_directories(${AMDSMITST_ROOT}/../../amd_smi/include)
|
|
include_directories(${AMDSMITST_ROOT}/../../include)
|
|
include_directories(${AMDSMITST_ROOT}/gtest/include)
|
|
|
|
# Build rules
|
|
message("--------AMDSMITST: " ${AMDSMITST} )
|
|
message("--------amdsmitstSources: " ${amdsmitstSources} )
|
|
message("--------functionalSources: " ${functionalSources} )
|
|
add_executable(${AMDSMITST} ${amdsmitstSources} ${functionalSources})
|
|
|
|
target_link_libraries(${AMDSMITST} ${AMDSMITST_LIBS} c stdc++ pthread)
|
|
|
|
install(TARGETS ${AMDSMITST}
|
|
ARCHIVE DESTINATION ${PROJECT_BINARY_DIR}/lib
|
|
LIBRARY DESTINATION ${PROJECT_BINARY_DIR}/lib
|
|
RUNTIME DESTINATION ${PROJECT_BINARY_DIR}/bin)
|
|
|