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

Set a default for NCORES #149

Closed
wants to merge 1 commit into from
Closed

Set a default for NCORES #149

wants to merge 1 commit into from

Conversation

jeroen
Copy link
Contributor

@jeroen jeroen commented Jan 15, 2024

I see a bunch of warnings when configuring:

-- Build files have been written to: /tmp/RtmpjkUDAr/file1c4d6c6cb7/nloptr/src/nlopt-build
make: the '-j' option requires a positive integer argument
Usage: make [options] [target] ...

The issue is that when NCORES Is unset, the argument is incomplete. This sets a default if NCORES is unset to 1.

@@ -36,7 +36,7 @@ ${CMAKE_BIN} \
-D NLOPT_SWIG=OFF \
-D NLOPT_TESTS=OFF \
${CMAKE_ADD_AR} ${CMAKE_ADD_RANLIB} ../nlopt-src
make -j${NCORES}
make -j${NCORES:-1}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move the fixing logic higher up? The script starts with

: ${R_HOME=$(R RHOME)}
RSCRIPT_BIN=${R_HOME}/bin/Rscript
NCORES=`${RSCRIPT_BIN} -e "cat(min(2, parallel::detectCores(logical = FALSE)))"`

Why does that not work in your settings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah good point. It seems to return NA on WebAssembly.

@jeroen jeroen closed this Jan 15, 2024
@jeroen jeroen deleted the patch-1 branch January 15, 2024 16:41
@jeroen
Copy link
Contributor Author

jeroen commented Jan 15, 2024

OK so the real problem is we are not accounting for the case where parallel::detectCores(logical = FALSE)) returns NA.

@eddelbuettel
Copy link
Contributor

Can you bubble that up to webr / wasm ?

@jeroen
Copy link
Contributor Author

jeroen commented Jan 15, 2024

The source of detectCores() show that NA is the default return value in cases that it fails to guess. So it would probably be appropriate to deal with that outcome when you call it here. But it's no biggy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants