CMakeLists.txt 9.03 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)

Chao Liu's avatar
Chao Liu committed
10
11
function(add_test_executable TEST_NAME)
    message("adding test ${TEST_NAME}")
12
13
    set(result 1)
    if(DEFINED DTYPES)
14
15
        foreach(source IN LISTS ARGN)
            set(test 0)
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
            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()
37
38
39
            if(test EQUAL 1)
                message("removing test ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
40
41
            endif()
        endforeach()
42
    endif()
43

44
    set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS})
45

46
    foreach(source IN LISTS ARGN)
47
48
49
50
51
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
52
    foreach(source IN LISTS ARGN)
53
        if(NOT TEST_TARGETS MATCHES "gfx9" AND source MATCHES "xdl")
54
55
56
57
58
            message("removing xdl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
    foreach(source IN LISTS ARGN)
59
	if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma")
60
61
62
63
            message("removing wmma test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
64
65
    #only continue if there are some source files left on the list
    if(ARGN)
66
        if(ARGN MATCHES "_xdl")
67
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
68
        elseif(ARGN MATCHES "_wmma")
illsilin's avatar
illsilin committed
69
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030 gfx950)
70
        elseif(ARGN MATCHES "_smfmac")
71
             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)
72
73
        endif()
        set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)
74
        add_executable(${TEST_NAME} ${ARGN})
75
        set_property(TARGET ${TEST_NAME} PROPERTY HIP_ARCHITECTURES ${TEST_TARGETS} )
76
        target_link_libraries(${TEST_NAME} PRIVATE getopt::getopt)
77
78
79
80
81
82
83
        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}")
84
    set(result ${result} PARENT_SCOPE)
85
endfunction()
86
87
88

function(add_gtest_executable TEST_NAME)
    message("adding gtest ${TEST_NAME}")
89
90
    set(result 1)
    if(DEFINED DTYPES)
91
92
        foreach(source IN LISTS ARGN)
            set(test 0)
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
            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()
114
115
116
            if(test EQUAL 1)
                message("removing gtest ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
117
118
119
            endif()
        endforeach()
    endif()
120

121
    set(TEST_TARGETS ${SUPPORTED_GPU_TARGETS})
122

123
124
125
126
    foreach(source IN LISTS ARGN)
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
127
128
        endif()
    endforeach()
129

130
    foreach(source IN LISTS ARGN)
131
        if(NOT TEST_TARGETS MATCHES "gfx9" AND source MATCHES "xdl")
132
133
134
135
            message("removing xdl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
136
137
138
139
140
141
142
143

    foreach(source IN LISTS ARGN)
    if(NOT TEST_TARGETS MATCHES "gfx95" AND source MATCHES "mx_")
        message("removing microscaling test ${source} ")
        list(REMOVE_ITEM ARGN "${source}")
    endif()
    endforeach()

144
    foreach(source IN LISTS ARGN)
145
	if(NOT TEST_TARGETS MATCHES "gfx11" AND NOT TEST_TARGETS MATCHES "gfx12" AND source MATCHES "wmma")
146
147
            message("removing wmma test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
148
149
        endif()
    endforeach()
150

151
152
    #only continue if there are some source files left on the list
    if(ARGN)
153
        if(ARGN MATCHES "_xdl")
154
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx1030 gfx1100 gfx1101 gfx1102 gfx1103 gfx1200 gfx1201 gfx10.3-generic gfx11-generic gfx12-generic)
155
        elseif(ARGN MATCHES "_wmma")
illsilin's avatar
illsilin committed
156
             list(REMOVE_ITEM TEST_TARGETS gfx900 gfx906 gfx906:xnack- gfx908:xnack+ gfx908:xnack- gfx90a:xnack+ gfx90a:xnack- gfx908 gfx90a gfx940 gfx941 gfx942 gfx1030 gfx950)
157
        elseif(ARGN MATCHES "_smfmac")
158
             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)
159
160
        endif()
        set_source_files_properties(${ARGN} PROPERTIES LANGUAGE HIP)
161
        add_executable(${TEST_NAME} ${ARGN})
162
        set_property(TARGET ${TEST_NAME} PROPERTY HIP_ARCHITECTURES ${TEST_TARGETS} )
163
164
165
166
167
        add_dependencies(tests ${TEST_NAME})
        add_dependencies(check ${TEST_NAME})

        # suppress gtest warnings
        target_compile_options(${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef)
168
        target_link_libraries(${TEST_NAME} PRIVATE gtest_main getopt::getopt)
169
170
171
172
173
        add_test(NAME ${TEST_NAME} COMMAND $<TARGET_FILE:${TEST_NAME}>)
        rocm_install(TARGETS ${TEST_NAME} COMPONENT tests)
        set(result 0)
    endif()
    #message("add_gtest returns ${result}")
174
    set(result ${result} PARENT_SCOPE)
175
endfunction()
176

177
add_compile_options(-Wno-c++20-extensions)
178
add_subdirectory(ck_tile)
Chao Liu's avatar
Chao Liu committed
179
180
181
182
183
add_subdirectory(magic_number_division)
add_subdirectory(space_filling_curve)
add_subdirectory(conv_util)
add_subdirectory(reference_conv_fwd)
add_subdirectory(gemm)
184
add_subdirectory(gemm_add)
185
add_subdirectory(gemm_layernorm)
Chao Liu's avatar
Chao Liu committed
186
add_subdirectory(gemm_split_k)
187
add_subdirectory(gemm_universal)
Chao Liu's avatar
Chao Liu committed
188
189
add_subdirectory(gemm_reduce)
add_subdirectory(batched_gemm)
190
add_subdirectory(batched_gemm_reduce)
Anthony Chang's avatar
Anthony Chang committed
191
add_subdirectory(batched_gemm_gemm)
Anthony Chang's avatar
Anthony Chang committed
192
add_subdirectory(batched_gemm_softmax_gemm)
193
add_subdirectory(batched_gemm_softmax_gemm_permute)
Chao Liu's avatar
Chao Liu committed
194
add_subdirectory(grouped_gemm)
195
add_subdirectory(reduce)
196
add_subdirectory(convnd_fwd)
JD's avatar
JD committed
197
add_subdirectory(convnd_bwd_data)
198
add_subdirectory(grouped_convnd_fwd)
199
add_subdirectory(grouped_convnd_bwd_weight)
200
add_subdirectory(block_to_ctile_map)
201
add_subdirectory(softmax)
rocking's avatar
rocking committed
202
add_subdirectory(normalization_fwd)
203
add_subdirectory(normalization_bwd_data)
204
add_subdirectory(normalization_bwd_gamma_beta)
Adam Osewski's avatar
Adam Osewski committed
205
add_subdirectory(data_type)
206
add_subdirectory(elementwise_normalization)
207
add_subdirectory(batchnorm)
208
add_subdirectory(contraction)
209
add_subdirectory(pool)
210
add_subdirectory(batched_gemm_multi_d)
211
add_subdirectory(grouped_convnd_bwd_data)
212
add_subdirectory(conv_tensor_rearrange)
arai713's avatar
arai713 committed
213
add_subdirectory(transpose)
arai713's avatar
arai713 committed
214
add_subdirectory(permute_scale)
215
add_subdirectory(wrapper)
216
if(SUPPORTED_GPU_TARGETS MATCHES "gfx11")
217
218
    add_subdirectory(wmma_op)
endif()
illsilin's avatar
illsilin committed
219
if(SUPPORTED_GPU_TARGETS MATCHES "gfx942" OR SUPPORTED_GPU_TARGETS MATCHES "gfx950") # smfmac needs ROCm6.2
220
221
    add_subdirectory(smfmac_op)
endif()
222
223
224
if(SUPPORTED_GPU_TARGETS MATCHES "gfx950") 
    add_subdirectory(mx_mfma_op)
endif()
carlushuang's avatar
carlushuang committed
225
add_subdirectory(position_embedding)
226
add_subdirectory(scatter_gather)