Skip to content

Commit

Permalink
Remove suppressions from polyk, supress OpenMP warning messages on st…
Browse files Browse the repository at this point in the history
…artup, add gitattributes and fix cran-check action
  • Loading branch information
shail-choksi committed Aug 9, 2024
1 parent 6302add commit 5ab17e5
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configure.ac text eol=lf
13 changes: 1 addition & 12 deletions .github/workflows/cran-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,16 @@ jobs:
- name: Build and Check ToxicR
if: runner.os != 'Windows'
run: |
R CMD build .
file config.log
cat config.log
r_output=$(R CMD build .)
echo "$r_output"
package_name=$(echo "$r_output" | sed -n "s/.*building ‘\([^’]*\.tar\.gz\)’.*/\1/p")
echo "$package_name"
package_name=$(echo "$r_output" | sed -n "s/.*building ‘\([^’]*\.tar\.gz\)’.*/\1/p")
R CMD check --as-cran --no-manual $package_name
shell: bash
working-directory: "."
- name: Build and Check ToxicR
if: runner.os == 'Windows'
run: |
r_output=$(R CMD build .)
echo "$r_output"
package_name=$(echo "$r_output" | sed -n "s/.*building '\([^']*\.tar\.gz\)'.*/\1/p")
echo "$package_name"
R CMD check --as-cran --no-manual $package_name
file ToxicR.Rcheck/00install.log
file ToxicR/ToxicR.Rcheck/00install.log
cat ToxicR.Rcheck/00install.log
cat ToxicR.Rcheck/00check.log
shell: bash
working-directory: "."
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
*.o
*.so
*.Rproj
.Rproj.user
.Rhistory
.vscode/*
.RData
*.tar.gz
*.dll
*.dll
install.sh
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Changes
## Version 23.10.1.2.3
## The following cumulative fixes are in version 23.10.1.2.3
## Version 23.10.1.2.4
## The following cumulative fixes are in version 23.10.1.2.4
- Add the ability to set a seed for nlopt and GSL to allow for consistent results
- Set additional checks and guards for openMP
## New Features
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Imports: Rcpp (>= 1.0.0), ggplot2 (>= 3.3.2), shiny (>= 1.5.0), coda
(>= 0.19-4), scales (>= 1.1.1), forcats, ggridges (>= 0.5.3),
doBy (>= 4.6.11), multcomp (>= 1.4), dplyr (>= 1.0.7), remotes
LinkingTo: Rcpp, RcppEigen, RcppGSL
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Encoding: UTF-8
VignetteBuilder: knitr
Suggests: plotly (>= 4.9.2.1), rmarkdown, actuar (>= 3.2-0),ggpubr (>=
Expand Down
2 changes: 1 addition & 1 deletion R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@
}

.set_threads <- function(num_threads) {
invisible(.Call(`_ToxicR_set_threads`, num_threads))
.Call(`_ToxicR_set_threads`, num_threads)
}

21 changes: 14 additions & 7 deletions R/opening_messages.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.onAttach <- function(libname, pkgname) {
msg <- "
version <- as.character(utils::packageVersion("ToxicR"))
msg <- paste0("
_______ _____
|__ __| \U1F913 | __ \\
| | _____ ___ ___| |__) |
| |/ _ \\ \\/ / |/ __| _ /
| | (_) > <| | (__| | \\ \\
|_|\\___/_/\\_\\_|\\___|_| \\_\\
24.1.1.2.4
",version,"
___
| |
/ \\ ____()()
Expand All @@ -39,7 +40,7 @@ PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIG
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
"
")

# notify the option to update? (5 possible cases)
# 1. error in getting the current package version -> yes
Expand All @@ -50,7 +51,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# in short, notify the option to update unless the version numbers match
# get version of the currently installed package
current_pkg_version <- tryCatch(
as.character(utils::packageVersion("ToxicR")),
version,
error = function(e) "unknown")
# github url
github_url <- paste0(
Expand Down Expand Up @@ -81,7 +82,7 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
compare_version_result == 0) {
startup_message <- paste0(
"Package attached: ToxicR v", current_pkg_version,
" (same as the most recent version available through GitHub).")
" (the most recent version available through GitHub).")
} else if (
# skip update for case 4
current_pkg_version != "unknown" &
Expand All @@ -103,7 +104,13 @@ OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}
packageStartupMessage(msg)
packageStartupMessage(startup_message)
.set_threads(2);
open_mp_message <- "OpenMP threads set to 2.\n"
status <- .set_threads(2)
if (status == 1) {
open_mp_message <- "OpenMP threads set to 2.\n"
} else if (status == 0) {
open_mp_message <- "OpenMP will not be used for parallelization.\n"
} else {
open_mp_message <- "OpenMP is not supported on this architecture.\n"
}
packageStartupMessage(open_mp_message)
}
7 changes: 4 additions & 3 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,14 @@ BEGIN_RCPP
END_RCPP
}
// set_threads
void set_threads(int num_threads);
int set_threads(int num_threads);
RcppExport SEXP _ToxicR_set_threads(SEXP num_threadsSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< int >::type num_threads(num_threadsSEXP);
set_threads(num_threads);
return R_NilValue;
rcpp_result_gen = Rcpp::wrap(set_threads(num_threads));
return rcpp_result_gen;
END_RCPP
}

Expand Down
6 changes: 3 additions & 3 deletions src/polyK/polyK_setup.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@


// necessary things to run in R
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wignored-attributes"
#include <RcppEigen.h>
#pragma GCC diagnostic pop
// #pragma GCC diagnostic pop

#include "polyK_animal.h"
#include "polyK_setup.h"
Expand Down
6 changes: 3 additions & 3 deletions src/polyK/polyK_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#include <array>
#include <list>
#include <vector>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wignored-attributes"
// #pragma GCC diagnostic push
// #pragma GCC diagnostic ignored "-Wignored-attributes"
#include <RcppEigen.h>
#pragma GCC diagnostic pop
// #pragma GCC diagnostic pop
#include <RcppGSL.h>

#include "polyK_animal.h"
Expand Down
13 changes: 9 additions & 4 deletions src/set_omp_threads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,25 @@ using namespace Rcpp;
// function: set_threads
// purpose: takes an integer value and set the number of
// openmp threads to that value
// output: none
// output: integer representing if openMP is supported and set correctely
// [[Rcpp::export(".set_threads")]]
void set_threads(int num_threads) {
int set_threads(int num_threads) {
#ifndef NO_OMP
if(omp_get_max_threads() > 1){
if (num_threads > omp_get_num_threads()) {
Seeder* s = Seeder::getInstance();
omp_set_num_threads(num_threads);
s->reset_max_threads(num_threads);
// Rcpp::Rcout << "OpenMP threads set to " << num_threads << std::endl;
return 1;
}
}else{
Rcout << "OMP will not be used for parallelization.";
return 0;
// Rcpp::Rcout << "OMP will not be used for parallelization.";
}
#else
Rcpp::Rcout << "OpenMP not supported on this architecure." << std::endl;
return -1;
// Rcpp::Rcout << "OpenMP not supported on this architecure." << std::endl;
#endif
return -1;
}

0 comments on commit 5ab17e5

Please sign in to comment.