From 5338925d7023f3259abc0d6cc4ca4a856d27e073 Mon Sep 17 00:00:00 2001 From: Yi DING Date: Fri, 24 Oct 2025 03:01:26 +0800 Subject: [PATCH] Use filename but not path to filter compilation (#3083) * prologue * Use filename but not path to filter test compilation [ROCm/composable_kernel commit: fe4eaeb2eb28088e07d7c7e5f8bd7499831a427c] --- test/CMakeLists.txt | 95 ++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 48 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c16841d595..47b776f401 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -53,26 +53,27 @@ function(add_test_executable TEST_NAME) set(result 1) if(DEFINED DTYPES) foreach(source IN LISTS ARGN) + get_filename_component(source_name ${source} NAME) set(test 0) - if((source MATCHES "_fp16" OR source MATCHES "_f16") AND NOT "fp16" IN_LIST DTYPES) + if((source_name MATCHES "_fp16|_f16") AND NOT "fp16" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp32" OR source MATCHES "_f32") AND NOT "fp32" IN_LIST DTYPES) + if((source_name MATCHES "_fp32|_f32") AND NOT "fp32" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp64" OR source MATCHES "_f64") AND NOT "fp64" IN_LIST DTYPES) + if((source_name MATCHES "_fp64|_f64") AND NOT "fp64" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp8" OR source MATCHES "_f8") AND NOT "fp8" IN_LIST DTYPES) + if((source_name MATCHES "_fp8|_f8") AND NOT "fp8" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_bf8" OR source MATCHES "_bf8") AND NOT "bf8" IN_LIST DTYPES) + if((source_name MATCHES "_bf8|_bf8") AND NOT "bf8" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_bf16" OR source MATCHES "_b16") AND NOT "bf16" IN_LIST DTYPES) + if((source_name MATCHES "_bf16|_b16") AND NOT "bf16" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_int8" OR source MATCHES "_i8") AND NOT "int8" IN_LIST DTYPES) + if((source_name MATCHES "_int8|_i8") AND NOT "int8" IN_LIST DTYPES) set(test 1) endif() if(test EQUAL 1) @@ -85,36 +86,36 @@ function(add_test_executable TEST_NAME) set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS}) foreach(source IN LISTS ARGN) - if(NOT DEFINED DPP_KERNELS AND source MATCHES "_dpp") + get_filename_component(source_name ${source} NAME) + if(NOT DEFINED DPP_KERNELS AND source_name MATCHES "_dpp") message(DEBUG "removing dpp test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() - endforeach() - foreach(source IN LISTS ARGN) - if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl") + if(NOT DEFINED DL_KERNELS AND source_name MATCHES "_dl") message(DEBUG "removing dl test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() - endforeach() - foreach(source IN LISTS ARGN) - if(NOT TEST_TARGETS MATCHES "gfx9" AND NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "xdl") + if(NOT TEST_TARGETS MATCHES "gfx9|gfx11|gfx12" AND source_name MATCHES "xdl") message(DEBUG "removing xdl test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() - endforeach() - foreach(source IN LISTS ARGN) - if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma") + if(NOT TEST_TARGETS MATCHES "gfx11|gfx12" AND source_name MATCHES "wmma") message(DEBUG "removing wmma test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() endforeach() #only continue if there are some source files left on the list + set(source_name_list "") + foreach(source IN LISTS ARGN) + get_filename_component(source_name ${source} NAME) + list(APPEND source_name_list ${source_name}) + endforeach() if(ARGN) - if(ARGN MATCHES "_xdl") + if(source_name_list MATCHES "_xdl") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx10-3-generic) - elseif(ARGN MATCHES "_wmma") + elseif(source_name_list MATCHES "_wmma") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx942 gfx1030 gfx950) - elseif(ARGN MATCHES "_smfmac") + elseif(source_name_list MATCHES "_smfmac") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151 gfx1152 gfx908 gfx90a gfx1200 gfx1201 gfx10-3-generic gfx11-generic gfx12-generic) endif() set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP) @@ -143,26 +144,27 @@ function(add_gtest_executable TEST_NAME) set(result 1) if(DEFINED DTYPES) foreach(source IN LISTS ARGN) + get_filename_component(source_name ${source} NAME) set(test 0) - if((source MATCHES "_fp16" OR source MATCHES "_f16") AND NOT "fp16" IN_LIST DTYPES) + if((source_name MATCHES "_fp16|_f16") AND NOT "fp16" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp32" OR source MATCHES "_f32") AND NOT "fp32" IN_LIST DTYPES) + if((source_name MATCHES "_fp32|_f32") AND NOT "fp32" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp64" OR source MATCHES "_f64") AND NOT "fp64" IN_LIST DTYPES) + if((source_name MATCHES "_fp64|_f64") AND NOT "fp64" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_fp8" OR source MATCHES "_f8") AND NOT "fp8" IN_LIST DTYPES) + if((source_name MATCHES "_fp8|_f8") AND NOT "fp8" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_bf8" OR source MATCHES "_bf8") AND NOT "bf8" IN_LIST DTYPES) + if((source_name MATCHES "_bf8|_bf8") AND NOT "bf8" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_bf16" OR source MATCHES "_b16") AND NOT "bf16" IN_LIST DTYPES) + if((source_name MATCHES "_bf16|_b16") AND NOT "bf16" IN_LIST DTYPES) set(test 1) endif() - if((source MATCHES "_int8" OR source MATCHES "_i8") AND NOT "int8" IN_LIST DTYPES) + if((source_name MATCHES "_int8|_i8") AND NOT "int8" IN_LIST DTYPES) set(test 1) endif() if(test EQUAL 1) @@ -175,42 +177,39 @@ function(add_gtest_executable TEST_NAME) set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS}) foreach(source IN LISTS ARGN) - if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl") + get_filename_component(source_name ${source} NAME) + if(NOT DEFINED DL_KERNELS AND source_name MATCHES "_dl") message(DEBUG "removing dl test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() - endforeach() - - foreach(source IN LISTS ARGN) - if(NOT TEST_TARGETS MATCHES "gfx9" AND NOT TEST_TARGETS MATCHES "gfx1[12]" AND source MATCHES "xdl") + if(NOT TEST_TARGETS MATCHES "gfx9|gfx11|gfx12" AND source_name MATCHES "xdl") message(DEBUG "removing xdl test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() - endforeach() - - foreach(source IN LISTS ARGN) - if(NOT TEST_TARGETS MATCHES "gfx95" AND source MATCHES "mx_") - message(DEBUG "removing microscaling test ${source} ") - list(REMOVE_ITEM ARGN "${source}") - endif() - endforeach() - - foreach(source IN LISTS ARGN) - if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma") - message(DEBUG "removing wmma test ${source} ") + if(NOT TEST_TARGETS MATCHES "gfx95" AND source_name MATCHES "mx_") + message(DEBUG "removing microscaling test ${source} ") + list(REMOVE_ITEM ARGN "${source}") + endif() + if(NOT TEST_TARGETS MATCHES "gfx11|gfx12" AND source_name MATCHES "wmma") + message(DEBUG "removing wmma test ${source} ") list(REMOVE_ITEM ARGN "${source}") endif() endforeach() #only continue if there are some source files left on the list + set(source_name_list "") + foreach(source IN LISTS ARGN) + get_filename_component(source_name ${source} NAME) + list(APPEND source_name_list ${source_name}) + endforeach() if(ARGN) - if(ARGN MATCHES "_xdl") + if(source_name_list MATCHES "_xdl") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx10-3-generic) - elseif(ARGN MATCHES "_wmma") + elseif(source_name_list MATCHES "_wmma") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx942 gfx1030 gfx950) - elseif(ARGN MATCHES "_smfmac") + elseif(source_name_list MATCHES "_smfmac") list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151 gfx1152 gfx908 gfx90a gfx1200 gfx1201 gfx10-3-generic gfx11-generic gfx12-generic) - elseif(ARGN MATCHES "_mx") #only build mx example for gfx950 + elseif(source_name_list MATCHES "_mx") #only build mx example for gfx950 list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx942 gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1150 gfx1151 gfx1152 gfx1200 gfx1201 gfx10-3-generic gfx11-generic gfx12-generic) endif() set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)