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

[Wasm] AOT support for threading-enabled runtime #70489

Closed
Tracked by #68162
jeromelaban opened this issue Jun 9, 2022 · 8 comments
Closed
Tracked by #68162

[Wasm] AOT support for threading-enabled runtime #70489

jeromelaban opened this issue Jun 9, 2022 · 8 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-Codegen-LLVM-mono
Milestone

Comments

@jeromelaban
Copy link
Contributor

Description

Building AOT images with threading enabled is failing.

Reproduction Steps

When building AOT images with threading enabled, the following lines:

#ifndef DISABLE_THREADS
monoeg_g_setenv ("MONO_THREADS_SUSPEND", "coop", 0);
monoeg_g_setenv ("MONO_SLEEP_ABORT_LIMIT", "5000", 0);
#endif

cause the following error:

`not compiled with safepoints`

@lambdageek mentioned that the environment needs to have MONO_THREADS_SUSPEND=coop set before invoking the compiler, but the compilation fails with the following:

* Assertion at /__w/Uno.DotnetRuntime.WebAssembly/Uno.DotnetRuntime.WebAssembly/runtime/src/mono/mono/mini/mini.c:2752, condition `mini_safepoints_enabled ()' not met

mini_safepoints_enabled (void)
{
#if defined (TARGET_WASM)
return FALSE;
#else
return TRUE;
#endif

Expected behavior

Compilation succeeds.

Actual behavior

See above.

Regression?

No

Known Workarounds

None

Configuration

213b4d4

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Jun 9, 2022
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@lambdageek lambdageek added arch-wasm WebAssembly architecture and removed untriaged New issue has not been triaged by the area owner labels Jun 9, 2022
@ghost
Copy link

ghost commented Jun 9, 2022

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

Building AOT images with threading enabled is failing.

Reproduction Steps

When building AOT images with threading enabled, the following lines:

#ifndef DISABLE_THREADS
monoeg_g_setenv ("MONO_THREADS_SUSPEND", "coop", 0);
monoeg_g_setenv ("MONO_SLEEP_ABORT_LIMIT", "5000", 0);
#endif

cause the following error:

`not compiled with safepoints`

@lambdageek mentioned that the environment needs to have MONO_THREADS_SUSPEND=coop set before invoking the compiler, but the compilation fails with the following:

* Assertion at /__w/Uno.DotnetRuntime.WebAssembly/Uno.DotnetRuntime.WebAssembly/runtime/src/mono/mono/mini/mini.c:2752, condition `mini_safepoints_enabled ()' not met

mini_safepoints_enabled (void)
{
#if defined (TARGET_WASM)
return FALSE;
#else
return TRUE;
#endif

Expected behavior

Compilation succeeds.

Actual behavior

See above.

Regression?

No

Known Workarounds

None

Configuration

213b4d4

Other information

No response

Author: jeromelaban
Assignees: -
Labels:

arch-wasm, untriaged

Milestone: -

@lambdageek
Copy link
Member

Ideally we can produce a single mono-aot-cross AOT compiler that is usable for wasm with and without threading. So we shoudl get rid of #ifdef paths and replace them with an aot compiler flag to decide if we're targeting a threaded runtime.

Another thing the flag could control is whether LLVM is allowed to use post-MVP atomics opcodes

@lewing
Copy link
Member

lewing commented Jun 13, 2022

@vargaz did #70520 resolve this fully?

@jeromelaban
Copy link
Contributor Author

@lewing This issue was using a similar change in the runtime (with safe point enabled) and it is still present.

@radical
Copy link
Member

radical commented Aug 11, 2022

@kg should this be moved to 8.0?

@kg
Copy link
Member

kg commented Aug 11, 2022

I think so.

@radical radical modified the milestones: 7.0.0, 8.0.0 Aug 11, 2022
@lambdageek
Copy link
Member

I think we're done here, actually. The AOT compiler now has a --wasm-gc-safepoints and the Wasm SDK now passes it automatically by default when the WasmEnableThreads property is true.

demo: https://lambdageek.dev/dotnet-wasm-raytracer/ (AOT+SIMD+threads)

@ghost ghost locked as resolved and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-Codegen-LLVM-mono
Projects
None yet
Development

No branches or pull requests

5 participants