cmake_minimum_required(VERSION 3.15)
project(ck_app LANGUAGES CXX)

if (DTYPES)
    add_definitions(-DDTYPES)
    if (DTYPES MATCHES "int8")
        add_definitions(-DCK_ENABLE_INT8)
        if(NOT DEFINED ${CK_ENABLE_INT8})
            set(CK_ENABLE_INT8 "ON")
        endif()
    endif()
    if (DTYPES MATCHES "fp8")
        add_definitions(-DCK_ENABLE_FP8)
        if(NOT DEFINED ${CK_ENABLE_FP8})
            set(CK_ENABLE_FP8 "ON")
        endif()
    endif()
    if (DTYPES MATCHES "fp16")
        add_definitions(-DCK_ENABLE_FP16)
        if(NOT DEFINED ${CK_ENABLE_FP16})
            set(CK_ENABLE_FP16 "ON")
        endif()
    endif()
    if (DTYPES MATCHES "fp32")
        add_definitions(-DCK_ENABLE_FP32)
        if(NOT DEFINED ${CK_ENABLE_FP32})
            set(CK_ENABLE_FP32 "ON")
        endif()
    endif()
    if (DTYPES MATCHES "fp64")
        add_definitions(-DCK_ENABLE_FP64)
        if(NOT DEFINED ${CK_ENABLE_FP64})
            set(CK_ENABLE_FP64 "ON")
        endif()
    endif()
    if (DTYPES MATCHES "bf16")
        add_definitions(-DCK_ENABLE_BF16)
        if(NOT DEFINED ${CK_ENABLE_BF16})
            set(CK_ENABLE_BF16 "ON")
        endif()
    endif()
    message("DTYPES macro set to ${DTYPES}")
else()
    add_definitions(-DCK_ENABLE_INT8 -DCK_ENABLE_FP8 -DCK_ENABLE_FP16 -DCK_ENABLE_FP32 -DCK_ENABLE_FP64 -DCK_ENABLE_BF16)
    if(NOT DEFINED ${CK_ENABLE_ALL_DTYPES})
        set(CK_ENABLE_ALL_DTYPES "ON")
    endif()
endif()

find_package(composable_kernel COMPONENTS device_operations)
find_package(hip REQUIRED PATHS /opt/rocm /opt/rocm/llvm $ENV{HIP_PATH} $ENV{ROCM_PATH})
message(STATUS "Build with HIP ${hip_VERSION}")

add_subdirectory(01_gemm)
add_subdirectory(02_gemm_add_add_fastgelu)
add_subdirectory(03_gemm_layernorm)
add_subdirectory(04_contraction)
add_subdirectory(05_layernorm)
add_subdirectory(06_softmax)
add_subdirectory(07_grouped_convnd_fwd)
add_subdirectory(08_fused_attention)
add_subdirectory(09_quantization)
add_subdirectory(10_grouped_convnd_bwd_data)
add_subdirectory(11_grouped_conv_bwd_weight)
add_subdirectory(12_elementwise_normalization)
add_subdirectory(13_batchnorm)
add_subdirectory(14_instance_id)
add_subdirectory(15_convnd_bwd_data)
add_subdirectory(15_gemm_add_multiply)
add_subdirectory(15_reduce)
add_subdirectory(16_convnd_fwd)
add_subdirectory(17_grouped_gemm_fastgelu)
add_subdirectory(18_groupnorm)
add_subdirectory(19_pool)
add_subdirectory(20_splitk_gemm)
add_subdirectory(21_grouped_gemm_bias)
add_subdirectory(22_grouped_gemm)
add_subdirectory(22_im2col_col2im)
