Git Product home page Git Product logo

Comments (10)

coatless avatar coatless commented on June 5, 2024 1

I think it would be better to be contained within armadillo. I noodled around with the Makevars approach I outlined above. It didn't work out well since I do not believe Makevars is even used by R/Attributes.R after browsing the file.

So, I would propose an approach similar to RQuantlib for setting the flag.

inlineCxxPlugin <- function(...) {
  plugin <- Rcpp:::Rcpp.plugin.maker(include.before = "#include <RcppArmadillo.h>", 
                                     libs           = "$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CFLAGS)", 
                                     package        = "RcppArmadillo")
  settings <- plugin()
  settings$env$PKG_CPPFLAGS <- paste0("$(SHLIB_OPENMP_CXXFLAGS)")
  settings
}

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

But ... as I recall this gist of getting OpenMP was to both compile and link with -fopenmp so we would need to get it into CXXFLAGS, or PKG_CXXFLAGS, or ... And make sure we cover the various C++ dialect options we now have.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

Ie here is what Rcpp does in its plugin for openmp:

## built-in OpenMP++11 plugin
.plugins[["openmp"]] <- function() {
    list(env = list(PKG_CXXFLAGS="-fopenmp",
                    PKG_LIBS="-fopenmp"))
}

(I suppose OpenMP++11 is a cut-and-pasto. Should be OpenMP.)

from rcpparmadillo.

coatless avatar coatless commented on June 5, 2024

@eddelbuettel You are correct. The functionality of Rcpp.plugin.maker needs to be extended...

from rcpparmadillo.

coatless avatar coatless commented on June 5, 2024

Or, what can happen is an injection into the Makevars slot in a similar way as the libs line is defined. See R/inline.R#L44-L54

Rcpp:::Rcpp.plugin.maker(
	include.before = "#include <RcppArmadillo.h>", 
	libs           = "$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) $(SHLIB_OPENMP_CFLAGS)", 
        Makevars       = list( PKG_CXXFLAGS = "$(SHLIB_OPENMP_CXXFLAGS)" ) ,
        Makevars.win   = list( PKG_CXXFLAGS = "$(SHLIB_OPENMP_CXXFLAGS)" ),
	package        = "RcppArmadillo")

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

Or ... we just punt and tell folks to rely on the existing plugin for OpenMP which reliably turns on OpenMP?

Ie recommend to turn on RcppArmadillo (via Rcpp::depends()) and OpenMP (via Rcpp::plugins()) ?

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

RcppGSL does something similar. The crux, as you say, is that this once aimed the inline package, and Rcpp sort of just picked it up.

We have to figure put the different use case and try to make sure we hit most of them home...

from rcpparmadillo.

coatless avatar coatless commented on June 5, 2024

Per 70a27b7 and 150899f this can be closed out.

However, note that Makevars uses PKG_CXXFLAGS while Makevars.win uses PKG_CPPFLAGS.
Though, setting the flags through either appears to matriculate the correct flags for the compile.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

Yes, testing this on Metra this am. Seems to work. Users may still have to supply the C++11 or C++14 (Rcpp) plugin in addition to the the depends getting them this from the pluginMaker.

Thanks for the reminder on the Makevars. I'll clean this up. Writing R Extension is a little rambling there but I PKG_CXXFLAGS may be better.

One thought I had was to ... maybe adding comments that all this is optional may help? Then again adding -fopenmp without actual OpenMP directive is just a null-op so no harm done.

from rcpparmadillo.

eddelbuettel avatar eddelbuettel commented on June 5, 2024

I think this one can be closed now.

from rcpparmadillo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.