Skip to content

Commit

Permalink
Merge pull request #1628 from albinahlback/fast_flint
Browse files Browse the repository at this point in the history
Add -O3 and -march=native to default CFLAGS
  • Loading branch information
albinahlback committed Nov 16, 2023
2 parents 4bbb654 + 43da347 commit f09196d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ concurrency:

jobs:
##############################################################################
# ubuntu, gcc, avx2, code coverage
# ubuntu, gcc, code coverage
##############################################################################
ubuntu-avx2-codecoverage:
name: Ubuntu GCC, AVX2, Code Coverage (x10)
ubuntu-codecoverage:
name: Ubuntu GCC, Code Coverage (x10)

runs-on: ubuntu-latest

Expand Down
16 changes: 14 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,11 @@ AX_CHECK_COMPILE_FLAG([-Wall],[DEFAULT_CFLAGS="-Wall $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overread],[DEFAULT_CFLAGS="-Wno-stringop-overread $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Wno-stringop-overflow],[DEFAULT_CFLAGS="-Wno-stringop-overflow $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-Werror=implicit-function-declaration],[DEFAULT_CFLAGS="-Werror=implicit-function-declaration $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-O2],[DEFAULT_CFLAGS="-O2 $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-O3],[DEFAULT_CFLAGS="-O3 $DEFAULT_CFLAGS"])
if test "$host" = "$build";
then
AX_CHECK_COMPILE_FLAG([-march=native],[DEFAULT_CFLAGS="-march=native $DEFAULT_CFLAGS"])
fi
AX_CHECK_COMPILE_FLAG([-std=c11],[DEFAULT_CFLAGS="-std=c11 $DEFAULT_CFLAGS"])
AX_CHECK_COMPILE_FLAG([-pedantic],[DEFAULT_CFLAGS="-pedantic $DEFAULT_CFLAGS"])

Expand Down Expand Up @@ -1028,7 +1032,15 @@ error
error
#endif
])],
[enable_fft_small="yes"]
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([#include <gmp.h>],[
#if GMP_LIMB_BITS == 32
#error Dead man
error
#endif
])],
[enable_fft_small="yes"]
)]
)]
)
fi
Expand Down
11 changes: 11 additions & 0 deletions src/fft_small/sd_fft_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
#include "fft_small.h"
#include "nmod.h"

#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
# include <malloc.h>
# define aligned_alloc(alignment, size) _aligned_malloc(size, alignment)
# define free _aligned_free
#endif

void * flint_aligned_alloc(ulong alignment, ulong size)
{
void * p;
Expand All @@ -32,6 +38,11 @@ void flint_aligned_free(void * p)
free(p);
}

#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__)
# undef aligned_alloc
# undef free
#endif

void sd_fft_ctx_clear(sd_fft_ctx_t Q)
{
ulong k;
Expand Down
6 changes: 5 additions & 1 deletion src/flint.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ typedef struct __FLINT_FILE FLINT_FILE;
# define FLINT_OPTIMIZE(x) FLINT_OPTIMIZE_NESTED_1(x)
#else
# define __attribute__(x)
# define FLINT_FORCE_INLINE static inline
# if defined(_MSC_VER)
# define FLINT_FORCE_INLINE static __forceinline
# else
# define FLINT_FORCE_INLINE static inline
# endif
# define FLINT_STATIC_NOINLINE static
# define FLINT_UNUSED(x) x
# define FLINT_SET_BUT_UNUSED(x) x
Expand Down

0 comments on commit f09196d

Please sign in to comment.