Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package] Temporary workaround for not modifying global OMP config #5134

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ VignetteBuilder: knitr
Suggests:
knitr,
processx,
RhpcBLASctl,
rmarkdown,
testthat
Depends:
Expand All @@ -63,6 +62,7 @@ Imports:
Matrix (>= 1.1-0),
methods,
parallel,
RhpcBLASctl,
utils
SystemRequirements:
C++11
Expand Down
2 changes: 2 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export(slice)
import(methods)
importFrom(Matrix,Matrix)
importFrom(R6,R6Class)
importFrom(RhpcBLASctl,omp_get_max_threads)
importFrom(RhpcBLASctl,omp_set_num_threads)
importFrom(data.table,":=")
importFrom(data.table,as.data.table)
importFrom(data.table,data.table)
Expand Down
6 changes: 6 additions & 0 deletions R-package/R/lgb.train.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' @importFrom RhpcBLASctl omp_get_max_threads omp_set_num_threads

#' @name lgb.train
#' @title Main training logic for LightGBM
#' @description Logic to train with LightGBM
Expand Down Expand Up @@ -149,6 +151,10 @@ lgb.train <- function(params = list(),
interaction_constraints <- params[["interaction_constraints"]]
params["interaction_constraints"] <- NULL

# This is a temporary workround for GH issue 4705
curr_threads <- RhpcBLASctl::omp_get_max_threads()
on.exit(RhpcBLASctl::omp_set_num_threads(curr_threads))

# Construct datasets, if needed
data$update_params(params = params)
data$construct()
Expand Down