-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
[OpenMP] Clang: cannot compile minimal example to wasm32/wasm64 #52714
Comments
Thanks, Pierre, I confirm the issue (for wasm) narrows down to omp critical. Thanks, S. |
@mf-RDP is it still an issue now? |
@shiltian @mf-RDP I was able to get omp working with the attached patch to the 14.0.0 branch. As i am sure someone with more intimate knowledge of the omp library may see some better ways of doing these things After apply the patch
Then to downstream libraries must compile with I have found that some critical variables in the downstream code consuming this custom built wasm .a may need to create their own assembly(.S) to define the user name critical variables. My assumption here was possibly missing backend to clang omitting the correct assembly? |
@arsnyder16 can you please upload your patch to https://reviews.llvm.org as a WIP review, this way people would be able to comment on the contents. I would suspect that assembly sources should be part of libomp, but I can be wrong, or maybe it can be either way. Wasm has its own atomic operations for synchronization. |
As @penzn mentioned, those assembly has to be properly added to |
@penzn @shiltian Sorry i am not familiar with the process involved here. Someone will need to step me through this. I certainly don't need ownership of this, i am sort of attack the problem for my use case and moved on. I just recently notice this was being discussed so i thought i would offer what i came up. I am happy to get the ball rolling. I am not familiar with Phabricator or where to upload the patch to https://reviews.llvm.org/ |
If there are questions about some of the changes in the patch, i am more than happy to explain what i experienced and my interpretation of why the change was needed |
@arsnyder16 thank you for the patch anyway! Sorry for the extra steps, it is easier to comment on the change directly than referencing lines and files in comments here.
reviews.llvm.org is an LLVM-owned instance of Phabricator, the process is pretty simple if you just use your Github account: login with Github and create a patch (pick LLVM Github Monorepo when it asks for repository), it will let you simply upload a diff. Diff should be ideally regenerated with -U999999 flag, that would show entire files. Let us know if you have any difficulties, I am sure we can work this out. |
Hi! I have a similar use-case where we build our own LLVM with This worked fine with our build from the 13 branch, but when moving to 17.0.6 we start seeing some frontend crashes (i.e. compiling some functions fails, whereas others succeed). Any hints at what could be going on in here?
|
The only clue in that stack trace is that the actual crash happened in |
FWIW, bumping to |
Hi,
this is a copy of issue 186 in https://github.com/WebAssembly/threads/issues/
Please see comments from sbc100 & sunfishcode there.
Compiling a minimal OpenMP example:
#pragma optimize off
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include "anet_intrinsic.h"
//#include <omp.h>
int main() {
#pragma omp parallel num_threads(4)
{
#pragma omp critical
abs(-5555);
}
}
fails:
C:\LLVM\BUILDLLDB\Debug\bin\clang++ -fopenmp -DDEBUG -mbulk-memory -mmutable-globals -O0 -I.. -I.... -I. -Wl,--max-memory=327680 -Wl,--shared-memory -matomics -target wasm32-wasi --sysroot /project/wasi-libc/sysroot-intrin-bulk-memory -Wl,--export-all -Wl,-L. -Wl,--entry=__main_void -Wl,--allow-undefined -o omp_dummy.cc.wasm omp_dummy.cc
Common symbols are not yet implemented for Wasm
While - for the moment - maybe we can leave compiling libomp to the embedder or he can provide appropriate _kmp* functions as runtime imports, providing compilation support would be a great step to OpenMP support.
Question would probably be: can be worked around needing common symbols for omp compilation.
Regards,
S.
The text was updated successfully, but these errors were encountered: