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

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

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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        foreach(source IN LISTS ARGN)
            set(test 0)
            foreach(type IN LISTS DTYPES)
                if(type MATCHES "fp16")
                    set(type1 "_f16")
                elseif(type MATCHES "fp32")
                    set(type1 "_f32")
                elseif(type MATCHES "fp8")
                    set(type1 "_f8")
                elseif(type MATCHES "bf16")
                    set(type1 "_b16")
                elseif(type MATCHES "fp64")
                    set(type1 "_f64")
                elseif(type MATCHES "int8")
                    set(type1 "_i8")
                endif()
                if("${source}" MATCHES "${type}" OR "${source}" MATCHES "${type1}")
                    #if filename matches any selected type, exit type loop and do no exclude the file from the list
                    set(test 0)
                    break()
                elseif((source MATCHES "fp8" OR source MATCHES "fp32" OR source MATCHES "fp64" OR source MATCHES "bf16" OR source MATCHES "int8" OR source MATCHES "fp16" OR
                    source MATCHES "_f8" OR source MATCHES "_f32" OR source MATCHES "_f64" OR source MATCHES "_i8" OR source MATCHES "_f16" OR source MATCHES "_b16") AND
                    NOT(source MATCHES type OR source MATCHES type1))
37
38
                    #if filename contains a type which doesn't match any selected type, mark it for removal
                    set(test 1)
39
40
41
42
43
                endif()
            endforeach()
            if(test EQUAL 1)
                message("removing test ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
44
45
            endif()
        endforeach()
46
47
    endif()
    foreach(source IN LISTS ARGN)
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()

    #only continue if there are some source files left on the list
    if(ARGN)
        add_executable(${TEST_NAME} ${ARGN})
        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}")
64
    set(result ${result} PARENT_SCOPE)
Chao Liu's avatar
Chao Liu committed
65
endfunction(add_test_executable TEST_NAME)
66

67
68
69
70
include(GoogleTest)

function(add_gtest_executable TEST_NAME)
    message("adding gtest ${TEST_NAME}")
71
72
    set(result 1)
    if(DEFINED DTYPES)
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
        foreach(source IN LISTS ARGN)
            set(test 0)
            foreach(type IN LISTS DTYPES)
                if(type MATCHES "fp16")
                    set(type1 "_f16")
                elseif(type MATCHES "fp32")
                    set(type1 "_f32")
                elseif(type MATCHES "fp8")
                    set(type1 "_f8")
                elseif(type MATCHES "bf16")
                    set(type1 "_b16")
                elseif(type MATCHES "fp64")
                    set(type1 "_f64")
                elseif(type MATCHES "int8")
                    set(type1 "_i8")
                endif()
                if("${source}" MATCHES "${type}" OR "${source}" MATCHES "${type1}")
                    #if filename matches any selected type, exit type loop and do no exclude the file from the list
                    set(test 0)
                    break()
                elseif((source MATCHES "fp8" OR source MATCHES "fp32" OR source MATCHES "fp64" OR source MATCHES "bf16" OR source MATCHES "int8" OR source MATCHES "fp16" OR
                    source MATCHES "_f8" OR source MATCHES "_f32" OR source MATCHES "_f64" OR source MATCHES "_i8" OR source MATCHES "_f16" OR source MATCHES "_b16") AND
                    NOT(source MATCHES type OR source MATCHES type1))
96
97
                    #if filename contains a type which doesn't match any selected type, mark it for removal
                    set(test 1)
98
99
100
101
102
                endif()
            endforeach()
            if(test EQUAL 1)
                message("removing gtest ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
            endif()
        endforeach()
    endif()
    foreach(source IN LISTS ARGN)
        if(NOT DEFINED DL_KERNELS AND source MATCHES "_dl")
            message("removing dl test ${source} ")
            list(REMOVE_ITEM ARGN "${source}")
        endif()
    endforeach()
    #only continue if there are some source files left on the list
    if(ARGN)
        add_executable(${TEST_NAME} ${ARGN})
        add_dependencies(tests ${TEST_NAME})
        add_dependencies(check ${TEST_NAME})

        # suppress gtest warnings
        target_compile_options(${TEST_NAME} PRIVATE -Wno-global-constructors -Wno-undef)
        target_link_libraries(${TEST_NAME} PRIVATE gtest_main)
        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}")
126
    set(result ${result} PARENT_SCOPE)
127
128
endfunction(add_gtest_executable TEST_NAME)

Chao Liu's avatar
Chao Liu committed
129
130
131
132
133
add_subdirectory(magic_number_division)
add_subdirectory(space_filling_curve)
add_subdirectory(conv_util)
add_subdirectory(reference_conv_fwd)
add_subdirectory(gemm)
134
add_subdirectory(gemm_layernorm)
Chao Liu's avatar
Chao Liu committed
135
add_subdirectory(gemm_split_k)
Chao Liu's avatar
Chao Liu committed
136
137
add_subdirectory(gemm_reduce)
add_subdirectory(batched_gemm)
138
add_subdirectory(batched_gemm_reduce)
Anthony Chang's avatar
Anthony Chang committed
139
add_subdirectory(batched_gemm_gemm)
Anthony Chang's avatar
Anthony Chang committed
140
add_subdirectory(batched_gemm_softmax_gemm)
141
add_subdirectory(batched_gemm_softmax_gemm_permute)
Chao Liu's avatar
Chao Liu committed
142
add_subdirectory(grouped_gemm)
143
add_subdirectory(reduce)
144
add_subdirectory(convnd_fwd)
JD's avatar
JD committed
145
add_subdirectory(convnd_bwd_data)
146
add_subdirectory(grouped_convnd_fwd)
147
add_subdirectory(grouped_convnd_bwd_weight)
148
add_subdirectory(block_to_ctile_map)
149
add_subdirectory(softmax)
150
add_subdirectory(normalization)
Adam Osewski's avatar
Adam Osewski committed
151
add_subdirectory(data_type)
152
add_subdirectory(elementwise_normalization)
153
add_subdirectory(batchnorm)
154
add_subdirectory(contraction)
155
add_subdirectory(pool)
156
add_subdirectory(batched_gemm_multi_d)
157
add_subdirectory(grouped_convnd_bwd_data)
158
add_subdirectory(conv_tensor_rearrange)
159
if(GPU_TARGETS MATCHES "gfx11")
160
161
    add_subdirectory(wmma_op)
endif()