dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.54k stars 4.54k forks source link

AdvSimd doesn't work at all on multiple Android devices #60792

Open MineCake147E opened 2 years ago

MineCake147E commented 2 years ago

Description

AdvSimd.IsSupported returns false, and AdvSimd.Add(Vector128<float>, Vector128<float>) throws PlatformNotSupportedException.

Reproduction Steps

  1. Create a new maui project with net6.0-android.
  2. Replace text inside OnCounterClicked with:
    private void OnCounterClicked(object sender, EventArgs e)
    {
    var sb = new StringBuilder()
    sb.AppendLine($"AdvSimd: {AdvSimd.IsSupported}");
        try
        {
                var r = Vector128.Create(1f);
                var q = AdvSimd.Add(r, r);
                sb.AppendLine($"{q.GetElement(3)}");
        }
        catch (Exception e)
        {
                sb.AppendLine($"{e}");
        }
    CounterLabel.Text = sb.ToString();
        SemanticScreenReader.Announce(CounterLabel.Text);
    }
  3. Build and deploy in Release mode.
  4. Run the app.
  5. Tap the counter.

Expected behavior

Shows

AdvSimd: true
2

Actual behavior

Shows

AdvSimd: false

and Exception details

Regression?

No response

Known Workarounds

No response

Configuration

EDIT: Updated Environment information and added a device.

EDIT: Visual Studio 2022 installation ``` Microsoft Visual Studio Community 2022 Version 17.3.0 Preview 3.0 VisualStudio.17.Preview/17.3.0-pre.3.0+32708.82 Microsoft .NET Framework Version 4.8.04084 インストールされているバージョン:Community Visual C++ 2022 00482-90000-00000-AA086 Microsoft Visual C++ 2022 ASP.NET and Web Tools 17.3.364.15177 ASP.NET and Web Tools AvaloniaPackage Extension 1.0 AvaloniaPackage Visual Studio Extension Detailed Info Azure App Service Tools v3.0.0 17.3.364.15177 Azure App Service Tools v3.0.0 Boost.Test のテスト アダプター 1.0 Boost.Test 向けに作成された単体テストを含む、Visual Studio のテスト ツールを有効にします。拡張機能のインストール ディレクトリに、使用条件およびサード パーティからの通知が含まれています。 C# ツール 4.3.0-3.22329.30+29e657c0582904529bae2a87c227220e03f509cf IDE で使用する C# コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。 Code Cleanup On Save 1.0.12 Automatically run one of the Code Clean profiles when saving the document. This ensures your code is always formatted correctly and follows your coding style conventions. CodeMaid 12.0 CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding. Common Azure Tools 1.10 Azure Mobile Services および Microsoft Azure Tools で使用する共通サービスを提供します。 Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. File Icons 2.7 Adds icons for files that are not recognized by Solution Explorer GhostDoc 22.2.22190.0 (Not Loaded) Generate XML Comments from your code, maintain clean and up-to-date documentation, produce help documentation in multiple formats, use intelligent source code Spell Checker in Visual Studio. Linux コア ダンプ デバッグ 1.0.9.32708 Linux コア ダンプのデバッグを有効にします。 Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Mono Debugging for Visual Studio 17.3.20 (3f4cb00) Support for debugging Mono processes with Visual Studio. NuGet パッケージ マネージャー 6.3.0 Visual Studio 内の NuGet パッケージ マネージャー。NuGet の詳細については、https://docs.nuget.org/ にアクセスしてください Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387 ASP.NET Core Razor の言語サービスを提供します。 SonarLint for Visual Studio 6.6.0.49766 SonarLint is an extension to your favorite IDE that provides on-the-fly feedback to developers on new bugs and quality issues injected into their code. Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. Test Adapter for Google Test 1.0 Google Test 向けに作成された単体テストを含む、Visual Studio のテスト ツールを有効にします。拡張機能のインストール ディレクトリに、使用条件およびサード パーティからの通知が含まれています。 Tweaks 2022 1.1.134 A collection of minor fixes and tweaks for Visual Studio to reduce the paper cuts and make you a happier developer TypeScript Tools 17.0.10701.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic ツール 4.3.0-3.22329.30+29e657c0582904529bae2a87c227220e03f509cf IDE で使用する Visual Basic コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。 Visual C++ for Cross Platform Mobile Development (Android) 17.0.32708.82 Visual C++ for Cross Platform Mobile Development (Android) Visual C++ for Linux Development 1.0.9.32708 Visual C++ for Linux Development Visual F# Tools 17.1.0-beta.22327.2+ddc90b20287a765a9d526da42b3be0dd8e907ec5 Microsoft Visual F# Tools Visual Studio Color Theme Designer 1.0 Allows users to create and edit Visual Studio themes. Themes can customize colors used for menus, toolbars, tabs, titlebars, the text editor, and other environment colors. Visual Studio IntelliCode 2.2 Visual Studio 向けの AI 支援付き開発。 Visual Studio Spell Check Everywhere VSSpellCheckEverywhere An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes. https://GitHub.com/EWSoftware/VSSpellChecker Visual Studio Spell Checker VSSpellChecker An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows. https://GitHub.com/EWSoftware/VSSpellChecker VisualStudio.DeviceLog 1.0 パッケージに関する情報 VisualStudio.Mac 1.0 Mac Extension for Visual Studio Xamarin 17.3.0.288 (main@5d42bb2) Xamarin.iOS と Xamarin.Android の開発を有効にする Visual Studio 拡張機能 Xamarin Designer 17.3.0.202 (remotes/origin/d17-3@6ce0bfa51) Visual Studio で Xamarin Designer ツールを有効にするための Visual Studio 拡張機能。 Xamarin Templates 17.2.28 (9b3d244) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 13.0.0.0 (d17-3/030cd63) Xamarin.Android Reference Assemblies and MSBuild support. Mono: dffa5ab Java.Interop: xamarin/java.interop/d17-3@7716ae53 SQLite: xamarin/sqlite/3.38.5@df4deab Xamarin.Android Tools: xamarin/xamarin-android-tools/main@14076a6 Xamarin.iOS and Xamarin.Mac SDK 15.11.0.308 (7ad9f8893) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```

Other information

Other intrinsics such as ArmBase and Dp did not work at all on both devices, and Vector.IsHardwareAccelerated also returned false, meaning that SIMD is currently not available at all.

dotnet-issue-labeler[bot] commented 2 years ago

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.

tannergooding commented 2 years ago

CC. @imhameed, @fanyang-mono

This is dependent on Mono and is tracked by https://github.com/dotnet/runtime/issues/43051

MineCake147E commented 2 years ago

Thank you for reply.
I updated my Visual Studio 2022 configuration.
I'm glad if it helps.

ghost commented 2 years ago

Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics See info in area-owners.md if you want to be subscribed.

Issue Details
### Description `AdvSimd.IsSupported` returns `false`, and `AdvSimd.Add(Vector128, Vector128)` throws `PlatformNotSupportedException`. ### Reproduction Steps 1. Create a new maui project with `net6.0-android`. 2. Replace text inside `OnCounterClicked` with: ```csharp private void OnCounterClicked(object sender, EventArgs e) { var sb = new StringBuilder() sb.AppendLine($"AdvSimd: {AdvSimd.IsSupported}"); try { var r = Vector128.Create(1f); var q = AdvSimd.Add(r, r); sb.AppendLine($"{q.GetElement(3)}"); } catch (Exception e) { sb.AppendLine($"{e}"); } CounterLabel.Text = sb.ToString(); SemanticScreenReader.Announce(CounterLabel.Text); } ``` 3. Build and deploy in Release mode. 4. Run the app. 5. Tap the counter. ### Expected behavior Shows ``` AdvSimd: true 2 ``` EDIT: miscalculation (my bad...) ### Actual behavior Shows ``` AdvSimd: false ``` and Exception details ### Regression? _No response_ ### Known Workarounds _No response_ ### Configuration
EDIT: Visual Studio 2022 installation ``` Microsoft Visual Studio Community 2022 Preview Version 17.0.0 Preview 6.0 VisualStudio.17.Preview/17.0.0-pre.6.0+31815.197 Microsoft .NET Framework Version 4.8.04084 インストールされているバージョン:Community Visual C++ 2022 00482-90000-00000-AA086 Microsoft Visual C++ 2022 ASP.NET and Web Tools 2019 17.0.776.61824 ASP.NET and Web Tools 2019 Azure App Service Tools v3.0.0 17.0.776.61824 Azure App Service Tools v3.0.0 Boost.Test のテスト アダプター 1.0 Boost.Test 向けに作成された単体テストを含む、Visual Studio のテスト ツールを有効にします。拡張機能のインストール ディレクトリに、使用条件およびサード パーティからの通知が含まれています。 C# ツール 4.0.0-6.21514.4+df45061e218c9b5813c5531bc06fb238a23e30f6 IDE で使用する C# コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。 Code Cleanup On Save 1.0.12 Automatically run one of the Code Clean profiles when saving the document. This ensures your code is always formatted correctly and follows your coding style conventions. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Extensibility Message Bus 1.2.6 (master@34d6af2) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. File Icons 2.7 Adds icons for files that are not recognized by Solution Explorer Linux コア ダンプ デバッグ 1.0.9.31808 Linux コア ダンプのデバッグを有効にします。 Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ ウィザード 1.0 Microsoft Visual C++ ウィザード Microsoft Visual Studio VC パッケージ 1.0 Microsoft Visual Studio VC パッケージ Mono Debugging for Visual Studio 17.0.11 (54f19d2) Support for debugging Mono processes with Visual Studio. NuGet パッケージ マネージャー 6.0.0 Visual Studio 内の NuGet パッケージ マネージャー。NuGet の詳細については、https://docs.nuget.org/ にアクセスしてください ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. Test Adapter for Google Test 1.0 Google Test 向けに作成された単体テストを含む、Visual Studio のテスト ツールを有効にします。拡張機能のインストール ディレクトリに、使用条件およびサード パーティからの通知が含まれています。 TypeScript Tools 17.0.1001.2002 TypeScript Tools for Microsoft Visual Studio Visual Basic ツール 4.0.0-6.21514.4+df45061e218c9b5813c5531bc06fb238a23e30f6 IDE で使用する Visual Basic コンポーネント。プロジェクトの種類や設定に応じて、異なるバージョンのコンパイラを使用できます。 Visual C++ for Cross Platform Mobile Development (Android) 17.0.31808.319 Visual C++ for Cross Platform Mobile Development (Android) Visual C++ for Linux Development 1.0.9.31808 Visual C++ for Linux Development Visual F# Tools 17.0.0-beta.21472.3+f0b5108c92b92ba5ee440228aadba3bae79b43a3 Microsoft Visual F# Tools Visual Studio Code デバッグ アダプターのホスト パッケージ 1.0 Visual Studio Code デバッグ アダプターを Visual Studio でホストするための相互運用レイヤー Visual Studio IntelliCode 2.2 Visual Studio 向けの AI 支援付き開発。 Visual Studio Spell Check Everywhere VSSpellCheckEverywhere An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes. https://GitHub.com/EWSoftware/VSSpellChecker Visual Studio Spell Checker VSSpellChecker An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows. https://GitHub.com/EWSoftware/VSSpellChecker Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake VisualStudio.DeviceLog 1.0 パッケージに関する情報 VisualStudio.Mac 1.0 Mac Extension for Visual Studio WSL を使用した .NET Core デバッグ 1.0 WSL を使用した .NET Core デバッグ Xamarin 17.0.0.324 (d17-0@b917ee4) Xamarin.iOS と Xamarin.Android の開発を有効にする Visual Studio 拡張機能 Xamarin Designer 17.0.0.175 (remotes/origin/main@2e64cffa4) Visual Studio で Xamarin Designer ツールを有効にするための Visual Studio 拡張機能。 Xamarin Templates 17.0.13 (1bcd73e) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 12.1.0.4 (d17-0/642abcd) Xamarin.Android Reference Assemblies and MSBuild support. Mono: c633fe9 Java.Interop: xamarin/java.interop/d17-0@8f7ddcdd ProGuard: Guardsquare/proguard/v7.0.1@912d149 SQLite: xamarin/sqlite/3.36.0@a575761 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-0@a5194e9 Xamarin.iOS and Xamarin.Mac SDK 15.0.0.17 (344dcfc35) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support. ```
- PC: Modified DELL XPS 8700 - OS: Windows 10 21H1 - CPU: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz 3.60 GHz - RAM: 16GB DDR3 - Graphics: NVIDIA GeForce GTX1060(6GB) Compatible - Storage: - OS(C:) : Western Digital WDC WDS100T2B0A-00SM50 1000.2 GB SATA SSD - WORKSPACE(D:) : Seagate ST1000DM003-1ER162 1000.2 GB 7200RPM SATA HDD - ARCHIVE(E:) : HGST HCC541010B9E660 1000.2 GB 5400RPM SATA HDD - Phone: Sony Xperia™ XZ3(SOV39) - OS: Android 10(52.1.C.0.360) - SoC: Qualcomm Snapdragon 845 ### Other information Other intrinsics such as ArmBase and Dp didn't work as well. Even `Vector.IsHardwareAccelerated` returns `false`, meaning SIMD isn't currently available at all.
Author: MineCake147E
Assignees: -
Labels: `area-System.Runtime.Intrinsics`, `untriaged`
Milestone: -
dakersnar commented 1 year ago

@fanyang-mono is this still planned for .NET 7.0? If not, can you please move it to 8.0? Thanks!

fanyang-mono commented 1 year ago

This might have been fixed by https://github.com/dotnet/runtime/pull/72982. I will try it out this week. If not, will move this to .NET8

fanyang-mono commented 1 year ago

AdvSimd is only supported when LLVM is enabled. This issue will persist till LLVM works on MAUI Android, which teams are focused on fixing some issues. For example, https://github.com/dotnet/runtime/issues/73304 https://github.com/dotnet/runtime/issues/68914

We should validate this again after LLVM is enabled. Moving this issue to 8.0.0

fanyang-mono commented 11 months ago

AdvSimd can only be enabled when both LLVM and JIT supports it on Arm64. The support for JIT hasn't landed yet. Moving this to .NET9.