mirror of
https://github.com/ROCm/composable_kernel.git
synced 2026-05-12 01:10:17 +00:00
* replace buffer_atomic with global_atomic * fixed global_atomic_add * added bf16 atomic_add * format * clang-format-12 * clean * clean * add guards * Update gtest.cmake * enabled splitk_gemm_multi_d * format * add ckProfiler * format * fixed naming * format * clean * clean * add guards * fix clang format * format * add kbatch printout * clean * Add rocm6.2 related gemm optimization * Limit bf16 atomic usage * remove redundant RCR gemm_universal instance * Add RRR fp8 gemm universal instance * Bug fix * Add GPU_TARGET guard to FP8/BF8 target * bug fix * update cmake * remove all fp8/bf8 example if arch not support * Enable fp8 RRR support in ckProfiler * limit greedy-reverse flag to gemm_universal in ckProfiler --------- Co-authored-by: Jing Zhang <jizhan@fb.com> Co-authored-by: Jing Zhang <jizhan@meta.com> Co-authored-by: zjing14 <zhangjing14@gmail.com> Co-authored-by: Illia Silin <98187287+illsilin@users.noreply.github.com> Co-authored-by: illsilin <Illia.Silin@amd.com>
202 lines
8.0 KiB
CMake
202 lines
8.0 KiB
CMake
include_directories(BEFORE
|
|
${PROJECT_SOURCE_DIR}/include
|
|
${PROJECT_SOURCE_DIR}/library/include
|
|
)
|
|
|
|
add_custom_target(examples)
|
|
|
|
function(add_example_dependencies EXAMPLE_NAME FILE_NAME)
|
|
if(FILE_NAME)
|
|
add_dependencies(EXAMPLE_NAME FILE_NAME)
|
|
endif()
|
|
endfunction(add_example_dependencies EXAMPLE_NAME)
|
|
|
|
function(add_example_executable EXAMPLE_NAME FILE_NAME)
|
|
message("adding example ${EXAMPLE_NAME}")
|
|
set(result 1)
|
|
if(DEFINED DTYPES)
|
|
foreach(source IN LISTS FILE_NAME)
|
|
set(test 0)
|
|
if((source MATCHES "_fp16" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_fp64" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_bf8" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_int8" OR source MATCHES "_i8") AND NOT "int8" IN_LIST DTYPES)
|
|
set(test 1)
|
|
endif()
|
|
if(test EQUAL 1)
|
|
message("removing example source file ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
if(INSTANCES_ONLY)
|
|
set(EX_TARGETS ${DEFAULT_GPU_TARGETS})
|
|
else()
|
|
set(EX_TARGETS ${GPU_TARGETS})
|
|
endif()
|
|
|
|
#Do not build any DL examples if DL_KERNELS not set
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
|
|
message("removing dl example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any XDL examples if gfx9 targets are not on the list
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT EX_TARGETS MATCHES "gfx9" AND source MATCHES "_xdl")
|
|
message("removing xdl example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any WMMA examples if gfx11 targets are not on the list
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT EX_TARGETS MATCHES "gfx11" AND NOT EX_TARGETS MATCHES "gfx12" AND source MATCHES "_wmma")
|
|
message("removing wmma example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any FP8 examples if CK_ENABLE_FP8 not set
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT DEFINED CK_ENABLE_FP8 AND source MATCHES "_fp8")
|
|
message("removing fp8 example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any BF8 examples if CK_ENABLE_BF8 not set
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT DEFINED CK_ENABLE_BF8 AND source MATCHES "_bf8")
|
|
message("removing bf8 example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#only continue if there are some source files left on the list
|
|
if(FILE_NAME)
|
|
if(FILE_NAME MATCHES "_xdl")
|
|
list(REMOVE_ITEM EX_TARGETS gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201)
|
|
elseif(FILE_NAME MATCHES "_wmma")
|
|
list(REMOVE_ITEM EX_TARGETS gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030)
|
|
endif()
|
|
set_source_files_properties(${FILE_NAME} PROPERTIES LANGUAGE HIP)
|
|
add_executable(${EXAMPLE_NAME} ${FILE_NAME})
|
|
target_link_libraries(${EXAMPLE_NAME} PRIVATE utility)
|
|
add_test(NAME ${EXAMPLE_NAME} COMMAND $<TARGET_FILE:${EXAMPLE_NAME}> ${ARGN})
|
|
set_property(TARGET ${EXAMPLE_NAME} PROPERTY HIP_ARCHITECTURES ${EX_TARGETS} )
|
|
add_dependencies(examples ${EXAMPLE_NAME})
|
|
add_dependencies(check ${EXAMPLE_NAME})
|
|
rocm_install(TARGETS ${EXAMPLE_NAME} COMPONENT examples)
|
|
set(result 0)
|
|
endif()
|
|
#message("add_example returns ${result}")
|
|
set(result ${result} PARENT_SCOPE)
|
|
endfunction(add_example_executable EXAMPLE_NAME)
|
|
|
|
function(add_example_dependencies EXAMPLE_NAME FILE_NAME)
|
|
if(result EQUAL 0)
|
|
add_dependencies(${EXAMPLE_NAME} ${FILE_NAME})
|
|
endif()
|
|
endfunction(add_example_dependencies EXAMPLE_NAME)
|
|
|
|
function(add_example_executable_no_testing EXAMPLE_NAME FILE_NAME)
|
|
message("adding example ${EXAMPLE_NAME}")
|
|
set(result 1)
|
|
if(DEFINED DTYPES)
|
|
foreach(source IN LISTS FILE_NAME)
|
|
set(test 0)
|
|
if((source MATCHES "_fp16" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_fp64" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_bf8" OR source MATCHES "_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)
|
|
set(test 1)
|
|
endif()
|
|
if((source MATCHES "_int8" OR source MATCHES "_i8") AND NOT "int8" IN_LIST DTYPES)
|
|
set(test 1)
|
|
endif()
|
|
if(test EQUAL 1)
|
|
message("removing example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
endif()
|
|
|
|
if(INSTANCES_ONLY)
|
|
set(EX_TARGETS ${DEFAULT_GPU_TARGETS})
|
|
else()
|
|
set(EX_TARGETS ${GPU_TARGETS})
|
|
endif()
|
|
#Do not build any DL examples if DL_KERNELS not set
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
|
|
message("removing dl example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any XDL examples if gfx9 targets are not on the list
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT EX_TARGETS MATCHES "gfx9" AND source MATCHES "_xdl")
|
|
message("removing xdl example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#Do not build any WMMA examples if gfx11 targets are not on the list
|
|
foreach(source IN LISTS FILE_NAME)
|
|
if(NOT EX_TARGETS MATCHES "gfx11" AND NOT EX_TARGETS MATCHES "gfx12" AND source MATCHES "_wmma")
|
|
message("removing wmma example ${source} ")
|
|
list(REMOVE_ITEM FILE_NAME "${source}")
|
|
endif()
|
|
endforeach()
|
|
#only continue if there are some source files left on the list
|
|
if(FILE_NAME)
|
|
if(FILE_NAME MATCHES "_xdl")
|
|
list(REMOVE_ITEM EX_TARGETS gfx900 gfx906 gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201)
|
|
elseif(FILE_NAME MATCHES "_wmma")
|
|
list(REMOVE_ITEM EX_TARGETS gfx900 gfx906 gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030)
|
|
endif()
|
|
set_source_files_properties(${FILE_NAME} PROPERTIES LANGUAGE HIP)
|
|
add_executable(${EXAMPLE_NAME} ${FILE_NAME})
|
|
target_link_libraries(${EXAMPLE_NAME} PRIVATE utility)
|
|
add_dependencies(examples ${EXAMPLE_NAME})
|
|
set_property(TARGET ${EXAMPLE_NAME} PROPERTY HIP_ARCHITECTURES ${EX_TARGETS} )
|
|
rocm_install(TARGETS ${EXAMPLE_NAME} COMPONENT examples)
|
|
set(result 0)
|
|
endif()
|
|
#message("add_example returns ${result}")
|
|
set(result ${result} PARENT_SCOPE)
|
|
endfunction(add_example_executable_no_testing EXAMPLE_NAME)
|
|
|
|
# add all example subdir
|
|
file(GLOB dir_list LIST_DIRECTORIES true *)
|
|
FOREACH(subdir ${dir_list})
|
|
if(IS_DIRECTORY "${subdir}" AND EXISTS "${subdir}/CMakeLists.txt")
|
|
add_subdirectory(${subdir})
|
|
ENDIF()
|
|
ENDFOREACH()
|