Skip to content

ggml-cpu: optimise assembly calls for hsum on s390x #14037

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taronaeo
Copy link
Contributor

@taronaeo taronaeo commented Jun 5, 2025

This pull request aims to optimise the assembly instructions for horizontal summation of vector elements on s390x.

Before Optimisation Assembly

     vlgvf   %r1,%v24,0                                                                                                                                           
     vlgvf   %r0,%v24,1                                                                                                                                           
     vlvgf   %v0,%r1,0                                                                                                                                            
     vlvgf   %v2,%r0,0                                                                                                                                            
     aebr    %f0,%f2                                                                                                                                              
     vlgvf   %r3,%v24,2                                                                                                                                           
     vlvgf   %v4,%r3,0                                                                                                                                            
     vlgvf   %r2,%v24,3                                                                                                                                           
     vlvgf   %v6,%r2,0                                                                                                                                            
     aebr    %f0,%f4                                                                                                                                              
     aebr    %f0,%f6                                                                                                                                              
     br  %r14

After Optimisation Assembly

     larl    %r1, .LCPI0_0                                                                                                                                        
     vl  %v0, 0(%r1), 3                                                                                                                                           
     vperm   %v0, %v24, %v24, %v0                                                                                                                                 
     vfasb   %v0, %v24, %v0                                                                                                                                       
     vrepf   %v1, %v0, 1                                                                                                                                          
     vfasb   %v0, %v0, %v1                                                                                                                                        
     br  %r14

Note: Assembly code generated will vary based on the compiler used (i.e., GCC vs. Clang).

Verification

To ensure that this optimisation did not break anything, the optimisation has been tested on the following models:

  1. IBM Granite 3.3 2B (F32, F16)
  2. Kindly request additional models to be tested

Note

Tests were conducted on an IBM z16 Mainframe with 2 IFLs (4 vCPUs) and 64 GB Memory on a shared R&D LPAR.

Please review this pull request and consider merging into the main repository. Thank you!

@taronaeo
Copy link
Contributor Author

taronaeo commented Jun 6, 2025

@ericcurtin Can assist to re-trigger the checks? Unsure why the job wasn't picked up by runners at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant