-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[openmp][wasm] Allow compiling OpenMP to WebAssembly #71297
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
#define KMP_OS_WINDOWS 0 | ||
#define KMP_OS_HURD 0 | ||
#define KMP_OS_SOLARIS 0 | ||
#define KMP_OS_WASI 0 | ||
#define KMP_OS_UNIX 0 /* disjunction of KMP_OS_LINUX, KMP_OS_DARWIN etc. */ | ||
|
||
#ifdef _WIN32 | ||
|
@@ -76,14 +77,20 @@ | |
#define KMP_OS_SOLARIS 1 | ||
#endif | ||
|
||
#if (defined __wasi__) || (defined __EMSCRIPTEN__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @abrown The changes in this PR will not allow openmp to compile under emscripten, the changes here will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good finds, both of them. Let's discuss in #95169. |
||
#undef KMP_OS_WASI | ||
#define KMP_OS_WASI 1 | ||
#endif | ||
|
||
#if (1 != KMP_OS_LINUX + KMP_OS_DRAGONFLY + KMP_OS_FREEBSD + KMP_OS_NETBSD + \ | ||
KMP_OS_OPENBSD + KMP_OS_DARWIN + KMP_OS_WINDOWS + KMP_OS_HURD + \ | ||
KMP_OS_SOLARIS) | ||
KMP_OS_SOLARIS + KMP_OS_WASI) | ||
#error Unknown OS | ||
#endif | ||
|
||
#if KMP_OS_LINUX || KMP_OS_DRAGONFLY || KMP_OS_FREEBSD || KMP_OS_NETBSD || \ | ||
KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_SOLARIS | ||
KMP_OS_OPENBSD || KMP_OS_DARWIN || KMP_OS_HURD || KMP_OS_SOLARIS || \ | ||
KMP_OS_WASI | ||
#undef KMP_OS_UNIX | ||
#define KMP_OS_UNIX 1 | ||
#endif | ||
|
@@ -196,6 +203,10 @@ | |
#define KMP_ARCH_ARM 1 | ||
#endif | ||
|
||
#if defined(__wasm32__) | ||
#define KMP_ARCH_WASM 1 | ||
#endif | ||
|
||
#if defined(__MIC__) || defined(__MIC2__) | ||
#define KMP_MIC 1 | ||
#if __MIC2__ || __KNC__ | ||
|
@@ -212,7 +223,8 @@ | |
#endif | ||
|
||
/* Specify 32 bit architectures here */ | ||
#define KMP_32_BIT_ARCH (KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS) | ||
#define KMP_32_BIT_ARCH \ | ||
(KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_MIPS || KMP_ARCH_WASM) | ||
|
||
// Platforms which support Intel(R) Many Integrated Core Architecture | ||
#define KMP_MIC_SUPPORTED \ | ||
|
@@ -222,7 +234,7 @@ | |
#if (1 != KMP_ARCH_X86 + KMP_ARCH_X86_64 + KMP_ARCH_ARM + KMP_ARCH_PPC64 + \ | ||
KMP_ARCH_AARCH64 + KMP_ARCH_MIPS + KMP_ARCH_MIPS64 + \ | ||
KMP_ARCH_RISCV64 + KMP_ARCH_LOONGARCH64 + KMP_ARCH_VE + \ | ||
KMP_ARCH_S390X) | ||
KMP_ARCH_S390X + KMP_ARCH_WASM) | ||
#error Unknown or unsupported architecture | ||
#endif | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@abrown Hey Andrew, this seems to break linking under wasm.
Previously when it common linked it was required to define these variables through assembly, hence you updates to z_Linux_asm.S specially
.global .gomp_critical_user_.reduction.var
are actually no longer required.But now that they are external linkage they suffer from duplicate symbol problem.
For critical sections this can avoided if you manually add a name to the critical section that does not conflict
omp critical(UniqueValue)
but for reduction allowing them to be named is not an option, so if multiple compilation units use reduction you will introduce a duplicate symbols
I am wonder if something like
InternalLinkage
is more appropriate