Skip to content

Commit

Permalink
Add check during configuration for strongly ordered cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
albinahlback committed Dec 28, 2023
1 parent 07edfb3 commit 5dddefd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CMake/cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#cmakedefine FLINT_HAVE_FFT_SMALL

#cmakedefine01 FLINT_KNOW_STRONG_ORDER

#ifdef _MSC_VER
# if defined(FLINT_BUILD_DLL)
# define FLINT_DLL __declspec(dllexport)
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ endif()
option(BUILD_SHARED_LIBS "Build shared libs" on)
option(WITH_NTL "Build tests for NTL interface or not" off)

# Check if strongly ordered memory
set(STRONGLY_ORDERED_CPUS x86_64 x86 i386 i586 AMD64)
if(CMAKE_SYSTEM_PROCESSOR IN_LIST STRONGLY_ORDERED_CPUS)
message(STATUS "Checking if system is strongly ordered - yes")
set(FLINT_KNOW_STRONG_ORDER ON)
else()
message(STATUS "Checking if system is strongly ordered - unsure")
set(FLINT_KNOW_STRONG_ORDER OFF)
endif()

# Find dependencies
find_package(PkgConfig REQUIRED)
pkg_check_modules(GMP REQUIRED IMPORTED_TARGET gmp>=6.2.1)
Expand Down
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,24 @@ then
fi
AC_SUBST(LDCONFIG)

dnl FIXME: Improve this check to include more processors.
AC_MSG_CHECKING([if memory is strongly-ordered])
case "$host_cpu" in
x86_64|x86|i386|i586)
flint_know_strong_order="yes"
AC_MSG_CHECKING([yes])
;;
*)
flint_know_strong_order="no"
AC_MSG_CHECKING([unsure])
;;
esac

if test "$flint_know_strong_order" = "yes";
then
AC_DEFINE(FLINT_KNOW_STRONG_ORDER,1,[Define if system is strongly ordered])]
fi

################################################################################
# check headers
################################################################################
Expand Down
3 changes: 3 additions & 0 deletions src/flint-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
/* Define if system is big endian. */
#undef FLINT_BIG_ENDIAN

/* Define if system is strongly ordered */
#undef FLINT_KNOW_STRONG_ORDER

/* Define if system has AVX2 */
#undef FLINT_HAVE_AVX2

Expand Down

0 comments on commit 5dddefd

Please sign in to comment.