# SPDX-FileCopyrightText: The Eigen Authors
# SPDX-License-Identifier: MPL-2.0

if(BLAS_FOUND)
  # HAVE_BLAS adds BM_BlasGemm, the reference sgemm_/dgemm_ on the same grid.
  eigen_add_benchmark(bench_gemm bench_gemm.cpp
      LIBRARIES ${BLAS_LIBRARIES} DEFINITIONS HAVE_BLAS)
  eigen_add_benchmark(bench_gemm_double bench_gemm.cpp
      LIBRARIES ${BLAS_LIBRARIES} DEFINITIONS HAVE_BLAS SCALAR=double)
else()
  eigen_add_benchmark(bench_gemm bench_gemm.cpp)
  eigen_add_benchmark(bench_gemm_double bench_gemm.cpp DEFINITIONS SCALAR=double)
endif()
eigen_add_benchmark(bench_gemm_complex bench_gemm.cpp
    DEFINITIONS "SCALAR=std::complex<float>" EIGEN_BENCH_COMPLEX_SCALAR)
eigen_add_benchmark(bench_gemm_complex_double bench_gemm.cpp
    DEFINITIONS "SCALAR=std::complex<double>" EIGEN_BENCH_COMPLEX_SCALAR)
eigen_add_benchmark(bench_gemm_threads bench_gemm_threads.cpp)
eigen_add_benchmark(bench_gemm_threads_double bench_gemm_threads.cpp DEFINITIONS SCALAR=double)
eigen_add_benchmark(bench_gemm_scaled bench_gemm_scaled.cpp)
eigen_add_benchmark(bench_gemm_scaled_double bench_gemm_scaled.cpp DEFINITIONS SCALAR=double)
eigen_add_benchmark(bench_gemm_scaled_complex bench_gemm_scaled.cpp DEFINITIONS "SCALAR=std::complex<float>")
eigen_add_benchmark(bench_gemm_scaled_complex_double bench_gemm_scaled.cpp DEFINITIONS "SCALAR=std::complex<double>")
eigen_add_benchmark(bench_gemv bench_gemv.cpp)
eigen_add_benchmark(bench_vecadd bench_vecadd.cpp)
eigen_add_benchmark(bench_trsm bench_trsm.cpp)
eigen_add_benchmark(bench_trsm_packet bench_trsm_packet.cpp)
eigen_add_benchmark(bench_reverse bench_reverse.cpp)
eigen_add_benchmark(bench_permutation_product bench_permutation_product.cpp)
eigen_add_benchmark(bench_permutation_transposition bench_permutation_transposition.cpp)
eigen_add_benchmark(bench_move_semantics bench_move_semantics.cpp)
eigen_add_benchmark(bench_reductions bench_reductions.cpp)
eigen_add_benchmark(bench_vectorwise_norm bench_vectorwise_norm.cpp)
eigen_add_benchmark(bench_complex_components bench_complex_components.cpp)
eigen_add_benchmark(bench_unary_pow bench_unary_pow.cpp)
eigen_add_benchmark(bench_pgather bench_pgather.cpp)
eigen_add_benchmark(bench_boolean_reductions bench_boolean_reductions.cpp)
# Separate operations and storage families to avoid moving unrelated hot loops.
foreach(operation All Any Count)
  string(TOLOWER ${operation} operation_name)
  eigen_add_benchmark(bench_visitor_${operation_name} bench_visitor.cpp
      DEFINITIONS EIGEN_BENCH_VISITOR_OP=${operation} EIGEN_BENCH_VISITOR_STRIDED=false)
  eigen_add_benchmark(bench_visitor_${operation_name}_strided bench_visitor.cpp
      DEFINITIONS EIGEN_BENCH_VISITOR_OP=${operation} EIGEN_BENCH_VISITOR_STRIDED=true)
endforeach()
eigen_add_benchmark(bench_count bench_count.cpp)
eigen_add_benchmark(bench_matrix_checks bench_matrix_checks.cpp)
eigen_add_benchmark(bench_dot bench_dot.cpp)
eigen_add_benchmark(bench_stable_norm bench_stable_norm.cpp)
eigen_add_benchmark(bench_approx_comparisons bench_approx_comparisons.cpp)
eigen_add_benchmark(bench_selfadjoint_l1norm bench_selfadjoint_l1norm.cpp)
eigen_add_benchmark(bench_cwise_math bench_cwise_math.cpp)
eigen_add_benchmark(bench_complex_sqrt bench_complex_sqrt.cpp)
eigen_add_benchmark(bench_cast bench_cast.cpp)
eigen_add_benchmark(bench_complex_log bench_complex_log.cpp)
eigen_add_benchmark(bench_int64_ops bench_int64_ops.cpp)
eigen_add_benchmark(bench_packet_ops bench_packet_ops.cpp)
eigen_add_benchmark(bench_broadcasting bench_broadcasting.cpp)
eigen_add_benchmark(bench_block_ops bench_block_ops.cpp)
eigen_add_benchmark(bench_block_coeffwise bench_block_coeffwise.cpp)
eigen_add_benchmark(bench_map bench_map.cpp)
eigen_add_benchmark(bench_reshaped bench_reshaped.cpp)
eigen_add_benchmark(bench_diagonal bench_diagonal.cpp)
eigen_add_benchmark(bench_diagonal_move bench_diagonal_move.cpp)
eigen_add_benchmark(bench_triangular_product bench_triangular_product.cpp)
eigen_add_benchmark(bench_selfadjoint_product bench_selfadjoint_product.cpp)
eigen_add_benchmark(bench_symv bench_symv.cpp)
eigen_add_benchmark(bench_trmv bench_trmv.cpp)
eigen_add_benchmark(bench_syr bench_syr.cpp)
eigen_add_benchmark(bench_syr2 bench_syr2.cpp)
eigen_add_benchmark(bench_construction bench_construction.cpp)
eigen_add_benchmark(bench_fixed_size bench_fixed_size.cpp)
eigen_add_benchmark(bench_fixed_size_double bench_fixed_size.cpp DEFINITIONS SCALAR=double)
eigen_add_benchmark(bench_fixed_size_complex bench_fixed_size.cpp DEFINITIONS "SCALAR=std::complex<float>")
eigen_add_benchmark(bench_fixed_size_complex_double bench_fixed_size.cpp DEFINITIONS "SCALAR=std::complex<double>")
# EIGEN_BENCH_FORCE_GEMM: the same sweep with every product on the GEMM path, to compare against the default.
eigen_add_benchmark(bench_fixed_size_gemm bench_fixed_size.cpp DEFINITIONS EIGEN_BENCH_FORCE_GEMM)
eigen_add_benchmark(bench_fixed_size_gemm_double bench_fixed_size.cpp DEFINITIONS EIGEN_BENCH_FORCE_GEMM SCALAR=double)
eigen_add_benchmark(bench_fixed_size_gemm_complex bench_fixed_size.cpp
    DEFINITIONS EIGEN_BENCH_FORCE_GEMM "SCALAR=std::complex<float>")
eigen_add_benchmark(bench_fixed_size_gemm_complex_double bench_fixed_size.cpp
    DEFINITIONS EIGEN_BENCH_FORCE_GEMM "SCALAR=std::complex<double>")
eigen_add_benchmark(bench_small_matrix bench_small_matrix.cpp)
eigen_add_benchmark(bench_small_dynamic_product bench_small_dynamic_product.cpp)
eigen_add_benchmark(bench_scaled_product bench_scaled_product.cpp)
eigen_add_benchmark(bench_outer_product bench_outer_product.cpp)
eigen_add_benchmark(bench_selfadjoint_diagonal bench_selfadjoint_diagonal.cpp)
eigen_add_benchmark(bench_segment_tail bench_segment_tail.cpp)
eigen_add_benchmark(bench_boolean_ops bench_boolean_ops.cpp)
eigen_add_benchmark(bench_boolean_ops_novec bench_boolean_ops.cpp DEFINITIONS EIGEN_DONT_VECTORIZE)
