Add m4sme_p and m4sme_e sub-configurations#921
Conversation
- The configuration is optimal for the Apple M4 chip's performance cores with a SVL of 512 bits. - The sgemm kernel's size is 2SVLx2SVL and the dgemm's is 4SVLx2SVL
- Use the ZA tiles' reading capabilities for more efficient packing
- Include packing routines for both kernels - Disable new kernels using an #if 0 block in the m4sme_p subconfig
- Reuse the SVLx4SVL and SVLx8SVL packing routines
- Reuse the 4SVLx2SVL packing routine
- Adjust block size to optimal value for the smaller SME Engine shared by the efficiency core cluster of the Apple M4 chip.
Details: - Add m4sme_p and m4sme_e tests in CI. - Streamline aarch64 testing with QEMU to use single arm64 build. - Add clang-based QEMU tests. - Update compiler toolchains: gcc14 and llvm17 needed for SME2.
|
I made some tweaks to the compiler support and added tests in CI. It may take a couple passes to get CI working since I changed how aarch64 w/ qemu is done. |
|
@Luislo1 @figual @luismacostero this is almost ready to merge I just want to cross all the i's.
|
|
Given Apple doesn't support core affinity, does it make sense to have separate configs for P/E-cores? Should we not have a config for M4 SME and then figure out the P/E dispatch internally? |
|
I tried this on M5 and it hit SIGILL. I am skeptical that M5 is backwards-incompatible with M4. |
|
Same on CircleCI. Could be due to the build flag changes I made, since it was complaining about SVE not being enabled, but then SME implementations don't actually have to support SVE in non-streaming mode... |
We need better support for run-time selection of different kernels (within the same sub-configuration) anyways. |
Fixed! It was a compiler flags problem (at least for build-6). (we are checking build-8 now)
Sure! We'll try during this week
@jeffhammond can you try the latest commit on an M5 processor? We don't have one available right now (working on it). |
|
|
|
I used AI to do performance analysis versus Apple's BLAS on the Mac M5 Pro CPU (4 S/P-core, 6 E-core). Everything looks great. |
|
@Luislo1 given that the config does work on the actual HW, I would be OK with semi-temporarily disabling the cross-compiler tests. Please let me know if you would like to do that or soldier on and try to fix them. |
|
@devinamatthews we've been trying to compile on the Apple M4 Pro with GCC but haven't gotten it to work with Apple's assembler with the SME intrinsics. If you could point us to the docker container for build-8, we could investigate that issue further, but otherwise we have no issue with leaving it as is for now. |
|
I don't suppose you've tried non-Apple clang? We might need to blacklist that too. |
|
We have only tried Homebrew clang in the M4 Pro. |
This PR adds two new arm64 sub-configurations to BLIS, called m4sme_p and m4sme_e. They are built for the ARM instruction set architecture and are optimized for the Apple Silicon M4 processor, utilizing the Scalable Matrix Extension 2(SME2). The m4sme_p sub-configuration is configured for execution in performance cores and m4sme_e in efficiency cores. Included in the armsme kernels folder are implementations for packing (1m) and the level 3 gemm kernel programmed with intrinsics.
The m4sme_p sub-configuration is chosen through a hardware detection heuristic if the machine supports the SME2 feature. The m4sme_e sub-configuration must be selected manually. The sub-configurations are temporarily blacklisted for all compilers except Clang 17 or later on Darwin.
Regarding the implementation details, the kernel lengths are SVL (Streaming Vector Length) agnostic. We have included 3 different gemm kernels for single precision and 4 for double precision based on the possibilities afforded by the ZA storage. Please note that despite the kernels themselves being agnostic, the bli_cntx_init file is specifically configured for the M4 silicon; Apple silicon currently only supports an SVL of 512b (64B) with an SME 2D array size of 4KiB.
Developers for the m4sme implementation:
@Luislo1
@figual
@luismacostero
We welcome your thoughts and look forward to your feedback on this implementation.