Closed coatless closed 7 months ago
Thanks, this sounds reasonable to me.
IIUC code written for openmp should safely degrade to serial code when the -fopenmp
flag has not been given? That is, the #pragma omp
s will be ignored, the #include <omp.h>
should be gated behind an #ifdef
, and the distributed loops themselves should become single-threaded loops?
If so, I think this change will be OK. I guess nothing is lost, since we don't currently seem to provide a omp.h
header under Emscripten anyway.
@georgestagg Yes, OpenMP-enabled code written using pragmas or guarded with #ifdef
checking _OPENMP
should safely degrade from parallel to serial usage. For the majority (if not all) of the packages on CRAN, this will hold as there are more stringent checks in place due to the lack of native OpenMP support on macOS.
At the moment, webR is passing into compilation statements
-fopenmp
.However, the header file is not being found:
https://github.com/coatless-mlpack/mlpack-hello-webr/actions/runs/7524258719/job/20510389211#step:5:489
In cases like
RcppArmadillo
, thearmadillo
library itself guards quite well against the lack ofOpenMP
:https://github.com/RcppCore/RcppArmadillo/blob/20e4ea3cdc5dd2a115f94c92eb4b1754e70f9696/inst/include/armadillo#L98C1-L110C1
However, others are likely just doing a check with:
Nullifying the
SHLIB_OPENMP_*
values ininst/webr-vars.mk
should avoid havingfopenmp
being passed in. The relevant OpenMP flags in the baseMakeconf
:So, I think the nullification can be done with:
Note:
DYLIB_LDFLAGS
is overridden already using$(CFLAGS)
, which are based on$(WASM_CFLAGS)
./cc @jeroen thoughts? have you run into something similar?