Add a flag to build CK libs required for HipTensor. (#3684)

* create a filter to build only libs required by hiptensor

* allow building libs for miopen and hiptensor at the same time

* tweak the lib filtering logic one more time

[ROCm/composable_kernel commit: 05ef93a69d]
This commit is contained in:
Illia Silin
2026-01-29 16:12:49 -08:00
committed by GitHub
parent a07d76a460
commit 4883171ee4
2 changed files with 24 additions and 10 deletions

View File

@@ -335,11 +335,23 @@ FOREACH(subdir_path ${dir_list})
endif()
endif()
# Build the required pattern based on library settings
set(required_pattern "")
set(pattern_parts "")
if(MIOPEN_REQ_LIBS_ONLY)
message(STATUS "Removing all sources that are not required for MIOpen")
if(NOT "${cmake_instance}" MATCHES "conv")
set(add_inst 0)
endif()
list(APPEND pattern_parts "conv")
endif()
if(HIPTENSOR_REQ_LIBS_ONLY)
message(STATUS "Removing all sources that are not required for HipTensor")
list(APPEND pattern_parts "contract" "reduce" "element")
endif()
if(pattern_parts)
string(JOIN "|" required_pattern ${pattern_parts})
endif()
# Apply the pattern if one was set
if(required_pattern AND NOT "${cmake_instance}" MATCHES "${required_pattern}")
set(add_inst 0)
endif()
if((add_inst EQUAL 1))
@@ -405,7 +417,7 @@ if(CK_DEVICE_OTHER_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel
)
endif()
if(CK_DEVICE_GEMM_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY)
if(CK_DEVICE_GEMM_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY AND NOT HIPTENSOR_REQ_LIBS_ONLY)
add_library(device_gemm_operations ${CK_DEVICE_GEMM_INSTANCES})
add_library(composablekernels::device_gemm_operations ALIAS device_gemm_operations)
target_compile_features(device_gemm_operations PUBLIC)
@@ -426,7 +438,7 @@ if(CK_DEVICE_GEMM_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel
)
endif()
if(CK_DEVICE_CONV_INSTANCES)
if(CK_DEVICE_CONV_INSTANCES AND (NOT HIPTENSOR_REQ_LIBS_ONLY OR MIOPEN_REQ_LIBS_ONLY))
add_library(device_conv_operations ${CK_DEVICE_CONV_INSTANCES})
add_library(composablekernels::device_conv_operations ALIAS device_conv_operations)
target_compile_features(device_conv_operations PUBLIC)
@@ -451,7 +463,7 @@ if(CK_DEVICE_CONV_INSTANCES)
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel
)
endif()
if(CK_DEVICE_MHA_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY AND BUILD_MHA_LIB)
if(CK_DEVICE_MHA_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY AND NOT HIPTENSOR_REQ_LIBS_ONLY AND BUILD_MHA_LIB)
set(gpu_list ${INST_TARGETS})
if(gpu_list MATCHES "gfx94" OR gpu_list MATCHES "gfx90a" OR gpu_list MATCHES "gfx95")
add_library(device_mha_operations ${CK_DEVICE_MHA_INSTANCES})
@@ -517,7 +529,7 @@ if(CK_DEVICE_REDUCTION_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY)
)
endif()
if(NOT MIOPEN_REQ_LIBS_ONLY)
if(NOT MIOPEN_REQ_LIBS_ONLY AND NOT HIPTENSOR_REQ_LIBS_ONLY)
add_library(device_operations INTERFACE)
target_link_libraries(device_operations INTERFACE
device_contraction_operations