Skip to content

Commit

Permalink
updating the configure script thanks to ivan
Browse files Browse the repository at this point in the history
  • Loading branch information
michellepistner committed May 31, 2024
1 parent 6408e16 commit 76cdc9c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 34 deletions.
12 changes: 6 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Type: Package
Title: Bayesian Multinomial Logistic Normal Regression
Version: 1.1.0
Date: 2024-05-15
Authors@R: c(person("Justin", "Silverman", role=c("aut", "cre"),
email = "JustinSilverman@psu.edu"),
Authors@R: c(person("Justin", "Silverman", role=c("aut"),
email = "Justin.Silverman@psu.edu"),
person("Kim", "Roche", role=("ctb"),
email = "[email protected]"),
person("Michelle", "Nixon", role=c("aut"),
email = "[email protected]"))
Maintainer: Justin Silverman
<JustinSilverman@psu.edu>
person("Michelle", "Nixon", role=c("ctb","cre"),
email = "[email protected]"))
Maintainer: Michelle Nixon
<pistner@psu.edu>
Description: Provides methods for fitting and inspection of Bayesian Multinomial Logistic Normal Models using MAP estimation and Laplace Approximation as developed in Silverman et. Al. (2022) <https://www.jmlr.org/papers/v23/19-882.html>. Key functionality is implemented in C++ for scalability. 'fido' replaces the previous package 'stray'.
License: GPL-3
URL: https://jsilve24.github.io/fido/
Expand Down
30 changes: 16 additions & 14 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3249,20 +3249,22 @@ mkdir -p "${BUILDDIR}"
owd=$(pwd)
cd "${BUILDDIR}"

# The configure script:
cat > test-omp.cpp <<EOF
#include <omp.h>
extern "C" void configtest(int * arg) {
*arg = omp_get_num_threads();
}
EOF
# Without the following you're relying on the GNU/Linux-like behaviour
# w.r.t. undefined symbols (see WRE 1.2.1.1):
cat > Makevars <<EOF
PKG_CXXFLAGS = \$(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = \$(SHLIB_OPENMP_CXXFLAGS)
EOF
R CMD SHLIB test-omp.cpp
# MPN: These updates were from a (very, very useful) help question posted to r-package-devel
# Credit goes to Ivan Krylov.

# compile and link the shared object
"${R_HOME}/bin/R" CMD SHLIB test-omp.cpp
# load it and use a function from the inside
"${R_HOME}/bin/Rscript" -e '
dyn.load(paste0("test-omp", .Platform$dynlib.ext))
.C("configtest", arg = integer(1))$arg
'
if test $? -eq 0; then
# everything seems to have succeeded
openmp_already_works="yes"
fi
# let the user know either way
AC_MSG_RESULT([${openmp_already_works}])

## Go back home.
cd "${owd}"
Expand Down
27 changes: 13 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,19 @@ mkdir -p "${BUILDDIR}"
owd=$(pwd)
cd "${BUILDDIR}"

# The configure script:
cat > test-omp.cpp <<EOF
#include <omp.h>
extern "C" void configtest(int * arg) {
*arg = omp_get_num_threads();
}
EOF
# Without the following you're relying on the GNU/Linux-like behaviour
# w.r.t. undefined symbols (see WRE 1.2.1.1):
cat > Makevars <<EOF
PKG_CXXFLAGS = \$(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = \$(SHLIB_OPENMP_CXXFLAGS)
EOF
R CMD SHLIB test-omp.cpp
# compile and link the shared object
"${R_HOME}/bin/R" CMD SHLIB test-omp.cpp
# load it and use a function from the inside
"${R_HOME}/bin/Rscript" -e '
dyn.load(paste0("test-omp", .Platform$dynlib.ext))
.C("configtest", arg = integer(1))$arg
'
if test $? -eq 0; then
# everything seems to have succeeded
openmp_already_works="yes"
fi
# let the user know either way
AC_MSG_RESULT([${openmp_already_works}])

## Go back home.
cd "${owd}"
Expand Down

0 comments on commit 76cdc9c

Please sign in to comment.