diff --git a/.github/workflows/distcheck.yml b/.github/workflows/distcheck.yml index afa302b..16ed804 100644 --- a/.github/workflows/distcheck.yml +++ b/.github/workflows/distcheck.yml @@ -26,4 +26,33 @@ jobs: run: ASAN_OPTIONS=detect_leaks=0 make -j $JOBS check - name: Distcheck run: make -j $JOBS distcheck + windows: + runs-on: windows-latest + defaults: + run: + shell: msys2 {0} + steps: + - name: Check out + uses: actions/checkout@v4 + - name: Setup MSYS2 + uses: msys2/setup-msys2@v2 + with: + msystem: MINGW64 + update: true + install: >- + mingw-w64-x86_64-gcc + mingw-w64-x86_64-autotools + mingw-w64-x86_64-libtool + mingw-w64-x86_64-pkg-config + autoconf + automake + make + - name: Configure + run: | + autoreconf -i + ./configure --enable-debug + - name: Check + run: make -j $JOBS check + - name: Distcheck + run: make -j $JOBS distcheck \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 9cdf901..750d2c6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,7 @@ AUTOMAKE_OPTIONS = foreign subdir-objects ACLOCAL_AMFLAGS = -I m4 +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir) -iquote$(top_builddir)/m4ri AM_CFLAGS=${SIMD_FLAGS} ${OPENMP_CFLAGS} ${DEBUG_FLAGS} ${LIBPNG_CFLAGS} lib_LTLIBRARIES = libm4ri.la @@ -57,7 +58,7 @@ EXTRA_DIST=m4ri/Doxyfile pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = m4ri.pc -libm4ri_la_LDFLAGS = -version-info @LT_VERSION@ -no-undefined +libm4ri_la_LDFLAGS = -version-info @LT_VERSION@ -no-undefined @M4RI_EXPORT_ALL_SYMBOLS_LDFLAGS@ libm4ri_la_LIBADD = $(LIBPNG_LIBADD) $(LIBM) SUBDIRS = . tests diff --git a/README.md b/README.md index d4812ae..6d6adbe 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ M4RI is a library for fast arithmetic with dense matrices over F2. The name M4RI * preliminary support for parallelisation on shared memory systems via OpenMP; -* and support for Linux, Solaris, and OS X (GCC). +* and support for Linux, Solaris, and OS X (GCC). Support for Windows (MSYS2/MinGW) is provided on a best effort basis and may disappear any time. See [Further Reading](https://bitbucket.org/malb/m4ri/wiki/Further%20Reading) for implemented algorithms. diff --git a/configure.ac b/configure.ac index 05c4a3e..61d6d28 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,7 @@ AC_CANONICAL_HOST AC_CONFIG_SRCDIR(m4ri/brilliantrussian.c) -AM_INIT_AUTOMAKE +AM_INIT_AUTOMAKE([nostdinc]) dnl Include maintainer mode targets. AM_MAINTAINER_MODE @@ -34,6 +34,20 @@ fi LT_LIB_M AC_SUBST(LIBM) +# Check for MinGW to add specific linker flags for DLL symbol exporting +case "$host_os" in + mingw*) + M4RI_EXPORT_ALL_SYMBOLS_LDFLAGS="-Wl,--export-all-symbols" + M4RI_INSTALL_FLAGS="-no-fast-install" + ;; + *) + M4RI_EXPORT_ALL_SYMBOLS_LDFLAGS="" + M4RI_INSTALL_FLAGS="-no-install" + ;; +esac +AC_SUBST(M4RI_EXPORT_ALL_SYMBOLS_LDFLAGS) +AC_SUBST(M4RI_INSTALL_FLAGS) + # SSE2 support AC_ARG_ENABLE([sse2], AS_HELP_STRING([--disable-sse2], [don't use SSE2 instruction set.]), diff --git a/m4/ax_cache_size.m4 b/m4/ax_cache_size.m4 index c30c7e8..72754bb 100644 --- a/m4/ax_cache_size.m4 +++ b/m4/ax_cache_size.m4 @@ -61,19 +61,19 @@ AC_DEFUN([AX_CACHE_SIZE], #Or use CPUID AX_GCC_X86_CPUID(0x80000000) cpu_exthigh=`echo $ax_cv_gcc_x86_cpuid_0x80000000 | cut -d ":" -f 1` - if test "x$cpu_exthi" > "x80000004"; then + if test "x$cpu_exthi" \> "x80000004"; then AX_GCC_X86_CPUID(0x80000005) # For L1 cache l1_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000005 | cut -d ":" -f 4` ax_l1_size=$((0x$l1_hexval >> 24)) fi - if test "x$cpu_exthi" > "x80000005"; then + if test "x$cpu_exthi" \> "x80000005"; then AX_GCC_X86_CPUID(0x80000006) # For L2 cache l2_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 3` ax_l2_size=$((0x$l2_hexval >> 16)) fi - if test "x$cpu_exthi" > "x80000005"; then + if test "x$cpu_exthi" \> "x80000005"; then AX_GCC_X86_CPUID(0x80000006) # For L3 cache l2_hexval=`echo $ax_cv_gcc_x86_cpuid_0x80000006 | cut -d ":" -f 4` ax_l2_size=$((0x$l2_hexval >> 18))*512 diff --git a/m4ri/io.c b/m4ri/io.c index f172f23..92b8bd6 100644 --- a/m4ri/io.c +++ b/m4ri/io.c @@ -23,6 +23,7 @@ #endif #include "m4ri_config.h" +#include #if __M4RI_HAVE_LIBPNG #include @@ -299,40 +300,39 @@ mzd_t *mzd_from_jcf(const char *fn, int verbose) { FILE *fh = fopen(fn, "r"); rci_t m, n; - long p = 0; - long nonzero = 0; + int p = 0; + int64_t nonzero = 0; if (!fh) { if (verbose) printf("Could not open file '%s' for reading\n", fn); return NULL; } - if (fscanf(fh, "%d %d %ld\n%ld\n\n", &m, &n, &p, &nonzero) != 4) { + if (fscanf(fh, "%d %d %d\n%" SCNd64 "\n\n", &m, &n, &p, &nonzero) != 4) { if (verbose) printf("File '%s' does not seem to be in JCF format.", fn); retval = 1; goto from_jcf_close_fh; } if (p != 2) { - if (verbose) printf("Expected p==2 but found p==%ld\n", p); + if (verbose) printf("Expected p==2 but found p==%d\n", p); retval = 1; goto from_jcf_close_fh; } if (verbose) - printf("reading %lu x %lu matrix with at most %ld non-zero entries (density at most: %6.5f)\n", - (unsigned long)m, (unsigned long)n, (unsigned long)nonzero, - ((double)nonzero) / ((double)m * n)); + printf("reading %d x %d matrix with at most %" PRId64 " non-zero entries (density at most: %6.5f)\n", + m, n, nonzero, ((double)nonzero) / ((double)m * n)); A = mzd_init(m, n); - long i = -1; - long j = 0; + rci_t i = -1; + rci_t j = 0; - while (fscanf(fh, "%ld\n", &j) == 1) { + while (fscanf(fh, "%d\n", &j) == 1) { if (j < 0) { i++, j = -j; } if (((j - 1) >= n) || (i >= m)) - m4ri_die("trying to write to (%ld,%ld) in %ld x %ld matrix\n", i, j - 1, m, n); + m4ri_die("trying to write to (%d,%d) in %d x %d matrix\n", i, j - 1, m, n); mzd_write_bit(A, i, j - 1, 1); }; diff --git a/m4ri/m4ri_config.h.in b/m4ri/m4ri_config.h.in index 6e248ec..64214fa 100644 --- a/m4ri/m4ri_config.h.in +++ b/m4ri/m4ri_config.h.in @@ -25,4 +25,9 @@ #define __M4RI_ENABLE_MZD_CACHE @M4RI_ENABLE_MZD_CACHE@ #define __M4RI_ENABLE_MMC @M4RI_ENABLE_MMC@ +#if defined(__MINGW32__) || defined(__MINGW64__) +#define random rand +#define srandom srand +#endif + #endif // M4RI_M4RI_CONFIG_H diff --git a/m4ri/misc.h b/m4ri/misc.h index 4697716..99fd6bb 100644 --- a/m4ri/misc.h +++ b/m4ri/misc.h @@ -418,7 +418,7 @@ static inline word m4ri_spread_bits(word const from, rci_t *const Q, int const l * \param n */ -#define __M4RI_ALIGNMENT(addr, n) (((unsigned long)(addr)) % (n)) +#define __M4RI_ALIGNMENT(addr, n) (((uintptr_t)(addr)) % (n)) /** * \brief Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc diff --git a/m4ri/mzd.h b/m4ri/mzd.h index b4a644a..3f2a264 100644 --- a/m4ri/mzd.h +++ b/m4ri/mzd.h @@ -557,7 +557,7 @@ static inline void mzd_row_add_offset(mzd_t *M, rci_t dstrow, rci_t srcrow, rci_ /* Now wide > 1 */ __m128i *__src = (__m128i *)src; __m128i *__dst = (__m128i *)dst; - __m128i *const eof = (__m128i *)((unsigned long)(src + wide) & ~0xFUL); + __m128i *const eof = (__m128i *)((uintptr_t)(src + wide) & ~(uintptr_t)0xF); do { __m128i xmm1 = _mm_xor_si128(*__dst, *__src); *__dst++ = xmm1; @@ -936,7 +936,7 @@ static inline void mzd_combine_even_in_place(mzd_t *A, rci_t const a_row, wi_t c if (__M4RI_ALIGNMENT(a, 16) == 0 && __M4RI_ALIGNMENT(b, 16) == 0) { __m128i *a128 = (__m128i *)a; __m128i *b128 = (__m128i *)b; - const __m128i *eof = (__m128i *)((unsigned long)(a + wide) & ~0xFUL); + const __m128i *eof = (__m128i *)((uintptr_t)(a + wide) & ~(uintptr_t)0xF); do { *a128 = _mm_xor_si128(*a128, *b128); @@ -1011,7 +1011,7 @@ static inline void mzd_combine_even(mzd_t *C, rci_t const c_row, wi_t const c_st __m128i *a128 = (__m128i *)a; __m128i *b128 = (__m128i *)b; __m128i *c128 = (__m128i *)c; - const __m128i *eof = (__m128i *)((unsigned long)(a + wide) & ~0xFUL); + const __m128i *eof = (__m128i *)((uintptr_t)(a + wide) & ~(uintptr_t)0xF); do { *c128 = _mm_xor_si128(*a128, *b128); diff --git a/m4ri/xor.h b/m4ri/xor.h index c0d302a..c4ae344 100644 --- a/m4ri/xor.h +++ b/m4ri/xor.h @@ -53,7 +53,7 @@ static inline void _mzd_combine(word *c, word const *t1, wi_t wide_in) { __m128i *__c = (__m128i *)c; __m128i *__t1 = (__m128i *)t1; - const __m128i *eof = (__m128i *)((unsigned long)(c + wide) & ~0xFUL); + const __m128i *eof = (__m128i *)((uintptr_t)(c + wide) & ~(uintptr_t)0xF); __m128i xmm1; while (__c < eof - 1) { diff --git a/tests/Makefile.am b/tests/Makefile.am index 21d0b64..b075991 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -12,10 +12,12 @@ TOPSRCDIR = $(srcdir)/.. TOPBUILDDIR = $(builddir)/.. DEFINES = # include TOPBUILDIR for m4ri_config.h -AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -D_XOPEN_SOURCE=600 $(DEFINES) @OPENMP_CFLAGS@ @PAPI_CFLAGS@ @LIBPNG_CFLAGS@ +AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -iquote$(TOPBUILDDIR)/m4ri -D_XOPEN_SOURCE=600 $(DEFINES) @OPENMP_CFLAGS@ @PAPI_CFLAGS@ @LIBPNG_CFLAGS@ STAGEDIR := $(realpath -s $(TOPBUILDDIR)/.libs) -AM_LDFLAGS = -L$(STAGEDIR) -Wl,-rpath,$(STAGEDIR) -lm4ri $(LIBM) @PAPI_LDFLAGS@ @PAPI_LIBS@ -no-install +AM_LDFLAGS = -Wl,-rpath,$(STAGEDIR) $(LIBM) @PAPI_LDFLAGS@ @PAPI_LIBS@ @M4RI_INSTALL_FLAGS@ + +LDADD = $(TOPBUILDDIR)/libm4ri.la test_smallops_SOURCES = test_smallops.c testing.c testing.h