5b27d846b2
The rdc.h is the only header file will be provided to the user.
The inital version only includes the data structure and function
required for the job stats example.
The example folder has one example demonstrated how to use the API
to collect the job summary stats.
The RdcBootStrap.cc will dynamically load different libraries when user
select either the standalone or embbed mode. We also created a
dummy RdcEmbeddedHandler.cc for librdc.so.
In order to run the example after build, it needs to specify the
LD_LIBRARY_PATH. Assume current folder is the build folder:
LD_LIBRARY_PATH=$PWD/rdc_libs $PWD/example/jobstats
The folder is structured in following ways:
example
include
- rdc - rdc.h (the only header file exposed to the user)
- rdc_libs
- impl
rdc_libs
- boostrap
- src
- rdc
- src
- rdc_client
- src
- rdc_server
- src
Change-Id: Ia386ddf4cabcb2dc4fe82de6464ca0619cb3d959
[ROCm/rdc commit: 85006053ed]
194 خطوط
6.7 KiB
CMake
Executable File
194 خطوط
6.7 KiB
CMake
Executable File
# Copyright (c) 2019 - present 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.
|
|
|
|
#
|
|
# Minimum version of cmake required
|
|
#
|
|
cmake_minimum_required(VERSION 3.5.0)
|
|
|
|
# ROCM_DIR should be passed in via command line; these will be used
|
|
# in sub-projects
|
|
set(RSMI_INC_DIR ${ROCM_DIR}/rocm_smi/include)
|
|
set(RSMI_LIB_DIR ${ROCM_DIR}/rocm_smi/lib)
|
|
|
|
if (NOT DEFINED RDC_CLIENT_ROOT_PATH)
|
|
set(RDC_CLIENT_ROOT_PATH "/opt/rocm/")
|
|
endif()
|
|
|
|
if (NOT DEFINED RDC_SERVER_ROOT_PATH)
|
|
set(RDC_SERVER_ROOT_PATH "/")
|
|
endif()
|
|
|
|
## Set default module path
|
|
if(NOT DEFINED CMAKE_MODULE_PATH)
|
|
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
|
|
endif()
|
|
## Include common cmake modules
|
|
include(utils)
|
|
|
|
set(RDC "rdc")
|
|
|
|
################# Determine the library version #########################
|
|
## Setup the package version based on git tags.
|
|
set(PKG_VERSION_GIT_TAG_PREFIX "rdc_pkg_ver")
|
|
|
|
# provide git to utilities
|
|
find_program (GIT NAMES git)
|
|
|
|
get_package_version_number("1.0.0" ${PKG_VERSION_GIT_TAG_PREFIX} GIT)
|
|
# VERSION_* variables should be set by get_version_from_tag
|
|
message("Package version: ${PKG_VERSION_STR}")
|
|
|
|
set(${RDC}_VERSION_MAJOR "${VERSION_MAJOR}")
|
|
set(${RDC}_VERSION_MINOR "${VERSION_MINOR}")
|
|
set(${RDC}_VERSION_PATCH "0")
|
|
set(${RDC}_VERSION_BUILD "0")
|
|
|
|
## Define default variable and variables for the optional build target
|
|
## RDC_lib-dev
|
|
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
|
CACHE STRING "Location of RDC source code.")
|
|
set(CMAKE_INSTALL_PREFIX "/"
|
|
CACHE STRING "Default installation directory.")
|
|
set(CPACK_PACKAGING_INSTALL_PREFIX "/"
|
|
CACHE STRING "Default packaging prefix.")
|
|
set(CPACK_GENERATOR "DEB;RPM" CACHE STRING "Default packaging generators.")
|
|
|
|
project(${RDC})
|
|
|
|
# Create a configure file to get version info from within library
|
|
configure_file(
|
|
"${PROJECT_SOURCE_DIR}/src/${RDC}64Config.in"
|
|
"${PROJECT_SOURCE_DIR}/include/rdc/${RDC}64Config.h")
|
|
|
|
if (NOT DEFINED CPACK_PACKAGE_VENDOR)
|
|
set(CPACK_PACKAGE_VENDOR "AMD")
|
|
endif()
|
|
|
|
if (NOT DEFINED CPACK_PACKAGE_CONTACT)
|
|
set(CPACK_PACKAGE_CONTACT "Advanced Micro Devices Inc.")
|
|
endif()
|
|
|
|
if (NOT DEFINED CPACK_PACKAGE_DESCRIPTION_SUMMARY)
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
|
"Radeon Data Center Tools")
|
|
endif()
|
|
|
|
if (NOT RDC_PACKAGE)
|
|
set(RDC_PACKAGE ${RDC})
|
|
endif()
|
|
|
|
set(CPACK_PACKAGE_FILE_NAME "${RDC_PACKAGE}-${PKG_VERSION_STR}")
|
|
## Verbose output.
|
|
set(CMAKE_VERBOSE_MAKEFILE on)
|
|
|
|
# Compile .proto files
|
|
file(GLOB PROTOB_DEF_SRC_FILES "protos/*.proto")
|
|
set(PROTOB_SRC_DIR "${PROJECT_SOURCE_DIR}/protos")
|
|
set(PROTOB_OUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
|
set(PROTOB_CMD "protoc")
|
|
|
|
foreach(file ${PROTOB_DEF_SRC_FILES})
|
|
execute_process(COMMAND
|
|
protoc --proto_path=${PROTOB_SRC_DIR} --cpp_out=${PROTOB_OUT_DIR} ${file}
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
RESULT_VARIABLE PROTOB_RESULT
|
|
OUTPUT_VARIABLE PROTOB_OUT_VAR)
|
|
message("protoc command returned: ${PROTOB_RESULT}")
|
|
|
|
find_program (GRPC_PLUGIN NAMES grpc_cpp_plugin)
|
|
message("GRPC_PLUGIN=${GRPC_PLUGIN})")
|
|
message("protoc cmd:")
|
|
message(" $ protoc --proto_path=${PROTOB_SRC_DIR}")
|
|
message(" --grpc_out=${PROTOB_OUT_DIR}")
|
|
message("....--plugin=\"${GRPC_PLUGIN}\" ${file}")
|
|
|
|
execute_process(COMMAND
|
|
protoc --proto_path=${PROTOB_SRC_DIR} --grpc_out=${PROTOB_OUT_DIR}
|
|
--plugin=protoc-gen-grpc=${GRPC_PLUGIN} ${file}
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
|
|
RESULT_VARIABLE PROTOB_RESULT
|
|
OUTPUT_VARIABLE PROTOB_OUT_VAR)
|
|
message("protoc command returned: ${PROTOB_RESULT}")
|
|
|
|
endforeach()
|
|
|
|
# define all the install component labels to install
|
|
set(SERVER_CTRL_COMPONENT "server_ctrl")
|
|
set(SERVER_BIN_COMPONENT "server_bin")
|
|
set(CLIENT_LIB_COMPONENT "client_lib")
|
|
set(CLIENT_HEADER_COMPONENT "client_header")
|
|
set(RDC_LIB_COMPONENT "rdc_lib")
|
|
set(GTEST_COMPONENT "rdc_gtest")
|
|
set(EXAMPLE_COMPONENT "rdc_example")
|
|
|
|
add_subdirectory("server")
|
|
add_subdirectory("client")
|
|
add_subdirectory("rdc_libs")
|
|
add_subdirectory("example")
|
|
|
|
# Turn on cmake "component install"
|
|
set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
|
|
set(CPACK_COMPONENTS_ALL ${SERVER_CTRL_COMPONENT}
|
|
${SERVER_BIN_COMPONENT} ${CLIENT_LIB_COMPONENT} ${CLIENT_HEADER_COMPONENT}
|
|
${RDC_LIB_COMPONENT})
|
|
|
|
|
|
configure_file(
|
|
"${PROJECT_SOURCE_DIR}/src/DEBIAN_postinst.in"
|
|
"${PROJECT_SOURCE_DIR}/DEBIAN/postinst")
|
|
configure_file(
|
|
"${PROJECT_SOURCE_DIR}/src/RPM_rpm_post.in"
|
|
"${PROJECT_SOURCE_DIR}/RPM/rpm_post")
|
|
|
|
|
|
|
|
# TODO set(CPACK_DEBIAN_PACKAGE_HOMEPAGE <GITHUB URL> )
|
|
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;
|
|
${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm")
|
|
set(CPACK_DEBIAN_PACKAGE_NAME ${RDC_PACKAGE})
|
|
set(CPACK_DEBIAN_PACKAGE_VERSION ${PKG_VERSION_STR})
|
|
|
|
# RPM package specific variables
|
|
set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_post")
|
|
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/RPM/rpm_postun")
|
|
set(CPACK_RPM_PACKAGE_NAME ${RDC_PACKAGE})
|
|
set(CPACK_RPM_PACKAGE_VERSION ${PKG_VERSION_STR})
|
|
|
|
# Generate Doxygen documentation
|
|
find_package(Doxygen)
|
|
if (DOXYGEN_FOUND)
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/docs/rdc_doxygen.cfg
|
|
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
|
add_custom_target(doc
|
|
${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
COMMENT "Generating API documentation with Doxygen" VERBATIM)
|
|
else()
|
|
message("Doxygen is not found. Will not generate documents.")
|
|
endif(DOXYGEN_FOUND)
|
|
|
|
## Add the packaging directives
|
|
include (CPack)
|
|
|