Skip to content

Request: ARM SME support (for Apple M4).. #4715

Closed

Description

@oscarbg

No need for unofficial Apple AMX intruction set on M4..
2tflops possible..

Activity

  1. martin-frbg commented on May 23, 2024

    @martin-frbg
    Collaborator

    PRs welcome... do you have the hardware to test ?

  2. oscarbg commented on May 24, 2024

    @oscarbg
    Author

    Not yet.. waiting for a mac mini m4..

  3. brada4 commented on May 24, 2024

    @brada4
  4. martin-frbg commented on May 24, 2024

    @martin-frbg
    Collaborator

    try reading that again, it's about SME...

  5. brada4 commented on May 24, 2024

    @brada4
  6. Mousius commented on May 25, 2024

    @Mousius
    Contributor

    You can develop and test using the Fixed Virtual Platform (FVP):
    apache/tvm#16755
    apache/tvm#16749

  7. brada4 commented on May 25, 2024

    @brada4
  8. martin-frbg commented on Aug 16, 2024

    @martin-frbg
    Collaborator

    some implementation hints there: https://scalable.uni-jena.de/opt/sme/index.html

  9. oscarbg commented on Nov 22, 2024

    @oscarbg
    Author

    Hi,
    any news?
    have a Mac Mini m4 to test..

  10. martin-frbg commented on Nov 22, 2024

    @martin-frbg
    Collaborator

    Bought an M4 mini myself recently but have not gotten around to doing much with it yet.

  11. martin-frbg commented on Feb 22, 2025

    @martin-frbg
    Collaborator

    #5084 added SME for the "small matrix" SGEMM pathway but needs some small tweaks to connect the M4 cpu target to it

    #5011 has a more general SME GEMM kernel but needs fixes for proper SYMM/TRMM support before it can be merged

  12. ITCJ commented on Mar 27, 2025

    @ITCJ

    #5084 added SME for the "small matrix" SGEMM pathway but needs some small tweaks to connect the M4 cpu target to it

    #5011 has a more general SME GEMM kernel but needs fixes for proper SYMM/TRMM support before it can be merged

    Based on a SC24 workshop Hello SME, llvm/llvm-project#114987 and llvm/llvm-project#95478 . Apple M4 does not support SVE outside of streaming.
    However, concurrent [WIP] #5011 is on top of KERNEL.ARMV8SVE. Result in illegal instruction. Any good ideas to solve that? Is create a new KERNEL.M4SME2 based on KERNEL.ARMV8 a good idea?

  13. ITCJ commented on Mar 27, 2025

    @ITCJ

    Further more, I have made some test on differences between SME1 and SME2 recently. It's quiet different to achieve best performance.
    I don‘t known if ACLE could fully utilize these resources.

  14. martin-frbg commented on Mar 27, 2025

    @martin-frbg
    Collaborator

    Yes, M4 only does streaming SVE so you'd need at least some setup code to enter streaming mode and perhaps save some dual-use registers beforehand, or even work in a totally different set of registers than what the existing SVE code uses.

    Both #5011 and #5084 introduced an ARMV9SME target for differentiation, it would also be possible to select kernel implementations (either at the KERNEL file level or within individual implementations) based on HAVE_SME or a similiar define. As #5011 is a WIP only concerned with GEMM and related functions, it does not work outside its narrow scope.

    The way forward - at least short-term - should be to split out M4 from the general "VORTEX" target into its own designation and enable the SME-based "small gemm" pathway for it. I hope to complete this very soon.

  15. violet73 commented on Apr 10, 2025

    @violet73

    Hi, I would like to ask why I encountered the following error on M4pro:

    Image

    Is it possible that my compiler does not recognize streaming flags?

    Compilation:
    clang -g -O0 -march=armv9.2-a+sme+sme2 ./test_sme_acle.cc -o ./test_sme_acle

    Clang version:
    Homebrew clang version 20.1.2
    Target: arm64-apple-darwin24.3.0
    Thread model: posix
    InstalledDir: /opt/homebrew/Cellar/llvm/20.1.2/bin

  16. ITCJ commented on Apr 10, 2025

    @ITCJ

    Hi, I would like to ask why I encountered the following error on M4pro:

    Image

    Is it possible that my compiler does not recognize streaming flags?

    Compilation: clang -g -O0 -march=armv9.2-a+sme+sme2 ./test_sme_acle.cc -o ./test_sme_acle

    Clang version: Homebrew clang version 20.1.2 Target: arm64-apple-darwin24.3.0 Thread model: posix InstalledDir: /opt/homebrew/Cellar/llvm/20.1.2/bin

    looks like the same problem mentioned above. Try using disassemble --mixed to show illegal instruction.

  17. violet73 commented on Apr 10, 2025

    @violet73

    looks like the same problem mentioned above. Try using disassemble --mixed to show illegal instruction.

    Thank you for your kindly reply, I disassembled it in lldb and the illegel instruction turns out to be cntd!

    That means the streaming flags will make the compiler add some illegal sve instructions that are not in streaming mode.

    This is somehow wired. Because I can't manually set the streaming mode before main is called.

    So I tried to remove the streaming flags in main and moved the sve code into another function foo
    with the local streaming flags.

    I also manually placed the invocation statement of foo within smstart and smstop.

    After these, the code could finally run normally!

  18. ITCJ commented on Apr 10, 2025

    @ITCJ

    looks like the same problem mentioned above. Try using disassemble --mixed to show illegal instruction.

    Thank you for your kindly reply, I disassembled it in lldb and the illegel instruction turns out to be cntd!

    That means the streaming flags will make the compiler add some illegal sve instructions that are not in streaming mode.

    This is somehow wired. Because I can't manually set the streaming mode before main is called.

    So I tried to remove the streaming flags in main and moved the sve code into another function foo with the local streaming flags.

    I also manually placed the invocation statement of foo within smstart and smstop.

    After these, the code could finally run normally!

    congrats, I also tried resolve similar issues. I encounter ADVL during unit test.
    加个微信?码发你邮箱了捏。

  19. martin-frbg commented on Apr 11, 2025

    @martin-frbg
    Collaborator

    the fast path for small matrix sgemm should be working on M4 with #5222 - but I'm now stuck on an illegal instruction error involving cntd/cntw myself, trying to get dot_kernel_sve working in streaming mode with the __arm_streaming attribute

  20. ITCJ commented on Apr 14, 2025

    @ITCJ

    the fast path for small matrix sgemm should be working on M4 with #5222 - but I'm now stuck on an illegal instruction error involving cntd/cntw myself, trying to get dot_kernel_sve working in streaming mode with the __arm_streaming attribute

    Is it a bug of LLVM compiler?

  21. martin-frbg commented on Mar 22, 2026

    @martin-frbg
    Collaborator

    Closing as the VORTEXM4 target received SME-based SGEMM/SSYMM/STRMM/SSYRK/SSYR2K in 0.3.31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions