-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #425 from RcppCore/feature/thread_throttle
Add OpenMP throttling helper
- Loading branch information
Showing
11 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,19 @@ | ||
2023-10-29 Dirk Eddelbuettel <[email protected]> | ||
|
||
* src/RcppArmadillo.cpp (armadillo_get_number_of_omp_threads) | ||
(armadillo_set_number_of_omp_threads): New helper functions | ||
* src/RcppExports.cpp: Regenerated | ||
* R/RcppExports.R: Idem | ||
* man/armadillo_get_number_of_omp_threads.Rd: Documentation | ||
|
||
* R/init.R (.onLoad): Store initial thread count | ||
* R/init.R (armadillo_throttle_cores, armadillo_reset_cores): | ||
Tread throtte and reset helper functions | ||
* man/armadillo_throttle_cores.Rd: Documentation | ||
|
||
* man/fastLm.Rd: Illustration of use of throttle and reset function | ||
* NAMESPACE: Export new functions | ||
|
||
2023-10-14 Dirk Eddelbuettel <[email protected]> | ||
|
||
* DESCRIPTION (Version, Date): RcppArmadillo 0.12.6.5.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## init.R: Startup | ||
## | ||
## Copyright (C) 2023 Dirk Eddelbuettel | ||
## | ||
## This file is part of RcppArmadillo. | ||
## | ||
## RcppArmadillo is free software: you can redistribute it and/or modify it | ||
## under the terms of the GNU General Public License as published by | ||
## the Free Software Foundation, either version 2 of the License, or | ||
## (at your option) any later version. | ||
## | ||
## RcppArmadillo is distributed in the hope that it will be useful, but | ||
## WITHOUT ANY WARRANTY; without even the implied warranty of | ||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
## GNU General Public License for more details. | ||
## | ||
## You should have received a copy of the GNU General Public License | ||
## along with RcppArmadillo. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
.pkgenv <- new.env(parent=emptyenv()) | ||
|
||
.onLoad <- function(libname, pkgname) { | ||
.pkgenv[["omp_threads"]] <- armadillo_get_number_of_omp_threads() | ||
} | ||
|
||
##' Throttle (or Reset) (Rcpp)Armadillo to Two Cores | ||
##' | ||
##' Helper functions to throttle use of cores by RcppArmadillo-internal | ||
##' code on systems with OpenMP. On package load, the initial value is | ||
##' saved and used to reset the value. | ||
##' @param n Integer value of desired cores, default is two | ||
armadillo_throttle_cores <- function(n = 2) { | ||
armadillo_set_number_of_omp_threads(n) | ||
} | ||
|
||
##' @rdname armadillo_throttle_cores | ||
armadillo_reset_cores <- function() { | ||
n <- .pkgenv[["omp_threads"]] | ||
armadillo_set_number_of_omp_threads(n) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters