CMakeLists.txt 10.7 KB
Newer Older
1
include_directories(BEFORE
Adam Osewski's avatar
Adam Osewski committed
2
    ${PROJECT_SOURCE_DIR}/
3
    ${PROJECT_SOURCE_DIR}/profiler/include
4
5
)

6
include(gtest)
JD's avatar
JD committed
7

8
9
add_custom_target(tests)

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
set(REGRESSION_TESTS
    test_gemm_standalone_xdl_fp16
    test_gemm_fp16
    test_gemm_splitk
    test_batched_gemm
    test_gemm_universal
    test_batched_gemm_softmax_gemm_fp16
    test_batched_gemm_softmax_gemm_permute_fp16
    test_batched_gemm_bias_softmax_gemm_permute_fp16
    test_batched_gemm_softmax_gemm_permute_bf16
    test_batched_gemm_bias_softmax_gemm_permute_bf16
    test_grouped_gemm_splitk
    test_reduce_no_index
    test_reduce_with_index
    test_convnd_fwd
    test_convnd_bwd_data
    test_grouped_convnd_fwd
    test_grouped_convnd_bwd_weight
    test_softmax_rank3
    test_softmax_rank4
    test_batchnorm_fwd_rank_4
    test_batchnorm_bwd_rank_4
    test_grouped_convnd_bwd_data_xdl
    test_conv_tensor_rearrange
)

Chao Liu's avatar
Chao Liu committed
36
37
function(add_test_executable TEST_NAME)
    message("adding test ${TEST_NAME}")
38
39
    set(result 1)
    if(DEFINED DTYPES)
40
41
        foreach(source IN LISTS ARGN)
            set(test 0)
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
            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()
63
64
65
            if(test EQUAL 1)
                message("removing test ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
66
67
            endif()
        endforeach()
68
    endif()
69

70
    set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS})
71

72
73
74
75
76
77
    foreach(source IN LISTS ARGN)
        if(NOT DEFINED DPP_KERNELS AND source MATCHES "_dpp")
            message("removing dpp test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
78
    foreach(source IN LISTS ARGN)
79
80
81
82
83
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
84
    foreach(source IN LISTS ARGN)
85
        if(NOT TEST_TARGETS MATCHES "gfx9" AND source MATCHES "xdl")
86
87
88
89
90
            message("removing xdl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
    foreach(source IN LISTS ARGN)
91
	if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma")
92
93
94
95
            message("removing wmma test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
96
97
    #only continue if there are some source files left on the list
    if(ARGN)
98
        if(ARGN MATCHES "_xdl")
99
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
100
        elseif(ARGN MATCHES "_wmma")
101
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030)
102
        elseif(ARGN MATCHES "_smfmac")
103
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx908 gfx90a gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
104
105
        endif()
        set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)
106
        add_executable(${TEST_NAME} ${ARGN})
107
        set_property(TARGET ${TEST_NAME} PROPERTY HIP_ARCHITECTURES ${TEST_TARGETS} )
108
        target_link_libraries(${TEST_NAME} PRIVATE getopt::getopt)
109
110
111
112
113
114
115
        add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
        add_dependencies(tests ${TEST_NAME})
        add_dependencies(check ${TEST_NAME})
        rocm_install(TARGETS ${TEST_NAME} COMPONENT tests)
        set(result 0)
    endif()
    #message("add_test returns ${result}")
116
    set(result ${result} PARENT_SCOPE)
117
118
119
120
121
122
123
124
125
    if(result EQUAL 0 AND NOT "${TEST_NAME}" IN_LIST REGRESSION_TESTS)
        message("adding to SMOKE TEST FILTER ${TEST_NAME}")
        set_tests_properties(${TEST_NAME} PROPERTIES LABELS "SMOKE_TEST")
        add_dependencies(smoke ${TEST_NAME})
    elseif(result EQUAL 0 AND "${TEST_NAME}" IN_LIST REGRESSION_TESTS)
        message("Adding to REGRESSION TEST FILTER ${TEST_NAME}")
        set_tests_properties(${TEST_NAME} PROPERTIES LABELS "REGRESSION_TEST")
        add_dependencies(regression ${TEST_NAME})
    endif()
126
endfunction()
127
128
129

function(add_gtest_executable TEST_NAME)
    message("adding gtest ${TEST_NAME}")
130
131
    set(result 1)
    if(DEFINED DTYPES)
132
133
        foreach(source IN LISTS ARGN)
            set(test 0)
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
            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()
155
156
157
            if(test EQUAL 1)
                message("removing gtest ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
158
159
160
            endif()
        endforeach()
    endif()
161

162
    set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS})
163

164
165
166
167
    foreach(source IN LISTS ARGN)
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
168
169
170
        endif()
    endforeach()
    foreach(source IN LISTS ARGN)
171
        if(NOT TEST_TARGETS MATCHES "gfx9" AND source MATCHES "xdl")
172
173
174
175
176
            message("removing xdl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
    foreach(source IN LISTS ARGN)
177
	if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma")
178
179
            message("removing wmma test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
180
181
182
183
        endif()
    endforeach()
    #only continue if there are some source files left on the list
    if(ARGN)
184
        if(ARGN MATCHES "_xdl")
185
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
186
        elseif(ARGN MATCHES "_wmma")
187
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030)
188
        elseif(ARGN MATCHES "_smfmac")
189
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx908 gfx90a gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
190
191
        endif()
        set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)
192
        add_executable(${TEST_NAME} ${ARGN})
193
        set_property(TARGET ${TEST_NAME} PROPERTY HIP_ARCHITECTURES ${TEST_TARGETS} )
194
195
196
197
198
        add_dependencies(tests ${TEST_NAME})
        add_dependencies(check ${TEST_NAME})

        # suppress gtest warnings
        target_compile_options(${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef)
199
        target_link_libraries(${TEST_NAME} PRIVATE gtest_main getopt::getopt)
200
201
202
203
        add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
        rocm_install(TARGETS ${TEST_NAME} COMPONENT tests)
        set(result 0)
    endif()
204
    message("add_gtest returns ${result}")
205
    set(result ${result} PARENT_SCOPE)
206
207
208
209
210
211
212
213
214
    if(result EQUAL 0 AND NOT "${TEST_NAME}" IN_LIST REGRESSION_TESTS)
        message("adding to SMOKE TEST FILTER ${TEST_NAME}")
        set_tests_properties(${TEST_NAME} PROPERTIES LABELS "SMOKE_TEST")
        add_dependencies(smoke ${TEST_NAME})
    elseif(result EQUAL 0 AND "${TEST_NAME}" IN_LIST REGRESSION_TESTS)
        message("Adding to REGRESSION TEST FILTER ${TEST_NAME}")
        set_tests_properties(${TEST_NAME} PROPERTIES LABELS "REGRESSION_TEST")
        add_dependencies(regression ${TEST_NAME})
    endif()
215
endfunction()
216

217
add_compile_options(-Wno-c++20-extensions)
218
add_subdirectory(ck_tile)
Chao Liu's avatar
Chao Liu committed
219
220
221
222
223
add_subdirectory(magic_number_division)
add_subdirectory(space_filling_curve)
add_subdirectory(conv_util)
add_subdirectory(reference_conv_fwd)
add_subdirectory(gemm)
224
add_subdirectory(gemm_add)
225
add_subdirectory(gemm_layernorm)
Chao Liu's avatar
Chao Liu committed
226
add_subdirectory(gemm_split_k)
227
add_subdirectory(gemm_universal)
Chao Liu's avatar
Chao Liu committed
228
229
add_subdirectory(gemm_reduce)
add_subdirectory(batched_gemm)
230
add_subdirectory(batched_gemm_reduce)
Anthony Chang's avatar
Anthony Chang committed
231
add_subdirectory(batched_gemm_gemm)
Anthony Chang's avatar
Anthony Chang committed
232
add_subdirectory(batched_gemm_softmax_gemm)
233
add_subdirectory(batched_gemm_softmax_gemm_permute)
Chao Liu's avatar
Chao Liu committed
234
add_subdirectory(grouped_gemm)
235
add_subdirectory(reduce)
236
add_subdirectory(convnd_fwd)
JD's avatar
JD committed
237
add_subdirectory(convnd_bwd_data)
238
add_subdirectory(grouped_convnd_fwd)
239
add_subdirectory(grouped_convnd_bwd_weight)
240
add_subdirectory(block_to_ctile_map)
241
add_subdirectory(softmax)
rocking's avatar
rocking committed
242
add_subdirectory(normalization_fwd)
243
add_subdirectory(normalization_bwd_data)
244
add_subdirectory(normalization_bwd_gamma_beta)
Adam Osewski's avatar
Adam Osewski committed
245
add_subdirectory(data_type)
246
add_subdirectory(elementwise_normalization)
247
add_subdirectory(batchnorm)
248
add_subdirectory(contraction)
249
add_subdirectory(pool)
250
add_subdirectory(batched_gemm_multi_d)
251
add_subdirectory(grouped_convnd_bwd_data)
252
add_subdirectory(conv_tensor_rearrange)
arai713's avatar
arai713 committed
253
add_subdirectory(transpose)
arai713's avatar
arai713 committed
254
add_subdirectory(permute_scale)
255
add_subdirectory(wrapper)
256
if(SUPPORTED_GPU_TARGETS MATCHES "gfx11")
257
258
    add_subdirectory(wmma_op)
endif()
259
if(SUPPORTED_GPU_TARGETS MATCHES "gfx942" AND CK_HIP_VERSION_MAJOR GREATER_EQUAL 6 AND CK_HIP_VERSION_MINOR GREATER_EQUAL 2) # smfmac needs ROCm6.2
260
261
    add_subdirectory(smfmac_op)
endif()
carlushuang's avatar
carlushuang committed
262
add_subdirectory(position_embedding)
263
add_subdirectory(scatter_gather)