From 605b3a5105476aa8055e138aaa36ec28db5e0edf Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Thu, 4 Jun 2020 19:25:31 +0530 Subject: [PATCH] Adapting to latest HSA changes JIRA : SWDEV-234471 With this change rocminfo exe shall be created using using hsa-runtime64::hsa-runtime64 which internally decides whether static or shared libs based on its cmake build options S. Keely: Update patch to use find_package for rocr dependency. Removed deadcode now supported by find_package. Removed "hsa/" prefix from include statements since find_package points to the target (ie rocr) include directory. Removed typedef on structs due to new clang-11 warning. Adapting to the comments : Removed PATHS for hsa find_package Change-Id: I1ec65cdbce3085e44f1839da196eb4ae5c9ff30d --- CMakeLists.txt | 88 +++++++++----------------------------------------- rocminfo.cc | 20 ++++++------ 2 files changed, 26 insertions(+), 82 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88a1d283aa..6dd3762d2d 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,4 @@ # -# Minimum version of cmake required -# -cmake_minimum_required(VERSION 3.5.0) -include ( GNUInstallDirs ) -# # GCC 4.8 or higher compiler required. # # Required Defines on cmake command line @@ -35,6 +30,17 @@ include ( GNUInstallDirs ) # # Currently support for Windows platform is not present # + +# +# Minimum version of cmake required +# +cmake_minimum_required(VERSION 3.5.0) + +set(ROCMINFO_EXE "rocminfo") +set(PROJECT_NAME ${ROCMINFO_EXE}) +project (${PROJECT_NAME}) + +include ( GNUInstallDirs ) if(WIN32) message("This sample is not supported on Windows platform") return() @@ -51,40 +57,7 @@ include(utils) # Process input variables # -# Required Defines first: -set(ROCRTST_BLD_BITS CACHE "64" STRING "Either 32 or 64") -set(ROCM_DIR CACHE PATH "Root for RocM install") -set(ROCR_INC_DIR ${ROCM_DIR}/include CACHE PATH "Path for RocM includes") -set(ROCR_LIB_DIR ${ROCM_DIR}/lib CACHE PATH "Path for RocM libraries") -# -# Determine ROCR Header files are present -# -if(NOT EXISTS ${ROCR_INC_DIR}/hsa/hsa.h) - message(FATAL_ERROR, "ERROR: ${ROCR_INC_DIR}/hsa/hsa.h does not exist. Check value of ROCM_DIR define") - return() -endif() - -# Determine ROCR Library files are present -# -if("${ROCRTST_BLD_BITS}" STREQUAL 32) - set (ONLY64STR "") - set (IS64BIT 0) -else() - set (ONLY64STR "64") - set (IS64BIT 1) -endif() -# -if (${IS64BIT} EQUAL 0) - if(NOT EXISTS ${ROCR_LIB_DIR}/libhsa-runtime.so) - message(FATAL_ERROR, "ERROR: ${ROCR_LIB_DIR}/libhsa-runtime.so doesn't exist. Check value of ROCM_DIR define") - return() - endif() -else() - if(NOT EXISTS ${ROCR_LIB_DIR}/libhsa-runtime64.so) - message(FATAL_ERROR, "ERROR: Define ROCR_LIB_DIR pointing to ROCR libraries is not set") - return() - endif() -endif() +find_package(hsa-runtime64 1.0 REQUIRED ) string(TOLOWER "${ROCRTST_BLD_TYPE}" tmp) if("${tmp}" STREQUAL release) @@ -95,15 +68,6 @@ else() set(ISDEBUG 1) endif() -# Set Name for Samples Project -# - -set(ROCMINFO_EXE "rocminfo") -set(PROJECT_NAME ${ROCMINFO_EXE}) -project (${PROJECT_NAME}) - - - # The following default version values should be updated as appropriate for # ABI breaks (update MAJOR and MINOR), and ABI/API additions (update MINOR). # Until ABI stabilizes VERSION_MAJOR will be 0. This should be over-ridden @@ -133,7 +97,6 @@ message("Package version: ${PKG_VERSION_STR}") # message("") message("Build Configuration:") -message("-------------IS64BIT: " ${IS64BIT}) message("-----------BuildType: " ${BUILD_TYPE}) message("------------Compiler: " ${CMAKE_CXX_COMPILER}) message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION}) @@ -176,17 +139,13 @@ 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} -Werror") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") # # Extend the compiler flags for 64-bit builds # -if (IS64BIT) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - if((${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") OR (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64")) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2") - endif() -else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") +if((${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64") OR (${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "AMD64")) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse -msse2") endif() # @@ -196,21 +155,6 @@ if(ISDEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -O0") endif() -# -# Linux Linker options -## -# Specify the directory containing various libraries of ROCR -# to be linked against for building ROC Perf applications -# -link_directories(${ROCR_LIB_DIR}) - -# -# Extend the list of libraries to be used for linking ROC Perf Apps -# -set(ROCR_LIBS ${ROCR_LIBS} hsa-runtime${ONLY64STR}) - -include_directories(${ROCR_INC_DIR} ${OPENCL_INC_DIR}) - ########################### # rocm_agent_enumerator ########################### @@ -223,7 +167,7 @@ configure_file(rocm_agent_enumerator rocm_agent_enumerator COPYONLY) ########################### aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} ROCMINFO_SOURCES) add_executable(${ROCMINFO_EXE} ${ROCMINFO_SOURCES}) -target_link_libraries(${ROCMINFO_EXE} ${ROCR_LIBS} c stdc++ dl pthread rt) +target_link_libraries(${ROCMINFO_EXE} hsa-runtime64::hsa-runtime64) ########################### # Install directives diff --git a/rocminfo.cc b/rocminfo.cc index 205e430a1e..7cc117e46a 100755 --- a/rocminfo.cc +++ b/rocminfo.cc @@ -55,8 +55,8 @@ #include #include -#include "hsa/hsa.h" -#include "hsa/hsa_ext_amd.h" +#include "hsa.h" +#include "hsa_ext_amd.h" #define COL_BLU "\x1B[34m" #define COL_KCYN "\x1B[36m" @@ -87,17 +87,17 @@ // This structure holds system information acquired through hsa info related // calls, and is later used for reference when displaying the information. -typedef struct { +struct system_info_t { uint16_t major, minor; uint64_t timestamp_frequency = 0; uint64_t max_wait = 0; hsa_endianness_t endianness; hsa_machine_model_t machine_model; -} system_info_t; +}; // This structure holds agent information acquired through hsa info related // calls, and is later used for reference when displaying the information. -typedef struct { +struct agent_info_t { char name[64]; char uuid[24]; char vendor_name[64]; @@ -133,7 +133,7 @@ typedef struct { uint16_t workgroup_max_dim[3]; uint16_t bdf_id; bool fast_f16; -} agent_info_t; +}; // This structure holds memory pool information acquired through hsa info // related calls, and is later used for reference when displaying the @@ -151,7 +151,7 @@ typedef struct { // This structure holds ISA information acquired through hsa info // related calls, and is later used for reference when displaying the // information. -typedef struct { +struct isa_info_t { char *name_str; uint32_t workgroup_max_size; hsa_dim3_t grid_max_dim; @@ -163,16 +163,16 @@ typedef struct { bool mach_models[2]; bool profiles[2]; bool fast_f16; -} isa_info_t; +}; // This structure holds cache information acquired through hsa info // related calls, and is later used for reference when displaying the // information. -typedef struct { +struct cache_info_t { char *name_str; uint8_t level; uint32_t size; -} cache_info_t; +}; static const uint32_t kLabelFieldSize = 25; static const uint32_t kValueFieldSize = 35;