# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
# SPDX-License-Identifier: MIT

if(GPU_TARGETS MATCHES "gfx94|gfx95|gfx90a|gfx125")
  add_executable(tile_example_gemm_basic gemm_basic.cpp)
  add_executable(tile_example_gemm_universal universal_gemm.cpp)
  add_executable(tile_example_gemm_weight_preshuffle gemm_weight_preshuffle.cpp)
  add_executable(tile_example_gemm_reduce gemm_splitk_two_stage_reduce.cpp)
  add_executable(tile_example_gemm_splitk_two_stage gemm_splitk_two_stage.cpp)
  if(GPU_TARGETS MATCHES "gfx125")
    add_executable(tile_example_gemm_mixed_prec gemm_mixed_prec.cpp)
    add_executable(tile_example_gemm_tdm_data_cache_prefetch gemm_tdm_data_cache_prefetch.cpp)
    add_executable(tile_example_gemm_weight_preshuffle_tdm_data_cache_prefetch gemm_weight_preshuffle_tdm_data_cache_prefetch.cpp)
    add_executable(tile_example_gemm_universal_cluster_launch universal_gemm.cpp)
  endif()
  set(EXAMPLE_GEMM_COMPILE_OPTIONS)
  set(EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS)
  if(CK_USE_OCP_FP8)
    list(APPEND EXAMPLE_GEMM_COMPILE_OPTIONS -DCK_TILE_USE_OCP_FP8)
  endif()
  list(APPEND EXAMPLE_GEMM_COMPILE_OPTIONS -mllvm -enable-noalias-to-md-conversion=0)
  list(APPEND EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS -Wno-unused-local-typedef)
  list(APPEND EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS -Wno-gnu-line-marker)
  # list(APPEND EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS --save-temps)
  list(APPEND EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS "SHELL: -mllvm -greedy-reverse-local-assignment=1 -mllvm -enable-noalias-to-md-conversion=1")
  target_compile_options(tile_example_gemm_basic PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
  target_compile_options(tile_example_gemm_universal PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
  target_compile_options(tile_example_gemm_weight_preshuffle PRIVATE ${EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS})
  target_compile_options(tile_example_gemm_reduce PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
  target_compile_options(tile_example_gemm_splitk_two_stage PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
  if(GPU_TARGETS MATCHES "gfx125")
    target_compile_options(tile_example_gemm_mixed_prec PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
    target_compile_options(tile_example_gemm_tdm_data_cache_prefetch PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
    target_compile_options(tile_example_gemm_weight_preshuffle_tdm_data_cache_prefetch PRIVATE ${EXAMPLE_WEIGHT_PRESHUFFLE_COMPILE_OPTIONS})
    target_compile_options(tile_example_gemm_universal_cluster_launch PRIVATE ${EXAMPLE_GEMM_COMPILE_OPTIONS})
    target_compile_definitions(tile_example_gemm_universal_cluster_launch PRIVATE CLUSTER_LAUNCH_ENABLED=1)
  endif()
endif()
