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] Enable SIMD #80797

Merged
merged 38 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
47be1e2
[wasm] Enable SIMD
radekdoulik Jan 18, 2023
a0fc3eb
Let old V8 use simd
radekdoulik Jan 18, 2023
b695c92
[wasm] ManagedToNativeGenerator: Skip unmanaged dlls
radical Jan 19, 2023
9c0ea37
Merge remote-tracking branch 'origin/main' into pr-wasm-enable-simd
radical Jan 19, 2023
cb53bc6
[wasm] WasmApp.Native.targets: do not trigger relinking when WasmEnab…
radical Jan 19, 2023
68da732
Use staging image with newer v8
radekdoulik Jan 19, 2023
b260375
[wasm] WasmAppHost: Add support for host arguments
radical Jan 20, 2023
d12ab67
[wasm] console template: Add --experimental-wasm-simd to node, and re…
radical Jan 20, 2023
5f68d50
[wasm] Pass --experiment-wasm-simd for aot library tests too
radical Jan 20, 2023
432e144
Merge branch 'pr-wasm-enable-simd' of https://github.com/radekdoulik/…
radical Jan 20, 2023
a15b3ef
Try to pass full path to v8
radekdoulik Jan 20, 2023
033d473
Use docker image for all wasm helix jobs
radekdoulik Jan 20, 2023
5dec1aa
Set DOTNET_CLI_HOME under workitem payload
radekdoulik Jan 23, 2023
80f678a
Revert "Try to pass full path to v8"
radekdoulik Jan 23, 2023
7242ab8
Use DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
radekdoulik Jan 23, 2023
37080d6
Set NeedsEMSDKNode to false
radekdoulik Jan 23, 2023
7eb08b7
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Jan 25, 2023
aa544f4
Revert "Set DOTNET_CLI_HOME under workitem payload"
radekdoulik Jan 25, 2023
dc72268
Set DOTNET_CLI_HOME under workitem payload
radekdoulik Jan 23, 2023
9e1640a
Reverse the test here as we don't relink anymore
radekdoulik Jan 31, 2023
ca896d7
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Jan 31, 2023
b836780
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Feb 6, 2023
1371cce
Set _ExtraTrimmerArgs for tests
radekdoulik Feb 6, 2023
758d5b6
Put the SIMD/trim related props in separate group
radekdoulik Feb 6, 2023
f736fa5
Add dynamic dependency
radekdoulik Feb 7, 2023
42ce1df
Disable Vector128IsHardwareAcceleratedTest
radekdoulik Feb 7, 2023
d8c5b6f
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Feb 9, 2023
3c02f89
Disable GenericVectorTests.IsHardwareAcceleratedTest
radekdoulik Feb 9, 2023
c401b52
Disable check_no_intrinsic_cattr in emit_vector_2_3_4
radekdoulik Feb 10, 2023
7e054d8
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Feb 20, 2023
143a73b
[mono] Disable few quaternion intrinsics
radekdoulik Feb 20, 2023
0114506
Change comparison order
radekdoulik Feb 20, 2023
2e0f09b
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Feb 21, 2023
d05cb53
Use stable images
radekdoulik Feb 21, 2023
44c4b13
Merge branch 'main' into pr-wasm-enable-simd
radical Feb 25, 2023
aed4dd2
WBT: Add --engine-arg=--experimental-wasm-simd for node, and v8
radical Feb 25, 2023
cfc855e
Do not skip dotnet 1st time experience anymore
radekdoulik Feb 27, 2023
7e5505a
Merge remote-tracking branch 'remotes/origin/main' into pr-wasm-enabl…
radekdoulik Feb 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eng/pipelines/libraries/helix-queues-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:

# Browser WebAssembly
- ${{ if eq(parameters.platform, 'browser_wasm') }}:
- Ubuntu.1804.Amd64.Open
- (Ubuntu.1804.Amd64)Ubuntu.1804.Amd64.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-helix-webassembly

# Browser WebAssembly Firefox
- ${{ if eq(parameters.platform, 'browser_wasm_firefox') }}:
Expand Down
2 changes: 2 additions & 0 deletions eng/testing/WasmRunnerAOTTemplate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ if [[ "$XHARNESS_COMMAND" == "test" ]]; then
if [[ -z "$JS_ENGINE" ]]; then
if [[ "$SCENARIO" == "WasmTestOnNodeJS" || "$SCENARIO" == "wasmtestonnodejs" ]]; then
JS_ENGINE="--engine=NodeJS"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
else
JS_ENGINE="--engine=V8"
JS_ENGINE_ARGS="$JS_ENGINE_ARGS --engine-arg=--experimental-wasm-simd"
radekdoulik marked this conversation as resolved.
Show resolved Hide resolved
fi
fi

Expand Down
15 changes: 15 additions & 0 deletions eng/testing/tests.wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@
<BuildAOTTestsOn Condition="'$(BuildAOTTestsOn)' == ''">local</BuildAOTTestsOn>
</PropertyGroup>

<PropertyGroup Condition="'$(BuildAOTTestsOn)' == 'local'">
<!--
When building for BuildAOTTestsOnHelix=true, the WasmApp*targets are *not* imported, because
they get instead used by the AOT proxy project on helix.

On the build machine only the regular part of the build is run, which includes trimming. But if
WasmApp*targets modify any trimming arguments, then those will not get picked up by this build.
For example - linker substitution files used with simd builds.

So, set those parameters explicitly here.
-->
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' == 'true'">$(_ExtraTrimmerArgs) --substitutions &quot;$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.WasmIntrinsics.xml&quot;</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs Condition="'$(WasmEnableSIMD)' != 'true'">$(_ExtraTrimmerArgs) --substitutions &quot;$(MonoProjectRoot)\wasm\build\ILLink.Substitutions.NoWasmIntrinsics.xml&quot;</_ExtraTrimmerArgs>
</PropertyGroup>

<ItemGroup>
<_AOT_InternalForceInterpretAssemblies Include="@(HighAotMemoryUsageAssembly)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ static GenericVectorTests()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/81785", TestPlatforms.Browser)]
public unsafe void IsHardwareAcceleratedTest()
{
MethodInfo methodInfo = typeof(Vector).GetMethod("get_IsHardwareAccelerated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Reflection;
using System.Runtime.InteropServices;
Expand All @@ -11,6 +12,8 @@ namespace System.Runtime.Intrinsics.Tests.Vectors
public sealed class Vector128Tests
{
[Fact]
[DynamicDependency(DynamicallyAccessedMemberTypes.PublicProperties, typeof(Vector128))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/81785", TestPlatforms.Browser)]
public unsafe void Vector128IsHardwareAcceleratedTest()
{
MethodInfo methodInfo = typeof(Vector128).GetMethod("get_IsHardwareAccelerated");
Expand Down
2 changes: 1 addition & 1 deletion src/libraries/sendtohelix-wasm.targets
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

<NeedsWorkload Condition="'$(Scenario)' == 'BuildWasmApps'">true</NeedsWorkload>
<NeedsEMSDK Condition="'$(NeedsToBuildWasmAppsOnHelix)' == 'true'">true</NeedsEMSDK>
<NeedsEMSDKNode Condition="'$(Scenario)' == 'WasmTestOnNodeJS' or '$(Scenario)' == 'BuildWasmApps'">true</NeedsEMSDKNode>
<NeedsEMSDKNode Condition="'$(Scenario)' == 'WasmTestOnNodeJS' or '$(Scenario)' == 'BuildWasmApps'">false</NeedsEMSDKNode>
radekdoulik marked this conversation as resolved.
Show resolved Hide resolved
<NeedsToRunOnBrowser Condition="'$(Scenario)' == 'WasmTestOnBrowser' or '$(Scenario)' == 'BuildWasmApps'">true</NeedsToRunOnBrowser>
<NeedsBuiltNugets Condition="'$(Scenario)' == 'BuildWasmApps'">true</NeedsBuiltNugets>

Expand Down
3 changes: 2 additions & 1 deletion src/mono/mono/mini/simd-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1954,7 +1954,8 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f

id = lookup_intrins (vector2_methods, sizeof (vector2_methods), cmethod);
if (id == -1) {
check_no_intrinsic_cattr (cmethod);
// https://github.com/dotnet/runtime/issues/81961
// check_no_intrinsic_cattr (cmethod);
return NULL;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace Wasm.Build.Tests;
public class NodeJSHostRunner : IHostRunner
{
public string GetTestCommand() => "wasm test";
public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace";
public string GetXharnessArgsOtherOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --locale={options.environmentLocale}";
public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --engine-arg=--experimental-wasm-simd";
public string GetXharnessArgsOtherOS(XHarnessArgsOptions options) => $"--js-file={options.jsRelativePath} --engine=NodeJS -v trace --locale={options.environmentLocale} --engine-arg=--experimental-wasm-simd";
public bool UseWasmConsoleOutput() => true;
public bool CanRunWBT() => true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Wasm.Build.Tests;

public class V8HostRunner : IHostRunner
{
private string GetXharnessArgs(string jsRelativePath) => $"--js-file={jsRelativePath} --engine=V8 -v trace";
private string GetXharnessArgs(string jsRelativePath) => $"--js-file={jsRelativePath} --engine=V8 -v trace --engine-arg=--experimental-wasm-simd";

public string GetTestCommand() => "wasm test";
public string GetXharnessArgsWindowsOS(XHarnessArgsOptions options) => GetXharnessArgs(options.jsRelativePath);
Expand Down
4 changes: 2 additions & 2 deletions src/mono/wasm/Wasm.Build.Tests/WasmSIMDTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public WasmSIMDTests(ITestOutputHelper output, SharedBuildPerTestClassFixture bu

[Theory]
[MemberData(nameof(MainMethodTestData), parameters: new object[] { /*aot*/ false, RunHost.All })]
public void BuildWithSIMD_NoAOT_ShouldRelink(BuildArgs buildArgs, RunHost host, string id)
public void BuildWithSIMD_NoAOT_ShouldNotRelink(BuildArgs buildArgs, RunHost host, string id)
{
string projectName = $"sim_with_workload_no_aot";
buildArgs = buildArgs with { ProjectName = projectName };
Expand All @@ -29,7 +29,7 @@ public void BuildWithSIMD_NoAOT_ShouldRelink(BuildArgs buildArgs, RunHost host,
new BuildProjectOptions(
InitProject: () => File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), s_simdProgramText),
Publish: false,
DotnetWasmFromRuntimePack: false));
DotnetWasmFromRuntimePack: true));

if (!_buildContext.TryGetBuildFor(buildArgs, out _))
{
Expand Down
5 changes: 1 addition & 4 deletions src/mono/wasm/build/WasmApp.Native.targets
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@
<!-- build AOT, only if explicitly requested -->
<WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true' and '$(RunAOTCompilationAfterBuild)' == 'true'">true</WasmBuildNative>

<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmEnableSIMD)' == 'true'">true</WasmBuildNative>

<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>

<WasmBuildNative Condition="'$(WasmBuildNative)' == ''">false</WasmBuildNative>
Expand All @@ -125,7 +123,6 @@
<!-- AOT==true overrides WasmBuildNative -->
<WasmBuildNative Condition="'$(RunAOTCompilation)' == 'true'">true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and @(NativeFileReference->Count()) > 0" >true</WasmBuildNative>
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(WasmEnableSIMD)' == 'true'">true</WasmBuildNative>

<!-- not aot, not trimmed app, no reason to relink -->
<WasmBuildNative Condition="'$(WasmBuildNative)' == '' and '$(PublishTrimmed)' != 'true'">false</WasmBuildNative>
Expand Down Expand Up @@ -203,7 +200,7 @@
<_EmccCommonFlags Include="-v" Condition="'$(EmccVerbose)' != 'false'" />
<_EmccCommonFlags Include="-s DISABLE_EXCEPTION_CATCHING=0" Condition="'$(WasmEnableExceptionHandling)' == 'false'" />
<_EmccCommonFlags Include="-fwasm-exceptions" Condition="'$(WasmEnableExceptionHandling)' == 'true'" />
<_EmccCommonFlags Include="-msimd128" Condition="'$(WasmEnableSIMD)' == 'true'" />
<_EmccCommonFlags Include="-msimd128" Condition="'$(WasmEnableSIMD)' == 'true' and '$(_WasmShouldAOT)' == 'true'" />

<_EmccIncludePaths Include="$(_WasmIntermediateOutputPath.TrimEnd('\/'))" />
<_EmccIncludePaths Include="$(_WasmRuntimePackIncludeDir)mono-2.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/mono/wasm/build/WasmApp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
<PropertyGroup>
<WasmDedup Condition="'$(WasmDedup)' == ''">true</WasmDedup>
<WasmEnableExceptionHandling Condition="'$(WasmEnableExceptionHandling)' == ''">false</WasmEnableExceptionHandling>
<WasmEnableSIMD Condition="'$(WasmEnableSIMD)' == ''">false</WasmEnableSIMD>
<WasmEnableSIMD Condition="'$(WasmEnableSIMD)' == ''">true</WasmEnableSIMD>

<!--<WasmStripAOTAssemblies Condition="'$(AOTMode)' == 'LLVMOnlyInterp'">false</WasmStripAOTAssemblies>-->
<!--<WasmStripAOTAssemblies Condition="'$(WasmStripAOTAssemblies)' == ''">$(RunAOTCompilation)</WasmStripAOTAssemblies>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
{
"name": "node",
"js-path": "main.mjs",
"Host": "nodejs"
},
{
"name": "v8",
"js-path": "main.mjs",
"Host": "v8"
"Host": "nodejs",
"host-args": [
"--experimental-wasm-simd"
]
radekdoulik marked this conversation as resolved.
Show resolved Hide resolved
}
]
}
Expand Down