diff --git a/CMakeLists.txt b/CMakeLists.txt index 13606975c0..2f1fc8892b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -605,6 +605,9 @@ ENDIF() ENDFOREACH() add_custom_target(instances DEPENDS utility;${CK_DEVICE_INSTANCES} SOURCES ${INSTANCE_FILES}) + +option(MIOPEN_REQ_LIBS_ONLY "Build only the MIOpen required libraries" OFF) + add_subdirectory(library) if(NOT GPU_ARCHS AND USER_GPU_TARGETS) @@ -624,11 +627,13 @@ if(NOT GPU_ARCHS AND USER_GPU_TARGETS) endif() endif() -rocm_package_setup_component(profiler - LIBRARY_NAME composablekernel - PACKAGE_NAME ckprofiler -) -add_subdirectory(profiler) +if (NOT MIOPEN_REQ_LIBS_ONLY) + rocm_package_setup_component(profiler + LIBRARY_NAME composablekernel + PACKAGE_NAME ckprofiler + ) + add_subdirectory(profiler) +endif() if(CK_USE_CODEGEN AND (SUPPORTED_GPU_TARGETS MATCHES "gfx9" OR GPU_ARCHS)) add_subdirectory(codegen) diff --git a/library/src/tensor_operation_instance/gpu/CMakeLists.txt b/library/src/tensor_operation_instance/gpu/CMakeLists.txt index 97946207a1..73f3ae6cd6 100755 --- a/library/src/tensor_operation_instance/gpu/CMakeLists.txt +++ b/library/src/tensor_operation_instance/gpu/CMakeLists.txt @@ -103,6 +103,18 @@ function(add_instance_library INSTANCE_NAME) list(REMOVE_ITEM ARGN "${source}") endif() endforeach() + + if(MIOPEN_REQ_LIBS_ONLY) + message("Removing all sources that are not required for MIOpen") + foreach(source IN LISTS ARGN) + if(source MATCHES "gemm" OR + source MATCHES "mha" OR + source MATCHES "contraction" OR + source MATCHES "reduce") + list(REMOVE_ITEM ARGN "${source}") + endif() + endforeach() + endif() #message("remaining instances: ${ARGN}") #only continue if there are some source files left on the list if(ARGN) @@ -343,7 +355,7 @@ if(CK_DEVICE_OTHER_INSTANCES) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel ) endif() -if(CK_DEVICE_GEMM_INSTANCES) +if(CK_DEVICE_GEMM_INSTANCES AND NOT MIOPEN_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) @@ -389,7 +401,7 @@ if(CK_DEVICE_CONV_INSTANCES) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel ) endif() -if(CK_DEVICE_MHA_INSTANCES) +if(CK_DEVICE_MHA_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY) 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}) @@ -411,7 +423,7 @@ if(CK_DEVICE_MHA_INSTANCES) ) endif() endif() -if(CK_DEVICE_CONTRACTION_INSTANCES) +if(CK_DEVICE_CONTRACTION_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY) add_library(device_contraction_operations ${CK_DEVICE_CONTRACTION_INSTANCES}) add_library(composablekernels::device_contraction_operations ALIAS device_contraction_operations) target_compile_features(device_contraction_operations PUBLIC) @@ -433,7 +445,7 @@ if(CK_DEVICE_CONTRACTION_INSTANCES) DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/composable_kernel ) endif() -if(CK_DEVICE_REDUCTION_INSTANCES) +if(CK_DEVICE_REDUCTION_INSTANCES AND NOT MIOPEN_REQ_LIBS_ONLY) add_library(device_reduction_operations ${CK_DEVICE_REDUCTION_INSTANCES}) add_library(composablekernels::device_reduction_operations ALIAS device_reduction_operations) target_compile_features(device_reduction_operations PUBLIC) @@ -455,14 +467,16 @@ if(CK_DEVICE_REDUCTION_INSTANCES) ) endif() -add_library(device_operations INTERFACE) -target_link_libraries(device_operations INTERFACE - device_contraction_operations - device_conv_operations - device_gemm_operations - device_other_operations - device_reduction_operations - utility) +if(NOT MIOPEN_REQ_LIBS_ONLY) + add_library(device_operations INTERFACE) + target_link_libraries(device_operations INTERFACE + device_contraction_operations + device_conv_operations + device_gemm_operations + device_other_operations + device_reduction_operations + utility) +endif() set(DEV_OPS_INC_DIRS ${PROJECT_SOURCE_DIR}/include/ck/