Skip to content

Commit

Permalink
more compiler flags
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cortes committed Dec 15, 2021
1 parent f5171a1 commit ef6d3e4
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
28 changes: 25 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,7 @@ PACKAGE_URL=''

ac_subst_vars='LTLIBOBJS
LIBOBJS
FNTP_FLAG
FNE_FLAG
OMP_PLUS_ATOMIC
OMP_PLUS_ATOMIC_L
Expand Down Expand Up @@ -3185,9 +3186,6 @@ fi
#AX_CHECK_COMPILE_FLAG([-fno-math-errno], [FNE_FLAG="-fno-math-errno"], [FNE_FLAG=""])
#AC_SUBST(FNE_FLAG)
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
Expand Down Expand Up @@ -3218,6 +3216,30 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS="$OLD_CFLAGS"
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-trapping-math"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"
then :
FNTP_FLAG="-fno-trapping-math"
else $as_nop
FNTP_FLAG=""
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CFLAGS="$OLD_CFLAGS"
ac_config_files="$ac_config_files src/Makevars"
cat >confcache <<\_ACEOF
Expand Down
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,15 @@ AC_COMPILE_IFELSE(
CFLAGS="$OLD_CFLAGS"
AC_SUBST(FNE_FLAG)

OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-trapping-math"
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[]])],
[FNTP_FLAG="-fno-trapping-math"],
[FNTP_FLAG=""]
)
CFLAGS="$OLD_CFLAGS"
AC_SUBST(FNTP_FLAG)

AC_CONFIG_FILES([src/Makevars])
AC_OUTPUT
12 changes: 10 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def build_extensions(self):
self.add_march_native()
self.add_openmp_linkage()
self.add_no_math_errno()
self.add_no_trapping_math()
if sys.platform[:3].lower() != "win":
self.add_link_time_optimization()

Expand Down Expand Up @@ -63,6 +64,13 @@ def add_no_math_errno(self):
e.extra_compile_args.append(arg_fnme)
e.extra_link_args.append(arg_fnme)

def add_no_trapping_math(self):
arg_fntm = "-fno-trapping-math"
if self.test_supports_compile_arg(arg_fntm):
for e in self.extensions:
e.extra_compile_args.append(arg_fntm)
e.extra_link_args.append(arg_fntm)

def add_openmp_linkage(self):
arg_omp1 = "-fopenmp"
arg_omp2 = "-qopenmp"
Expand Down Expand Up @@ -125,7 +133,7 @@ def test_supports_compile_arg(self, comm):
author = 'David Cortes',
author_email = 'david.cortes.rivera@gmail.com',
url = 'https://github.com/david-cortes/poismf',
version = '0.3.1-6',
version = '0.3.1-7',
install_requires = ['numpy', 'pandas>=0.24', 'cython', 'scipy'],
description = 'Fast and memory-efficient Poisson factorization for sparse count matrices',
cmdclass = {'build_ext': build_ext_subclass},
Expand Down Expand Up @@ -162,7 +170,7 @@ def test_supports_compile_arg(self, comm):
author = 'David Cortes',
author_email = 'david.cortes.rivera@gmail.com',
url = 'https://github.com/david-cortes/poismf',
version = '0.3.1-6',
version = '0.3.1-7',
install_requires = ['numpy', 'scipy', 'pandas>=0.24', 'cython'],
description = 'Fast and memory-efficient Poisson factorization for sparse count matrices',
)
4 changes: 2 additions & 2 deletions src/Makevars.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PKG_CPPFLAGS = -D_FOR_R -DUSE_FC_LEN_T
PKG_CFLAGS = @OMP_PLUS_ATOMIC@ @FNE_FLAG@ $(C_VISIBILITY)
PKG_LIBS = @OMP_PLUS_ATOMIC_L@ @FNE_FLAG@ $(BLAS_LIBS) $(FLIBS)
PKG_CFLAGS = @OMP_PLUS_ATOMIC@ @FNE_FLAG@ @FNTP_FLAG@ $(C_VISIBILITY)
PKG_LIBS = @OMP_PLUS_ATOMIC_L@ $(BLAS_LIBS) $(FLIBS)

0 comments on commit ef6d3e4

Please sign in to comment.