[hit] Add support for specifying dependencies in HIT syntax (#1323)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
b2fc64cc39
Коммит
d3e2bbc791
@@ -47,7 +47,7 @@ In the above, BUILD commands provide instructions on how to build the test case
|
||||
|
||||
The supported syntax for the BUILD command is:
|
||||
```
|
||||
BUILD: %t %s HIPCC_OPTIONS <hipcc_specific_options> HCC_OPTIONS <hcc_specific_options> NVCC_OPTIONS <nvcc_specific_options> EXCLUDE_HIP_PLATFORM <hcc|nvcc|all>
|
||||
BUILD: %t %s HIPCC_OPTIONS <hipcc_specific_options> HCC_OPTIONS <hcc_specific_options> NVCC_OPTIONS <nvcc_specific_options> EXCLUDE_HIP_PLATFORM <hcc|nvcc|all> DEPENDS <dependencies>
|
||||
```
|
||||
%s: refers to current source file name. Additional source files needed for the test can be specified by name (including relative path).
|
||||
%t: refers to target executable named derived by removing the extension from the current source file. Alternatively a target executable name can be specified.
|
||||
@@ -55,13 +55,14 @@ HIPCC_OPTIONS: All options specified after this delimiter are passed to hipcc on
|
||||
HCC_OPTIONS: All options specified after this delimiter are passed to hipcc on HCC platform only.
|
||||
NVCC_OPTIONS: All options specified after this delimiter are passed to hipcc on NVCC platform only.
|
||||
EXCLUDE_HIP_PLATFORM: This can be used to exclude a test case from HCC, NVCC or both platforms.
|
||||
DEPENDS: This can be used to specify dependencies that need to be built before building the current target.
|
||||
|
||||
|
||||
#### BUILD_CMD command
|
||||
|
||||
The supported syntax for the BUILD_CMD command is:
|
||||
```
|
||||
BUILD_CMD: <targetname> <build_command> EXCLUDE_HIP_PLATFORM <hcc|nvcc|all>
|
||||
BUILD_CMD: <targetname> <build_command> EXCLUDE_HIP_PLATFORM <hcc|nvcc|all> DEPENDS <dependencies>
|
||||
```
|
||||
%s: refers to current source file name. Additional source files needed for the test can be specified by name (including relative path).
|
||||
%t: refers to target executable named derived by removing the extension from the current source file. Alternatively a target executable name can be specified.
|
||||
@@ -71,6 +72,8 @@ BUILD_CMD: <targetname> <build_command> EXCLUDE_HIP_PLATFORM <hcc|nvcc|all>
|
||||
%cxx: refers to system c compiler pointed to by /usr/bin/c++.
|
||||
%S: refers to path to current source file.
|
||||
%T: refers to path to current build target.
|
||||
EXCLUDE_HIP_PLATFORM: This can be used to exclude a test case from HCC, NVCC or both platforms.
|
||||
DEPENDS: This can be used to specify dependencies that need to be built before building the current target.
|
||||
|
||||
|
||||
#### TEST command
|
||||
|
||||
@@ -3,7 +3,7 @@ find_package(HIP REQUIRED)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Helper macro to parse BUILD instructions
|
||||
macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_options _link_options _exclude_platforms _dir)
|
||||
macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_options _link_options _exclude_platforms _depends _dir)
|
||||
set(${_target})
|
||||
set(${_sources})
|
||||
set(${_hipcc_options})
|
||||
@@ -11,12 +11,14 @@ macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_opt
|
||||
set(${_nvcc_options})
|
||||
set(${_link_options})
|
||||
set(${_exclude_platforms})
|
||||
set(${_depends})
|
||||
set(_target_found FALSE)
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found FALSE)
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
foreach(arg ${ARGN})
|
||||
if(NOT _target_found)
|
||||
set(_target_found TRUE)
|
||||
@@ -27,30 +29,42 @@ macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_opt
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xHCC_OPTIONS")
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found TRUE)
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xNVCC_OPTIONS")
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found FALSE)
|
||||
set(_nvcc_options_found TRUE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xLINK_OPTIONS")
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found FALSE)
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found TRUE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM")
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found FALSE)
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found TRUE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xDEPENDS")
|
||||
set(_hipcc_options_found FALSE)
|
||||
set(_hcc_options_found FALSE)
|
||||
set(_nvcc_options_found FALSE)
|
||||
set(_link_options_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found TRUE)
|
||||
else()
|
||||
if(_hipcc_options_found)
|
||||
list(APPEND ${_hipcc_options} ${arg})
|
||||
@@ -62,6 +76,8 @@ macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_opt
|
||||
list(APPEND ${_link_options} ${arg})
|
||||
elseif(_exclude_platforms_found)
|
||||
set(${_exclude_platforms} ${arg})
|
||||
elseif(_depends_found)
|
||||
list(APPEND ${_depends} ${arg})
|
||||
else()
|
||||
list(APPEND ${_sources} "${_dir}/${arg}")
|
||||
endif()
|
||||
@@ -70,21 +86,29 @@ macro(PARSE_BUILD_COMMAND _target _sources _hipcc_options _hcc_options _nvcc_opt
|
||||
endmacro()
|
||||
|
||||
# Helper macro to parse CUSTOM BUILD instructions
|
||||
macro(PARSE_CUSTOMBUILD_COMMAND _target _buildcmd _exclude_platforms)
|
||||
macro(PARSE_CUSTOMBUILD_COMMAND _target _buildcmd _exclude_platforms _depends)
|
||||
set(${_target})
|
||||
set(${_buildcmd} " ")
|
||||
set(${_exclude_platforms})
|
||||
set(${_depends})
|
||||
set(_target_found FALSE)
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found FALSE)
|
||||
foreach(arg ${ARGN})
|
||||
if(NOT _target_found)
|
||||
set(_target_found TRUE)
|
||||
set(${_target} ${arg})
|
||||
elseif("x${arg}" STREQUAL "xEXCLUDE_HIP_PLATFORM")
|
||||
set(_exclude_platforms_found TRUE)
|
||||
set(_depends_found FALSE)
|
||||
elseif("x${arg}" STREQUAL "xDEPENDS")
|
||||
set(_exclude_platforms_found FALSE)
|
||||
set(_depends_found TRUE)
|
||||
else()
|
||||
if(_exclude_platforms_found)
|
||||
set(${_exclude_platforms} ${arg})
|
||||
elseif(_depends_found)
|
||||
list(APPEND ${_depends} ${arg})
|
||||
else()
|
||||
list(APPEND ${_buildcmd} ${arg})
|
||||
endif()
|
||||
@@ -179,7 +203,7 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
string(REGEX REPLACE "\n" ";" _contents "${_contents}")
|
||||
foreach(_cmd ${_contents})
|
||||
string(REGEX REPLACE " " ";" _cmd "${_cmd}")
|
||||
parse_build_command(_target _sources _hipcc_options _hcc_options _nvcc_options _link_options _exclude_platforms ${_dir} ${_cmd})
|
||||
parse_build_command(_target _sources _hipcc_options _hcc_options _nvcc_options _link_options _exclude_platforms _depends ${_dir} ${_cmd})
|
||||
string(REGEX REPLACE "/" "." target ${_label}/${_target})
|
||||
insert_into_map("_exclude" "${target}" "${_exclude_platforms}")
|
||||
if(_exclude_platforms STREQUAL "all" OR _exclude_platforms STREQUAL ${HIP_PLATFORM})
|
||||
@@ -190,6 +214,10 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
target_link_libraries(${target} PRIVATE ${_link_options})
|
||||
set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target} RUNTIME_OUTPUT_DIRECTORY ${_label} LINK_DEPENDS "${HIP_LIB_FILES}")
|
||||
add_dependencies(${_parent} ${target})
|
||||
foreach(_dependency ${_depends})
|
||||
string(REGEX REPLACE "/" "." _dependency ${_label}/${_dependency})
|
||||
add_dependencies(${target} ${_dependency})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -208,7 +236,7 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
string(REGEX REPLACE "%T" ${_label} _contents "${_contents}")
|
||||
foreach(_cmd ${_contents})
|
||||
string(REGEX REPLACE " " ";" _cmd "${_cmd}")
|
||||
parse_custombuild_command(_target _buildcmd _exclude_platforms ${_cmd})
|
||||
parse_custombuild_command(_target _buildcmd _exclude_platforms _depends ${_cmd})
|
||||
string(REGEX REPLACE "/" "." target ${_label}/${_target})
|
||||
insert_into_map("_exclude" "${target}" "${_exclude_platforms}")
|
||||
if(_exclude_platforms STREQUAL "all" OR _exclude_platforms STREQUAL ${HIP_PLATFORM})
|
||||
@@ -219,6 +247,10 @@ macro(HIT_ADD_FILES _dir _label _parent)
|
||||
#add_custom_target(${target} COMMAND ${buildscript})
|
||||
add_custom_target(${target} COMMAND sh -c "${_buildcmd}")
|
||||
add_dependencies(${_parent} ${target})
|
||||
foreach(_dependency ${_depends})
|
||||
string(REGEX REPLACE "/" "." _dependency ${_label}/${_dependency})
|
||||
add_dependencies(${target} ${_dependency})
|
||||
endforeach()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user