CMakeLists.txt 5.76 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
        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
43
    endif()
    foreach(source IN LISTS ARGN)
44
45
46
47
48
49
50
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})
        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}")
60
    set(result ${result} PARENT_SCOPE)
Chao Liu's avatar
Chao Liu committed
61
endfunction(add_test_executable TEST_NAME)
62

63
64
65
66
include(GoogleTest)

function(add_gtest_executable TEST_NAME)
    message("adding gtest ${TEST_NAME}")
67
68
    set(result 1)
    if(DEFINED DTYPES)
69
70
        foreach(source IN LISTS ARGN)
            set(test 0)
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
            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()
92
93
94
            if(test EQUAL 1)
                message("removing gtest ${source} ")
                list(REMOVE_ITEM ARGN "${source}")
95
96
97
98
99
100
101
102
103
104
105
106
107
108
            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})
109

110
111
112
113
114
115
116
117
        # 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}")
118
    set(result ${result} PARENT_SCOPE)
119
120
endfunction(add_gtest_executable TEST_NAME)

Alan Turner's avatar
Alan Turner committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
if(CK_BUILD_JIT_LIB)
    add_subdirectory(jit_library)
else()
    add_subdirectory(magic_number_division)
    add_subdirectory(space_filling_curve)
    add_subdirectory(conv_util)
    add_subdirectory(reference_conv_fwd)
    add_subdirectory(gemm)
    add_subdirectory(gemm_layernorm)
    add_subdirectory(gemm_split_k)
    add_subdirectory(gemm_reduce)
    add_subdirectory(batched_gemm)
    add_subdirectory(batched_gemm_reduce)
    add_subdirectory(batched_gemm_gemm)
    add_subdirectory(batched_gemm_softmax_gemm)
    add_subdirectory(batched_gemm_softmax_gemm_permute)
    add_subdirectory(grouped_gemm)
    add_subdirectory(reduce)
    add_subdirectory(convnd_fwd)
    add_subdirectory(convnd_bwd_data)
    add_subdirectory(grouped_convnd_fwd)
    add_subdirectory(grouped_convnd_bwd_weight)
    add_subdirectory(block_to_ctile_map)
    add_subdirectory(softmax)
145
    add_subdirectory(normalization_fwd)
Alan Turner's avatar
Alan Turner committed
146
147
148
149
    add_subdirectory(data_type)
    add_subdirectory(elementwise_normalization)
    add_subdirectory(batchnorm)
    add_subdirectory(contraction)
150
    add_subdirectory(pool)
151
152
    add_subdirectory(batched_gemm_multi_d)
    add_subdirectory(grouped_convnd_bwd_data)
153
154
    add_subdirectory(conv_tensor_rearrange)
    add_subdirectory(transpose)
Alan Turner's avatar
Alan Turner committed
155
156
157
    if(GPU_TARGETS MATCHES "gfx11")
        add_subdirectory(wmma_op)
    endif()
158
endif()