Aocl integration updated

libeigen/eigen!1952
This commit is contained in:
sharad bhaskar
2025-11-24 17:20:42 +00:00
committed by Rasmus Munk Larsen
parent a6630c53c1
commit 8a1083e9bf
8 changed files with 1527 additions and 8 deletions

View File

@@ -71,6 +71,7 @@ endif()
option(EIGEN_BUILD_BTL "Build benchmark suite" OFF)
option(EIGEN_BUILD_SPBENCH "Build sparse benchmark suite" OFF)
option(EIGEN_BUILD_AOCL_BENCH "Build AOCL benchmark" OFF)
# Avoid building docs if included from another project.
# Building documentation requires creating and running executables on the host
# platform. We shouldn't do this if cross-compiling.
@@ -305,17 +306,30 @@ if (EIGEN_IS_BUILDING_)
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
find_package(StandardMathLibrary)
cmake_policy(SET CMP0074 NEW)
find_package(AOCL QUIET)
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "")
if(NOT STANDARD_MATH_LIBRARY_FOUND)
message(FATAL_ERROR
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
else()
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
else()
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
if(AOCL_FOUND)
list(APPEND EIGEN_STANDARD_LIBRARIES_TO_LINK_TO ${AOCL_LIBRARIES})
if(AOCL_INCLUDE_DIRS)
include_directories(${AOCL_INCLUDE_DIRS})
endif()
endif()
if(NOT STANDARD_MATH_LIBRARY_FOUND)
message(FATAL_ERROR
"Can't link to the standard math library. Please report to the Eigen developers, telling them about your platform.")
else()
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO} ${STANDARD_MATH_LIBRARY}")
else()
set(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO "${STANDARD_MATH_LIBRARY}")
endif()
# Clean up any leading/trailing whitespace in the variable to avoid CMP0004 errors
string(STRIP "${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}" EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
endif()
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
message(STATUS "Standard libraries to link to explicitly: ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO}")
else()
@@ -743,6 +757,57 @@ endif()
if(NOT WIN32 AND EIGEN_BUILD_SPBENCH)
add_subdirectory(bench/spbench EXCLUDE_FROM_ALL)
endif()
#--------------------------------------------------------------------------------------#
# AOCL BENCHMARK BUILD SECTION #
#--------------------------------------------------------------------------------------#
if(EIGEN_BUILD_AOCL_BENCH)
# Allow users to override the default architecture
set(EIGEN_AOCL_BENCH_ARCH "znver5" CACHE STRING "Target architecture for AOCL benchmark")
add_executable(benchmark_aocl EXCLUDE_FROM_ALL bench/benchmark_aocl.cpp)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-march=${EIGEN_AOCL_BENCH_ARCH}" COMPILER_SUPPORTS_AOCL_ARCH)
if(COMPILER_SUPPORTS_AOCL_ARCH)
target_compile_options(benchmark_aocl PRIVATE -O3 -Wno-shadow -march=${EIGEN_AOCL_BENCH_ARCH})
else()
message(WARNING "${EIGEN_AOCL_BENCH_ARCH} architecture not supported by compiler")
target_compile_options(benchmark_aocl PRIVATE -O3)
endif()
# Add custom flags if provided
if(EIGEN_AOCL_BENCH_FLAGS)
separate_arguments(CUSTOM_FLAGS NATIVE_COMMAND "${EIGEN_AOCL_BENCH_FLAGS}")
target_compile_options(benchmark_aocl PRIVATE ${CUSTOM_FLAGS})
# Check if OpenMP is requested in custom flags and link it
string(FIND "${EIGEN_AOCL_BENCH_FLAGS}" "-fopenmp" OPENMP_REQUESTED)
if(NOT OPENMP_REQUESTED EQUAL -1)
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
target_link_libraries(benchmark_aocl OpenMP::OpenMP_CXX)
else()
# Generic fallback: let compiler handle OpenMP linking
if(MSVC)
target_compile_options(benchmark_aocl PRIVATE "/openmp")
else()
target_compile_options(benchmark_aocl PRIVATE "-fopenmp")
target_link_options(benchmark_aocl PRIVATE "-fopenmp")
endif()
message(STATUS "Using compiler OpenMP flags as fallback")
endif()
endif()
endif()
target_include_directories(benchmark_aocl PRIVATE ${INCLUDE_INSTALL_DIR})
if(EIGEN_AOCL_BENCH_USE_MT)
target_compile_definitions(benchmark_aocl PRIVATE EIGEN_USE_AOCL_MT)
else()
target_compile_definitions(benchmark_aocl PRIVATE EIGEN_USE_AOCL_ALL)
endif()
target_link_libraries(benchmark_aocl Eigen3::Eigen)
if(EIGEN_STANDARD_LIBRARIES_TO_LINK_TO)
target_link_libraries(benchmark_aocl ${EIGEN_STANDARD_LIBRARIES_TO_LINK_TO})
endif()
endif()
#----------------------------------------------------------------------------------------#
if (EIGEN_BUILD_DEMOS)
add_subdirectory(demos EXCLUDE_FROM_ALL)
@@ -792,6 +857,9 @@ if(PROJECT_IS_TOP_LEVEL)
if (EIGEN_BUILD_LAPACK)
message(STATUS "lapack | Build LAPACK subset library (not the same thing as Eigen)")
endif()
if(EIGEN_BUILD_AOCL_BENCH)
message(STATUS "benchmark_aocl | Build AOCL benchmark executable")
endif()
message(STATUS "------------+--------------------------------------------------------------")
message(STATUS "")
endif()
@@ -799,3 +867,4 @@ endif()
message(STATUS "")
message(STATUS "Configured Eigen ${EIGEN_VERSION_STRING}")
message(STATUS "")