Skip to content

Commit

Permalink
Refactoring of check if built with support for OpenMP
Browse files Browse the repository at this point in the history
  • Loading branch information
stewid committed Feb 10, 2017
1 parent bd76ad5 commit 71329fe
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 70 deletions.
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Imports:
stats,
utils,
Matrix
Collate:
Collate:
'AllGenerics.R'
'check_arguments.R'
'scheduled_events.R'
Expand All @@ -48,7 +48,6 @@ Collate:
'SISe_sp.R'
'SimInf.R'
'demo_model.R'
'dependencies.R'
'distance.R'
'run_outer.R'
RoxygenNote: 6.0.1
Expand Down
14 changes: 12 additions & 2 deletions R/SimInf.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## SimInf, a framework for stochastic disease spread simulations
## Copyright (C) 2015 Pavol Bauer
## Copyright (C) 2015 - 2016 Stefan Engblom
## Copyright (C) 2015 - 2016 Stefan Widgren
## Copyright (C) 2015 - 2017 Stefan Engblom
## Copyright (C) 2015 - 2017 Stefan Widgren
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -34,6 +34,16 @@ NULL
library.dynam.unload("SimInf", libpath)
}

##' Is OpenMP available
##'
##' @return TRUE if SimInf was built with support for OpenMP, else
##' FALSE.
##' @keywords internal
have_openmp <- function()
{
.Call("siminf_have_openmp", PACKAGE = "SimInf")
}

##' Scheduled events example data
##'
##' Synthetic scheduled events data to demonstrate the \code{SISe3}
Expand Down
24 changes: 0 additions & 24 deletions R/dependencies.R

This file was deleted.

24 changes: 0 additions & 24 deletions R/dependencies.R.in

This file was deleted.

24 changes: 15 additions & 9 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,6 @@ MODELS_OBJ
PKG_LIBS
PKG_CFLAGS
PKG_CPPFLAGS
SIMINF_HAVE_OPENMP
OPENMP_CFLAGS
OBJEXT
EXEEXT
Expand Down Expand Up @@ -619,6 +618,7 @@ infodir
docdir
oldincludedir
includedir
runstatedir
localstatedir
sharedstatedir
sysconfdir
Expand Down Expand Up @@ -691,6 +691,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
Expand Down Expand Up @@ -943,6 +944,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;

-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;

-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
Expand Down Expand Up @@ -1080,7 +1090,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir
libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
Expand Down Expand Up @@ -1233,6 +1243,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
Expand Down Expand Up @@ -2707,11 +2718,8 @@ _ACEOF
$as_echo "${ac_pkg_openmp}" >&6; }
fi
if test "x${ac_pkg_openmp}" = xyes; then
SIMINF_HAVE_OPENMP=TRUE
else
if test "x${ac_pkg_openmp}" = xno; then
OPENMP_CFLAGS=''
SIMINF_HAVE_OPENMP=FALSE
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING:
-----------------------------------------------
Unable to find OpenMP on this system.
Expand Down Expand Up @@ -2858,7 +2866,6 @@ fi
# List all model files to compile
MODELS_OBJ=`"${RSCRIPT}" -e "cat(paste0('models/', sub('c$', 'o', list.files('src/models', '.c$')), collapse=' '))"`
PKG_CPPFLAGS="-I. -Icore -Imisc -Imodels ${OPENMP_CFLAGS} ${CPPFLAGS}"
PKG_CFLAGS="${OPENMP_CFLAGS}"
Expand All @@ -2867,7 +2874,7 @@ PKG_LIBS="${OPENMP_CFLAGS} ${LIBS}"
ac_config_files="$ac_config_files R/dependencies.R src/Makevars"
ac_config_files="$ac_config_files src/Makevars"
cat >confcache <<\_ACEOF
Expand Down Expand Up @@ -3575,7 +3582,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
for ac_config_target in $ac_config_targets
do
case $ac_config_target in
"R/dependencies.R") CONFIG_FILES="$CONFIG_FILES R/dependencies.R" ;;
"src/Makevars") CONFIG_FILES="$CONFIG_FILES src/Makevars" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
Expand Down
12 changes: 4 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SimInf, a framework for stochastic disease spread simulations
# Copyright (C) 2015 Pavol Bauer
# Copyright (C) 2015 - 2016 Stefan Engblom
# Copyright (C) 2015 - 2016 Stefan Widgren
# Copyright (C) 2015 - 2017 Stefan Engblom
# Copyright (C) 2015 - 2017 Stefan Widgren
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -65,11 +65,8 @@ if test -n "${OPENMP_CFLAGS}"; then
AC_MSG_RESULT([${ac_pkg_openmp}])
fi

if test "x${ac_pkg_openmp}" = xyes; then
SIMINF_HAVE_OPENMP=TRUE
else
if test "x${ac_pkg_openmp}" = xno; then
OPENMP_CFLAGS=''
SIMINF_HAVE_OPENMP=FALSE
AC_MSG_WARN([
-----------------------------------------------
Unable to find OpenMP on this system.
Expand Down Expand Up @@ -116,12 +113,11 @@ fi
# List all model files to compile
MODELS_OBJ=`"${RSCRIPT}" -e "cat(paste0('models/', sub('c$', 'o', list.files('src/models', '[.]c$')), collapse=' '))"`

AC_SUBST(SIMINF_HAVE_OPENMP)
AC_SUBST([PKG_CPPFLAGS], ["-I. -Icore -Imisc -Imodels ${OPENMP_CFLAGS} ${CPPFLAGS}"])
AC_SUBST([PKG_CFLAGS], ["${OPENMP_CFLAGS}"])
AC_SUBST([PKG_LIBS], ["${OPENMP_CFLAGS} ${LIBS}"])
AC_SUBST(MODELS_OBJ)

AC_CONFIG_FILES([R/dependencies.R src/Makevars])
AC_CONFIG_FILES([src/Makevars])

AC_OUTPUT
6 changes: 5 additions & 1 deletion man/have_openmp.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/siminf.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,17 @@ SEXP siminf_run(

return trajectory;
}

/**
* Is OpenMP available
*/
SEXP siminf_have_openmp()
{
return Rf_ScalarLogical(
#ifdef _OPENMP
1
#else
0
#endif
);
}

0 comments on commit 71329fe

Please sign in to comment.