UoB-HPC / SimEng

The University of Bristol HPC Simulation Engine
https://uob-hpc.github.io/SimEng
Apache License 2.0
93 stars 20 forks source link

Issues with Running Statically Compiled ARMv8.4-SVE Binary on SimEng: Incorrect %d Formatting in Output #435

Closed tarinduj closed 4 weeks ago

tarinduj commented 1 month ago

Check List

Binary File Information Please run file on the binary used and paste the output below (i.e. file myBinary.elf).

sme_matmul_fp32: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.7.0, not stripped

System Description Please provide the following as a list:

SimEng Version additional-sme-support d5c631cc3a42b17fda07c97467e5c92db78d4f3f 0.9.6-48-gd5c631cc

SimEng CMAKE Options Used -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="/mnt/SimEng/install" -DCMAKE_CXX_COMPILER="g++" -DCMAKE_CXX_FLAGS="-std=c++17"

Binary Compilation Instructions armclang -static -march=armv8.4-a+sve -Wall -O3 -o sme_matmul_fp32 main.c matmul.c

SimEng Command Line Expression simeng /mnt/SimEng/configs/a64fx_SME.yaml /mnt/SME_Evaluation_Resources/SME_matmul_fp32/sme_matmul_fp32 200 128 128 128

SimEng Metadata Output If your simulation begins to execute the binary, please provide the metadata that SimEng prints at the start of execution. E.g.

[SimEng] Build metadata:
[SimEng]        Version: 0.9.6
[SimEng]        Compile Time - Date: 12:53:25 - Oct 13 2024
[SimEng]        Build type: Release
[SimEng]        Compile options: $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>;-Wall;-pedantic
[SimEng]        Test suite: OFF

[SimEng] Running in Out-of-Order mode
[SimEng] Workload: /mnt/SME_Evaluation_Resources/SME_matmul_fp32/sme_matmul_fp32 200 128 128 128
[SimEng] Config file: /mnt/SimEng/configs/a64fx_SME.yaml
[SimEng] ISA: AArch64
[SimEng] Auto-generated Special File directory: True
[SimEng] Special File directory used: /mnt/SimEng/build/specialFiles/
[SimEng] Number of Cores: 1
[SimEng] Starting...

Problem Description This was the example from SME_Evaluation_Resources. It prints %d instead of the integer values.

$ simeng /mnt/SimEng/configs/a64fx_SME.yaml /mnt/SME_Evaluation_Resources/SME_matmul_fp32/sme_matmul_fp32 200 128 128 128
...
Left Matrix Dimensions = %d x %d
Right Matrix Dimensions = %d x %d
SME Loop iterations = %d

Calculating %d iterations of SME Matrix Multiply...
Calculating Reference Matrix Multiply...Done
Done
Calculating %d iterations of SME Matrix Multiply...
Done

ERROR TOLERANCE = %.4f%%
%lu, %f, %f
Invalid Matrix Dimensions. Please ensure that :
        - K dimension is Greater-Than 2 

Runtime args ==> ./BINARY_NAME iterations M K NCalculating Reference Matrix Multiply...PASS

[SimEng:ExceptionHandler] Received exit_group syscall: terminating with exit code 0
[SimEng:Core] Halting due to fatal exception

[SimEng] branch.executed: 3470226
[SimEng] branch.mispredict: 133144
[SimEng] branch.missrate: 3.84%
[SimEng] cycles: 31947381
[SimEng] decode.earlyFlushes: 0
[SimEng] dispatch.rsStalls: 616964
[SimEng] fetch.branchStalls: 1392611
[SimEng] flushes: 227480
[SimEng] ipc: 0.69
[SimEng] issue.backendStalls: 17290970
[SimEng] issue.frontendStalls: 701160
[SimEng] issue.portBusyStalls: 101761
[SimEng] lsq.loadViolations: 94399
[SimEng] rename.allocationStalls: 8020318
[SimEng] rename.lqStalls: 0
[SimEng] rename.robStalls: 15176335
[SimEng] rename.sqStalls: 4120
[SimEng] retired: 22183166

[SimEng] Finished 31947381 ticks in 18897ms (1691 kHz, 1.2 MIPS)

But the binary itself works when I run it without using SimEng (until it meets an invalid instruction).

$./sme_matmul_fp32 200 128 128 128
Left Matrix Dimensions = 128 x 128
Right Matrix Dimensions = 128 x 128
SME Loop iterations = 200

Illegal instruction
FinnWilkinson commented 1 month ago

Thanks for raising this issue. I've pushed some instruction logic fixes to the additional-sme-support branch which helped to resolve this issue last week for a different compiler. Please let me know if this fixes the issue you're having

tarinduj commented 1 month ago

Perfect. That worked. Thank you.

Not related to the issue, but do you happen to have any pointers to SME examples other than SME_Evaluation_Resources? I am trying to implement a matrix transpose with SME. I tried running something I implemented using MLIR 'ArmSME' Dialect, but it looks like SimEng can't run it.

FinnWilkinson commented 1 month ago

Unfortunately SME resources are quite few and far betweeen... You can look at this project however and see if anything is of use