Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@ via github releases)
4. Run `make install` in order to globally install the library and the binary
of msolve.

Note on SIMD instructions
=========================

On x86-64, msolve contains AVX2 and AVX-512 variants of its linear algebra
kernels and chooses the best one supported by the CPU at runtime. Thus the
binaries run on any x86-64 CPU, independently of the CPU of the build machine.
If msolve is only used on the machine it is built on, adding `-march=native` to
CFLAGS lets the compiler optimize the remaining code for this CPU as well.

Note to macOS users
===================

Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
AUTOMAKE_OPTIONS = color-tests
SUBDIRS = src/usolve src/fglm src/neogb src/msolve

AM_CFLAGS = $(SIMD_FLAGS) $(CPUEXT_FLAGS) $(OPENMP_CFLAGS)
AM_CFLAGS = $(OPENMP_CFLAGS)
LDADD = src/neogb/libneogb.la src/fglm/libfglm.la src/usolve/libusolve.la

bin_PROGRAMS = msolve
Expand Down
48 changes: 47 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,53 @@ AC_TYPE_UINT8_T


AX_COUNT_CPUS
AX_EXT

# AVX2 and AVX-512 kernels are compiled whenever the compiler supports them
# and are selected at runtime depending on the CPU msolve runs on, see
# src/msolve/cpu_features.h. Thus the binaries do not depend on the CPU of
# the build machine.
case $host_cpu in
x86_64*|amd64*)
AC_CACHE_CHECK([whether $CC can build AVX2 kernels],
[msolve_cv_avx2_kernels],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <immintrin.h>
__attribute__((target("avx2")))
static long long f(long long x)
{
__m256i v = _mm256_set1_epi64x(x);
v = _mm256_add_epi64(_mm256_mul_epu32(v, v), _mm256_cmpgt_epi64(v, v));
return _mm256_extract_epi64(v, 0);
}]], [[return __builtin_cpu_supports("avx2") ? (int)f(3) : 0;]])],
[msolve_cv_avx2_kernels=yes],
[msolve_cv_avx2_kernels=no])])
if test "x$msolve_cv_avx2_kernels" = xyes; then
AC_DEFINE([HAVE_AVX2_KERNELS], [1],
[Define to 1 if AVX2 kernels are built (selected at runtime).])
fi

AC_CACHE_CHECK([whether $CC can build AVX-512 kernels],
[msolve_cv_avx512_kernels],
[AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <immintrin.h>
__attribute__((target("avx512f,avx512bw")))
static long long f(long long x)
{
__m512i v = _mm512_set1_epi64(x);
__mmask8 m = _mm512_cmpgt_epi64_mask(v, _mm512_setzero_si512());
v = _mm512_mask_add_epi64(v, m, v, _mm512_mullo_epi16(v, v));
return _mm512_reduce_add_epi64(v);
}]], [[return __builtin_cpu_supports("avx512f")
&& __builtin_cpu_supports("avx512bw") ? (int)f(3) : 0;]])],
[msolve_cv_avx512_kernels=yes],
[msolve_cv_avx512_kernels=no])])
if test "x$msolve_cv_avx512_kernels" = xyes; then
AC_DEFINE([HAVE_AVX512_KERNELS], [1],
[Define to 1 if AVX-512 kernels are built (selected at runtime).])
fi
;;
esac

AX_GCC_BUILTIN([__builtin_constant_p])
AX_GCC_BUILTIN([__builtin_clzll])
AX_GCC_BUILTIN([__builtin_clzl])
Expand Down
53 changes: 0 additions & 53 deletions m4/ax_check_compile_flag.m4

This file was deleted.

64 changes: 0 additions & 64 deletions m4/ax_cpu_vendor.m4

This file was deleted.

Loading
Loading