CMakeLists.txt 6.44 KB
Newer Older
Artur Wojcik's avatar
Artur Wojcik committed
1
2
3
# SPDX-License-Identifier: MIT
# Copyright (c) 2018-2022, Advanced Micro Devices, Inc. All rights reserved.

4
include_directories(BEFORE
Adam Osewski's avatar
Adam Osewski committed
5
    ${PROJECT_SOURCE_DIR}/
6
    ${PROJECT_SOURCE_DIR}/profiler/include
7
8
)

Artur Wojcik's avatar
Artur Wojcik committed
9
include(GTest)
JD's avatar
JD committed
10

11
12
add_custom_target(tests)

Chao Liu's avatar
Chao Liu committed
13
14
function(add_test_executable TEST_NAME)
    message("adding test ${TEST_NAME}")
15
16
    set(result 1)
    if(DEFINED DTYPES)
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
        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))
40
41
                    #if filename contains a type which doesn't match any selected type, mark it for removal
                    set(test 1)
42
43
44
45
46
                endif()
            endforeach()
            if(test EQUAL 1)
                message("removing test ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
47
48
            endif()
        endforeach()
49
50
    endif()
    foreach(source IN LISTS ARGN)
51
52
53
54
55
56
57
58
59
        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})
Artur Wojcik's avatar
Artur Wojcik committed
60
        target_link_libraries(${TEST_NAME} PRIVATE getopt::getopt)
61
62
63
64
65
66
67
        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}")
68
    set(result ${result} PARENT_SCOPE)
Artur Wojcik's avatar
Artur Wojcik committed
69
endfunction()
70
71
72

function(add_gtest_executable TEST_NAME)
    message("adding gtest ${TEST_NAME}")
73
74
    set(result 1)
    if(DEFINED DTYPES)
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
        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))
98
99
                    #if filename contains a type which doesn't match any selected type, mark it for removal
                    set(test 1)
100
101
102
103
104
                endif()
            endforeach()
            if(test EQUAL 1)
                message("removing gtest ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
            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)
Artur Wojcik's avatar
Artur Wojcik committed
122
        target_link_libraries(${TEST_NAME} PRIVATE gtest_main getopt::getopt)
123
124
125
126
127
        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}")
128
    set(result ${result} PARENT_SCOPE)
Artur Wojcik's avatar
Artur Wojcik committed
129
endfunction()
130

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