Browse Source

Optimized cgemm kernel 16x4 LASX for LoongArch

tags/v0.3.27
pengxu 1 year ago
parent
commit
4787a55c64
20 changed files with 19828 additions and 7 deletions
  1. +1170
    -0
      kernel/generic/zhemm_ltcopy_16.c
  2. +1168
    -0
      kernel/generic/zhemm_utcopy_16.c
  3. +587
    -0
      kernel/generic/zneg_tcopy_16.c
  4. +333
    -0
      kernel/generic/zsymm_lcopy_16.c
  5. +332
    -0
      kernel/generic/zsymm_ucopy_16.c
  6. +2310
    -0
      kernel/generic/ztrmm_lncopy_16.c
  7. +2313
    -0
      kernel/generic/ztrmm_ltcopy_16.c
  8. +2316
    -0
      kernel/generic/ztrmm_uncopy_16.c
  9. +2318
    -0
      kernel/generic/ztrmm_utcopy_16.c
  10. +308
    -0
      kernel/generic/ztrsm_lncopy_16.c
  11. +264
    -0
      kernel/generic/ztrsm_ltcopy_16.c
  12. +313
    -0
      kernel/generic/ztrsm_uncopy_16.c
  13. +261
    -0
      kernel/generic/ztrsm_utcopy_16.c
  14. +7
    -3
      kernel/loongarch64/KERNEL.LOONGSON3R5
  15. +3757
    -0
      kernel/loongarch64/cgemm_kernel_16x4_lasx.S
  16. +691
    -0
      kernel/loongarch64/cgemm_ncopy_16_lasx.S
  17. +325
    -0
      kernel/loongarch64/cgemm_ncopy_4_lasx.S
  18. +741
    -0
      kernel/loongarch64/cgemm_tcopy_16_lasx.S
  19. +306
    -0
      kernel/loongarch64/cgemm_tcopy_4_lasx.S
  20. +8
    -4
      param.h

+ 1170
- 0
kernel/generic/zhemm_ltcopy_16.c
File diff suppressed because it is too large
View File


+ 1168
- 0
kernel/generic/zhemm_utcopy_16.c
File diff suppressed because it is too large
View File


+ 587
- 0
kernel/generic/zneg_tcopy_16.c View File

@@ -0,0 +1,587 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, FLOAT *b){

BLASLONG i, j;

FLOAT *aoffset;
FLOAT *aoffset1, *aoffset2;

FLOAT *boffset;

FLOAT ctemp01, ctemp02, ctemp03, ctemp04;
FLOAT ctemp05, ctemp06, ctemp07, ctemp08;
FLOAT ctemp09, ctemp10, ctemp11, ctemp12;
FLOAT ctemp13, ctemp14, ctemp15, ctemp16;
FLOAT ctemp17, ctemp18, ctemp19, ctemp20;
FLOAT ctemp21, ctemp22, ctemp23, ctemp24;
FLOAT ctemp25, ctemp26, ctemp27, ctemp28;
FLOAT ctemp29, ctemp30, ctemp31, ctemp32;

FLOAT ctemp33, ctemp34, ctemp35, ctemp36;
FLOAT ctemp37, ctemp38, ctemp39, ctemp40;
FLOAT ctemp41, ctemp42, ctemp43, ctemp44;
FLOAT ctemp45, ctemp46, ctemp47, ctemp48;
FLOAT ctemp49, ctemp50, ctemp51, ctemp52;
FLOAT ctemp53, ctemp54, ctemp55, ctemp56;
FLOAT ctemp57, ctemp58, ctemp59, ctemp60;
FLOAT ctemp61, ctemp62, ctemp63, ctemp64;

aoffset = a;
boffset = b;
lda *= 2;

#if 0
fprintf(stderr, "M = %d N = %d\n", m, n);
#endif

j = (n >> 4);
if (j > 0){
do{
aoffset1 = aoffset;
aoffset2 = aoffset + lda;
aoffset += 32;

i = (m >> 1);
if (i > 0){
do{
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);
ctemp09 = *(aoffset1 + 8);
ctemp10 = *(aoffset1 + 9);
ctemp11 = *(aoffset1 + 10);
ctemp12 = *(aoffset1 + 11);
ctemp13 = *(aoffset1 + 12);
ctemp14 = *(aoffset1 + 13);
ctemp15 = *(aoffset1 + 14);
ctemp16 = *(aoffset1 + 15);
ctemp17 = *(aoffset1 + 16);
ctemp18 = *(aoffset1 + 17);
ctemp19 = *(aoffset1 + 18);
ctemp20 = *(aoffset1 + 19);
ctemp21 = *(aoffset1 + 20);
ctemp22 = *(aoffset1 + 21);
ctemp23 = *(aoffset1 + 22);
ctemp24 = *(aoffset1 + 23);
ctemp25 = *(aoffset1 + 24);
ctemp26 = *(aoffset1 + 25);
ctemp27 = *(aoffset1 + 26);
ctemp28 = *(aoffset1 + 27);
ctemp29 = *(aoffset1 + 28);
ctemp30 = *(aoffset1 + 29);
ctemp31 = *(aoffset1 + 30);
ctemp32 = *(aoffset1 + 31);

ctemp33 = *(aoffset2 + 0);
ctemp34 = *(aoffset2 + 1);
ctemp35 = *(aoffset2 + 2);
ctemp36 = *(aoffset2 + 3);
ctemp37 = *(aoffset2 + 4);
ctemp38 = *(aoffset2 + 5);
ctemp39 = *(aoffset2 + 6);
ctemp40 = *(aoffset2 + 7);
ctemp41 = *(aoffset2 + 8);
ctemp42 = *(aoffset2 + 9);
ctemp43 = *(aoffset2 + 10);
ctemp44 = *(aoffset2 + 11);
ctemp45 = *(aoffset2 + 12);
ctemp46 = *(aoffset2 + 13);
ctemp47 = *(aoffset2 + 14);
ctemp48 = *(aoffset2 + 15);
ctemp49 = *(aoffset2 + 16);
ctemp50 = *(aoffset2 + 17);
ctemp51 = *(aoffset2 + 18);
ctemp52 = *(aoffset2 + 19);
ctemp53 = *(aoffset2 + 20);
ctemp54 = *(aoffset2 + 21);
ctemp55 = *(aoffset2 + 22);
ctemp56 = *(aoffset2 + 23);
ctemp57 = *(aoffset2 + 24);
ctemp58 = *(aoffset2 + 25);
ctemp59 = *(aoffset2 + 26);
ctemp60 = *(aoffset2 + 27);
ctemp61 = *(aoffset2 + 28);
ctemp62 = *(aoffset2 + 29);
ctemp63 = *(aoffset2 + 30);
ctemp64 = *(aoffset2 + 31);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

*(boffset + 8) = -ctemp09;
*(boffset + 9) = -ctemp10;
*(boffset + 10) = -ctemp11;
*(boffset + 11) = -ctemp12;
*(boffset + 12) = -ctemp13;
*(boffset + 13) = -ctemp14;
*(boffset + 14) = -ctemp15;
*(boffset + 15) = -ctemp16;

*(boffset + 16) = -ctemp17;
*(boffset + 17) = -ctemp18;
*(boffset + 18) = -ctemp19;
*(boffset + 19) = -ctemp20;
*(boffset + 20) = -ctemp21;
*(boffset + 21) = -ctemp22;
*(boffset + 22) = -ctemp23;
*(boffset + 23) = -ctemp24;

*(boffset + 24) = -ctemp25;
*(boffset + 25) = -ctemp26;
*(boffset + 26) = -ctemp27;
*(boffset + 27) = -ctemp28;
*(boffset + 28) = -ctemp29;
*(boffset + 29) = -ctemp30;
*(boffset + 30) = -ctemp31;
*(boffset + 31) = -ctemp32;

*(boffset + 32) = -ctemp33;
*(boffset + 33) = -ctemp34;
*(boffset + 34) = -ctemp35;
*(boffset + 35) = -ctemp36;
*(boffset + 36) = -ctemp37;
*(boffset + 37) = -ctemp38;
*(boffset + 38) = -ctemp39;
*(boffset + 39) = -ctemp40;

*(boffset + 40) = -ctemp41;
*(boffset + 41) = -ctemp42;
*(boffset + 42) = -ctemp43;
*(boffset + 43) = -ctemp44;
*(boffset + 44) = -ctemp45;
*(boffset + 45) = -ctemp46;
*(boffset + 46) = -ctemp47;
*(boffset + 47) = -ctemp48;

*(boffset + 48) = -ctemp49;
*(boffset + 49) = -ctemp50;
*(boffset + 50) = -ctemp51;
*(boffset + 51) = -ctemp52;
*(boffset + 52) = -ctemp53;
*(boffset + 53) = -ctemp54;
*(boffset + 54) = -ctemp55;
*(boffset + 55) = -ctemp56;

*(boffset + 56) = -ctemp57;
*(boffset + 57) = -ctemp58;
*(boffset + 58) = -ctemp59;
*(boffset + 59) = -ctemp60;
*(boffset + 60) = -ctemp61;
*(boffset + 61) = -ctemp62;
*(boffset + 62) = -ctemp63;
*(boffset + 63) = -ctemp64;

aoffset1 += 2 * lda;
aoffset2 += 2 * lda;
boffset += 64;

i --;
}while(i > 0);
}

if (m & 1){
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);
ctemp09 = *(aoffset1 + 8);
ctemp10 = *(aoffset1 + 9);
ctemp11 = *(aoffset1 + 10);
ctemp12 = *(aoffset1 + 11);
ctemp13 = *(aoffset1 + 12);
ctemp14 = *(aoffset1 + 13);
ctemp15 = *(aoffset1 + 14);
ctemp16 = *(aoffset1 + 15);
ctemp17 = *(aoffset1 + 16);
ctemp18 = *(aoffset1 + 17);
ctemp19 = *(aoffset1 + 18);
ctemp20 = *(aoffset1 + 19);
ctemp21 = *(aoffset1 + 20);
ctemp22 = *(aoffset1 + 21);
ctemp23 = *(aoffset1 + 22);
ctemp24 = *(aoffset1 + 23);
ctemp25 = *(aoffset1 + 24);
ctemp26 = *(aoffset1 + 25);
ctemp27 = *(aoffset1 + 26);
ctemp28 = *(aoffset1 + 27);
ctemp29 = *(aoffset1 + 28);
ctemp30 = *(aoffset1 + 29);
ctemp31 = *(aoffset1 + 30);
ctemp32 = *(aoffset1 + 31);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

*(boffset + 8) = -ctemp09;
*(boffset + 9) = -ctemp10;
*(boffset + 10) = -ctemp11;
*(boffset + 11) = -ctemp12;
*(boffset + 12) = -ctemp13;
*(boffset + 13) = -ctemp14;
*(boffset + 14) = -ctemp15;
*(boffset + 15) = -ctemp16;

*(boffset + 16) = -ctemp17;
*(boffset + 17) = -ctemp18;
*(boffset + 18) = -ctemp19;
*(boffset + 19) = -ctemp20;
*(boffset + 20) = -ctemp21;
*(boffset + 21) = -ctemp22;
*(boffset + 22) = -ctemp23;
*(boffset + 23) = -ctemp24;

*(boffset + 24) = -ctemp25;
*(boffset + 25) = -ctemp26;
*(boffset + 26) = -ctemp27;
*(boffset + 27) = -ctemp28;
*(boffset + 28) = -ctemp29;
*(boffset + 29) = -ctemp30;
*(boffset + 30) = -ctemp31;
*(boffset + 31) = -ctemp32;

boffset += 32;
}

j--;
}while(j > 0);
} /* end of if(j > 0) */

if (n & 8){
aoffset1 = aoffset;
aoffset2 = aoffset + lda;
aoffset += 16;

i = (m >> 1);
if (i > 0){
do{
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);
ctemp09 = *(aoffset1 + 8);
ctemp10 = *(aoffset1 + 9);
ctemp11 = *(aoffset1 + 10);
ctemp12 = *(aoffset1 + 11);
ctemp13 = *(aoffset1 + 12);
ctemp14 = *(aoffset1 + 13);
ctemp15 = *(aoffset1 + 14);
ctemp16 = *(aoffset1 + 15);

ctemp17 = *(aoffset2 + 0);
ctemp18 = *(aoffset2 + 1);
ctemp19 = *(aoffset2 + 2);
ctemp20 = *(aoffset2 + 3);
ctemp21 = *(aoffset2 + 4);
ctemp22 = *(aoffset2 + 5);
ctemp23 = *(aoffset2 + 6);
ctemp24 = *(aoffset2 + 7);
ctemp25 = *(aoffset2 + 8);
ctemp26 = *(aoffset2 + 9);
ctemp27 = *(aoffset2 + 10);
ctemp28 = *(aoffset2 + 11);
ctemp29 = *(aoffset2 + 12);
ctemp30 = *(aoffset2 + 13);
ctemp31 = *(aoffset2 + 14);
ctemp32 = *(aoffset2 + 15);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

*(boffset + 8) = -ctemp09;
*(boffset + 9) = -ctemp10;
*(boffset + 10) = -ctemp11;
*(boffset + 11) = -ctemp12;
*(boffset + 12) = -ctemp13;
*(boffset + 13) = -ctemp14;
*(boffset + 14) = -ctemp15;
*(boffset + 15) = -ctemp16;

*(boffset + 16) = -ctemp17;
*(boffset + 17) = -ctemp18;
*(boffset + 18) = -ctemp19;
*(boffset + 19) = -ctemp20;
*(boffset + 20) = -ctemp21;
*(boffset + 21) = -ctemp22;
*(boffset + 22) = -ctemp23;
*(boffset + 23) = -ctemp24;

*(boffset + 24) = -ctemp25;
*(boffset + 25) = -ctemp26;
*(boffset + 26) = -ctemp27;
*(boffset + 27) = -ctemp28;
*(boffset + 28) = -ctemp29;
*(boffset + 29) = -ctemp30;
*(boffset + 30) = -ctemp31;
*(boffset + 31) = -ctemp32;

aoffset1 += 2 * lda;
aoffset2 += 2 * lda;
boffset += 32;

i --;
}while(i > 0);
}

if (m & 1){
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);
ctemp09 = *(aoffset1 + 8);
ctemp10 = *(aoffset1 + 9);
ctemp11 = *(aoffset1 + 10);
ctemp12 = *(aoffset1 + 11);
ctemp13 = *(aoffset1 + 12);
ctemp14 = *(aoffset1 + 13);
ctemp15 = *(aoffset1 + 14);
ctemp16 = *(aoffset1 + 15);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

*(boffset + 8) = -ctemp09;
*(boffset + 9) = -ctemp10;
*(boffset + 10) = -ctemp11;
*(boffset + 11) = -ctemp12;
*(boffset + 12) = -ctemp13;
*(boffset + 13) = -ctemp14;
*(boffset + 14) = -ctemp15;
*(boffset + 15) = -ctemp16;

boffset += 16;
}
}

if (n & 4){
aoffset1 = aoffset;
aoffset2 = aoffset + lda;
aoffset += 8;

i = (m >> 1);
if (i > 0){
do{
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);

ctemp09 = *(aoffset2 + 0);
ctemp10 = *(aoffset2 + 1);
ctemp11 = *(aoffset2 + 2);
ctemp12 = *(aoffset2 + 3);
ctemp13 = *(aoffset2 + 4);
ctemp14 = *(aoffset2 + 5);
ctemp15 = *(aoffset2 + 6);
ctemp16 = *(aoffset2 + 7);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

*(boffset + 8) = -ctemp09;
*(boffset + 9) = -ctemp10;
*(boffset + 10) = -ctemp11;
*(boffset + 11) = -ctemp12;
*(boffset + 12) = -ctemp13;
*(boffset + 13) = -ctemp14;
*(boffset + 14) = -ctemp15;
*(boffset + 15) = -ctemp16;

aoffset1 += 2 * lda;
aoffset2 += 2 * lda;
boffset += 16;

i --;
}while(i > 0);
}

if (m & 1){
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);
ctemp05 = *(aoffset1 + 4);
ctemp06 = *(aoffset1 + 5);
ctemp07 = *(aoffset1 + 6);
ctemp08 = *(aoffset1 + 7);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

boffset += 8;
}
}

if (n & 2){
aoffset1 = aoffset;
aoffset2 = aoffset + lda;
aoffset += 4;

i = (m >> 1);
if (i > 0){
do{
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);

ctemp05 = *(aoffset2 + 0);
ctemp06 = *(aoffset2 + 1);
ctemp07 = *(aoffset2 + 2);
ctemp08 = *(aoffset2 + 3);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;
*(boffset + 4) = -ctemp05;
*(boffset + 5) = -ctemp06;
*(boffset + 6) = -ctemp07;
*(boffset + 7) = -ctemp08;

aoffset1 += 2 * lda;
aoffset2 += 2 * lda;
boffset += 8;

i --;
}while(i > 0);
}

if (m & 1){
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset1 + 2);
ctemp04 = *(aoffset1 + 3);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;

boffset += 4;
}
}

if (n & 1){
aoffset1 = aoffset;
aoffset2 = aoffset + lda;
// aoffset += 2;

i = (m >> 1);
if (i > 0){
do{
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);
ctemp03 = *(aoffset2 + 0);
ctemp04 = *(aoffset2 + 1);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
*(boffset + 2) = -ctemp03;
*(boffset + 3) = -ctemp04;

aoffset1 += 2 * lda;
aoffset2 += 2 * lda;
boffset += 4;

i --;
}while(i > 0);
}

if (m & 1){
ctemp01 = *(aoffset1 + 0);
ctemp02 = *(aoffset1 + 1);

*(boffset + 0) = -ctemp01;
*(boffset + 1) = -ctemp02;
// boffset += 2;
}
}

return 0;
}

+ 333
- 0
kernel/generic/zsymm_lcopy_16.c View File

@@ -0,0 +1,333 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG posX, BLASLONG posY, FLOAT *b){

BLASLONG i, js, offset;

FLOAT data01, data02, data03, data04, data05, data06, data07, data08;
FLOAT data09, data10, data11, data12, data13, data14, data15, data16;
FLOAT data17, data18, data19, data20, data21, data22, data23, data24;
FLOAT data25, data26, data27, data28, data29, data30, data31, data32;

FLOAT *ao1, *ao2, *ao3, *ao4, *ao5, *ao6, *ao7, *ao8;
FLOAT *ao9, *ao10, *ao11, *ao12, *ao13, *ao14, *ao15, *ao16;

lda *= 2;

js = (n >> 4);
while (js > 0){

offset = posX - posY;

if (offset > 0) ao1 = a + (posX + 0) * 2 + posY * lda; else ao1 = a + posY * 2 + (posX + 0) * lda;
if (offset > -1) ao2 = a + (posX + 1) * 2 + posY * lda; else ao2 = a + posY * 2 + (posX + 1) * lda;
if (offset > -2) ao3 = a + (posX + 2) * 2 + posY * lda; else ao3 = a + posY * 2 + (posX + 2) * lda;
if (offset > -3) ao4 = a + (posX + 3) * 2 + posY * lda; else ao4 = a + posY * 2 + (posX + 3) * lda;
if (offset > -4) ao5 = a + (posX + 4) * 2 + posY * lda; else ao5 = a + posY * 2 + (posX + 4) * lda;
if (offset > -5) ao6 = a + (posX + 5) * 2 + posY * lda; else ao6 = a + posY * 2 + (posX + 5) * lda;
if (offset > -6) ao7 = a + (posX + 6) * 2 + posY * lda; else ao7 = a + posY * 2 + (posX + 6) * lda;
if (offset > -7) ao8 = a + (posX + 7) * 2 + posY * lda; else ao8 = a + posY * 2 + (posX + 7) * lda;
if (offset > -8) ao9 = a + (posX + 8) * 2 + posY * lda; else ao9 = a + posY * 2 + (posX + 8) * lda;
if (offset > -9) ao10 = a + (posX + 9) * 2 + posY * lda; else ao10 = a + posY * 2 + (posX + 9) * lda;
if (offset > -10) ao11 = a + (posX + 10) * 2 + posY * lda; else ao11 = a + posY * 2 + (posX + 10) * lda;
if (offset > -11) ao12 = a + (posX + 11) * 2 + posY * lda; else ao12 = a + posY * 2 + (posX + 11) * lda;
if (offset > -12) ao13 = a + (posX + 12) * 2 + posY * lda; else ao13 = a + posY * 2 + (posX + 12) * lda;
if (offset > -13) ao14 = a + (posX + 13) * 2 + posY * lda; else ao14 = a + posY * 2 + (posX + 13) * lda;
if (offset > -14) ao15 = a + (posX + 14) * 2 + posY * lda; else ao15 = a + posY * 2 + (posX + 14) * lda;
if (offset > -15) ao16 = a + (posX + 15) * 2 + posY * lda; else ao16 = a + posY * 2 + (posX + 15) * lda;


i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);
data09 = *(ao5 + 0);
data10 = *(ao5 + 1);
data11 = *(ao6 + 0);
data12 = *(ao6 + 1);
data13 = *(ao7 + 0);
data14 = *(ao7 + 1);
data15 = *(ao8 + 0);
data16 = *(ao8 + 1);
data17 = *(ao9 + 0);
data18 = *(ao9 + 1);
data19 = *(ao10 + 0);
data20 = *(ao10 + 1);
data21 = *(ao11 + 0);
data22 = *(ao11 + 1);
data23 = *(ao12 + 0);
data24 = *(ao12 + 1);
data25 = *(ao13 + 0);
data26 = *(ao13 + 1);
data27 = *(ao14 + 0);
data28 = *(ao14 + 1);
data29 = *(ao15 + 0);
data30 = *(ao15 + 1);
data31 = *(ao16 + 0);
data32 = *(ao16 + 1);

if (offset > 0) ao1 += lda; else ao1 += 2;
if (offset > -1) ao2 += lda; else ao2 += 2;
if (offset > -2) ao3 += lda; else ao3 += 2;
if (offset > -3) ao4 += lda; else ao4 += 2;
if (offset > -4) ao5 += lda; else ao5 += 2;
if (offset > -5) ao6 += lda; else ao6 += 2;
if (offset > -6) ao7 += lda; else ao7 += 2;
if (offset > -7) ao8 += lda; else ao8 += 2;
if (offset > -8) ao9 += lda; else ao9 += 2;
if (offset > -9) ao10 += lda; else ao10 += 2;
if (offset > -10) ao11 += lda; else ao11 += 2;
if (offset > -11) ao12 += lda; else ao12 += 2;
if (offset > -12) ao13 += lda; else ao13 += 2;
if (offset > -13) ao14 += lda; else ao14 += 2;
if (offset > -14) ao15 += lda; else ao15 += 2;
if (offset > -15) ao16 += lda; else ao16 += 2;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;
b[ 8] = data09;
b[ 9] = data10;
b[10] = data11;
b[11] = data12;
b[12] = data13;
b[13] = data14;
b[14] = data15;
b[15] = data16;
b[16] = data17;
b[17] = data18;
b[18] = data19;
b[19] = data20;
b[20] = data21;
b[21] = data22;
b[22] = data23;
b[23] = data24;
b[24] = data25;
b[25] = data26;
b[26] = data27;
b[27] = data28;
b[28] = data29;
b[29] = data30;
b[30] = data31;
b[31] = data32;

b += 32;

offset --;
i --;
}

posX += 16;
js --;
}

if (n & 8) {
offset = posX - posY;

if (offset > 0) ao1 = a + (posX + 0) * 2 + posY * lda; else ao1 = a + posY * 2 + (posX + 0) * lda;
if (offset > -1) ao2 = a + (posX + 1) * 2 + posY * lda; else ao2 = a + posY * 2 + (posX + 1) * lda;
if (offset > -2) ao3 = a + (posX + 2) * 2 + posY * lda; else ao3 = a + posY * 2 + (posX + 2) * lda;
if (offset > -3) ao4 = a + (posX + 3) * 2 + posY * lda; else ao4 = a + posY * 2 + (posX + 3) * lda;
if (offset > -4) ao5 = a + (posX + 4) * 2 + posY * lda; else ao5 = a + posY * 2 + (posX + 4) * lda;
if (offset > -5) ao6 = a + (posX + 5) * 2 + posY * lda; else ao6 = a + posY * 2 + (posX + 5) * lda;
if (offset > -6) ao7 = a + (posX + 6) * 2 + posY * lda; else ao7 = a + posY * 2 + (posX + 6) * lda;
if (offset > -7) ao8 = a + (posX + 7) * 2 + posY * lda; else ao8 = a + posY * 2 + (posX + 7) * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);
data09 = *(ao5 + 0);
data10 = *(ao5 + 1);
data11 = *(ao6 + 0);
data12 = *(ao6 + 1);
data13 = *(ao7 + 0);
data14 = *(ao7 + 1);
data15 = *(ao8 + 0);
data16 = *(ao8 + 1);

if (offset > 0) ao1 += lda; else ao1 += 2;
if (offset > -1) ao2 += lda; else ao2 += 2;
if (offset > -2) ao3 += lda; else ao3 += 2;
if (offset > -3) ao4 += lda; else ao4 += 2;
if (offset > -4) ao5 += lda; else ao5 += 2;
if (offset > -5) ao6 += lda; else ao6 += 2;
if (offset > -6) ao7 += lda; else ao7 += 2;
if (offset > -7) ao8 += lda; else ao8 += 2;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;
b[ 8] = data09;
b[ 9] = data10;
b[10] = data11;
b[11] = data12;
b[12] = data13;
b[13] = data14;
b[14] = data15;
b[15] = data16;

b += 16;

offset --;
i --;
}

posX += 8;
}

if (n & 4) {
offset = posX - posY;

if (offset > 0) ao1 = a + (posX + 0) * 2 + posY * lda; else ao1 = a + posY * 2 + (posX + 0) * lda;
if (offset > -1) ao2 = a + (posX + 1) * 2 + posY * lda; else ao2 = a + posY * 2 + (posX + 1) * lda;
if (offset > -2) ao3 = a + (posX + 2) * 2 + posY * lda; else ao3 = a + posY * 2 + (posX + 2) * lda;
if (offset > -3) ao4 = a + (posX + 3) * 2 + posY * lda; else ao4 = a + posY * 2 + (posX + 3) * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);

if (offset > 0) ao1 += lda; else ao1 += 2;
if (offset > -1) ao2 += lda; else ao2 += 2;
if (offset > -2) ao3 += lda; else ao3 += 2;
if (offset > -3) ao4 += lda; else ao4 += 2;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;

b += 8;

offset --;
i --;
}

posX += 4;
}

if (n & 2) {

offset = posX - posY;

if (offset > 0) ao1 = a + (posX + 0) * 2 + posY * lda; else ao1 = a + posY * 2 + (posX + 0) * lda;
if (offset > -1) ao2 = a + (posX + 1) * 2 + posY * lda; else ao2 = a + posY * 2 + (posX + 1) * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);

if (offset > 0) ao1 += lda; else ao1 += 2;
if (offset > -1) ao2 += lda; else ao2 += 2;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;

b += 4;

offset --;
i --;
}

posX += 2;

}

if (n & 1) {

offset = posX - posY;

if (offset > 0) ao1 = a + (posX + 0) * 2 + posY * lda; else ao1 = a + posY * 2 + (posX + 0) * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);

if (offset > 0) ao1 += lda; else ao1 += 2;

b[ 0] = data01;
b[ 1] = data02;

b += 2;

offset --;
i --;
}

}

return 0;
}

+ 332
- 0
kernel/generic/zsymm_ucopy_16.c View File

@@ -0,0 +1,332 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG posX, BLASLONG posY, FLOAT *b){

BLASLONG i, js, offset;

FLOAT data01, data02, data03, data04, data05, data06, data07, data08;
FLOAT data09, data10, data11, data12, data13, data14, data15, data16;
FLOAT data17, data18, data19, data20, data21, data22, data23, data24;
FLOAT data25, data26, data27, data28, data29, data30, data31, data32;

FLOAT *ao1, *ao2, *ao3, *ao4, *ao5, *ao6, *ao7, *ao8;
FLOAT *ao9, *ao10, *ao11, *ao12, *ao13, *ao14, *ao15, *ao16;

lda *= 2;

js = (n >> 4);
while (js > 0){

offset = posX - posY;

if (offset > 0) ao1 = a + posY * 2 + (posX + 0) * lda; else ao1 = a + (posX + 0) * 2 + posY * lda;
if (offset > -1) ao2 = a + posY * 2 + (posX + 1) * lda; else ao2 = a + (posX + 1) * 2 + posY * lda;
if (offset > -2) ao3 = a + posY * 2 + (posX + 2) * lda; else ao3 = a + (posX + 2) * 2 + posY * lda;
if (offset > -3) ao4 = a + posY * 2 + (posX + 3) * lda; else ao4 = a + (posX + 3) * 2 + posY * lda;
if (offset > -4) ao5 = a + posY * 2 + (posX + 4) * lda; else ao5 = a + (posX + 4) * 2 + posY * lda;
if (offset > -5) ao6 = a + posY * 2 + (posX + 5) * lda; else ao6 = a + (posX + 5) * 2 + posY * lda;
if (offset > -6) ao7 = a + posY * 2 + (posX + 6) * lda; else ao7 = a + (posX + 6) * 2 + posY * lda;
if (offset > -7) ao8 = a + posY * 2 + (posX + 7) * lda; else ao8 = a + (posX + 7) * 2 + posY * lda;
if (offset > -8) ao9 = a + posY * 2 + (posX + 8) * lda; else ao9 = a + (posX + 8) * 2 + posY * lda;
if (offset > -9) ao10 = a + posY * 2 + (posX + 9) * lda; else ao10 = a + (posX + 9) * 2 + posY * lda;
if (offset > -10) ao11 = a + posY * 2 + (posX + 10) * lda; else ao11 = a + (posX + 10) * 2 + posY * lda;
if (offset > -11) ao12 = a + posY * 2 + (posX + 11) * lda; else ao12 = a + (posX + 11) * 2 + posY * lda;
if (offset > -12) ao13 = a + posY * 2 + (posX + 12) * lda; else ao13 = a + (posX + 12) * 2 + posY * lda;
if (offset > -13) ao14 = a + posY * 2 + (posX + 13) * lda; else ao14 = a + (posX + 13) * 2 + posY * lda;
if (offset > -14) ao15 = a + posY * 2 + (posX + 14) * lda; else ao15 = a + (posX + 14) * 2 + posY * lda;
if (offset > -15) ao16 = a + posY * 2 + (posX + 15) * lda; else ao16 = a + (posX + 15) * 2 + posY * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);
data09 = *(ao5 + 0);
data10 = *(ao5 + 1);
data11 = *(ao6 + 0);
data12 = *(ao6 + 1);
data13 = *(ao7 + 0);
data14 = *(ao7 + 1);
data15 = *(ao8 + 0);
data16 = *(ao8 + 1);
data17 = *(ao9 + 0);
data18 = *(ao9 + 1);
data19 = *(ao10 + 0);
data20 = *(ao10 + 1);
data21 = *(ao11 + 0);
data22 = *(ao11 + 1);
data23 = *(ao12 + 0);
data24 = *(ao12 + 1);
data25 = *(ao13 + 0);
data26 = *(ao13 + 1);
data27 = *(ao14 + 0);
data28 = *(ao14 + 1);
data29 = *(ao15 + 0);
data30 = *(ao15 + 1);
data31 = *(ao16 + 0);
data32 = *(ao16 + 1);

if (offset > 0) ao1 += 2; else ao1 += lda;
if (offset > -1) ao2 += 2; else ao2 += lda;
if (offset > -2) ao3 += 2; else ao3 += lda;
if (offset > -3) ao4 += 2; else ao4 += lda;
if (offset > -4) ao5 += 2; else ao5 += lda;
if (offset > -5) ao6 += 2; else ao6 += lda;
if (offset > -6) ao7 += 2; else ao7 += lda;
if (offset > -7) ao8 += 2; else ao8 += lda;
if (offset > -8) ao9 += 2; else ao9 += lda;
if (offset > -9) ao10 += 2; else ao10 += lda;
if (offset > -10) ao11 += 2; else ao11 += lda;
if (offset > -11) ao12 += 2; else ao12 += lda;
if (offset > -12) ao13 += 2; else ao13 += lda;
if (offset > -13) ao14 += 2; else ao14 += lda;
if (offset > -14) ao15 += 2; else ao15 += lda;
if (offset > -15) ao16 += 2; else ao16 += lda;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;
b[ 8] = data09;
b[ 9] = data10;
b[10] = data11;
b[11] = data12;
b[12] = data13;
b[13] = data14;
b[14] = data15;
b[15] = data16;
b[16] = data17;
b[17] = data18;
b[18] = data19;
b[19] = data20;
b[20] = data21;
b[21] = data22;
b[22] = data23;
b[23] = data24;
b[24] = data25;
b[25] = data26;
b[26] = data27;
b[27] = data28;
b[28] = data29;
b[29] = data30;
b[30] = data31;
b[31] = data32;

b += 32;

offset --;
i --;
}

posX += 16;
js --;
}

if (n & 8) {
offset = posX - posY;

if (offset > 0) ao1 = a + posY * 2 + (posX + 0) * lda; else ao1 = a + (posX + 0) * 2 + posY * lda;
if (offset > -1) ao2 = a + posY * 2 + (posX + 1) * lda; else ao2 = a + (posX + 1) * 2 + posY * lda;
if (offset > -2) ao3 = a + posY * 2 + (posX + 2) * lda; else ao3 = a + (posX + 2) * 2 + posY * lda;
if (offset > -3) ao4 = a + posY * 2 + (posX + 3) * lda; else ao4 = a + (posX + 3) * 2 + posY * lda;
if (offset > -4) ao5 = a + posY * 2 + (posX + 4) * lda; else ao5 = a + (posX + 4) * 2 + posY * lda;
if (offset > -5) ao6 = a + posY * 2 + (posX + 5) * lda; else ao6 = a + (posX + 5) * 2 + posY * lda;
if (offset > -6) ao7 = a + posY * 2 + (posX + 6) * lda; else ao7 = a + (posX + 6) * 2 + posY * lda;
if (offset > -7) ao8 = a + posY * 2 + (posX + 7) * lda; else ao8 = a + (posX + 7) * 2 + posY * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);
data09 = *(ao5 + 0);
data10 = *(ao5 + 1);
data11 = *(ao6 + 0);
data12 = *(ao6 + 1);
data13 = *(ao7 + 0);
data14 = *(ao7 + 1);
data15 = *(ao8 + 0);
data16 = *(ao8 + 1);

if (offset > 0) ao1 += 2; else ao1 += lda;
if (offset > -1) ao2 += 2; else ao2 += lda;
if (offset > -2) ao3 += 2; else ao3 += lda;
if (offset > -3) ao4 += 2; else ao4 += lda;
if (offset > -4) ao5 += 2; else ao5 += lda;
if (offset > -5) ao6 += 2; else ao6 += lda;
if (offset > -6) ao7 += 2; else ao7 += lda;
if (offset > -7) ao8 += 2; else ao8 += lda;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;
b[ 8] = data09;
b[ 9] = data10;
b[10] = data11;
b[11] = data12;
b[12] = data13;
b[13] = data14;
b[14] = data15;
b[15] = data16;

b += 16;

offset --;
i --;
}

posX += 8;
}

if (n & 4) {

offset = posX - posY;

if (offset > 0) ao1 = a + posY * 2 + (posX + 0) * lda; else ao1 = a + (posX + 0) * 2 + posY * lda;
if (offset > -1) ao2 = a + posY * 2 + (posX + 1) * lda; else ao2 = a + (posX + 1) * 2 + posY * lda;
if (offset > -2) ao3 = a + posY * 2 + (posX + 2) * lda; else ao3 = a + (posX + 2) * 2 + posY * lda;
if (offset > -3) ao4 = a + posY * 2 + (posX + 3) * lda; else ao4 = a + (posX + 3) * 2 + posY * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);
data05 = *(ao3 + 0);
data06 = *(ao3 + 1);
data07 = *(ao4 + 0);
data08 = *(ao4 + 1);

if (offset > 0) ao1 += 2; else ao1 += lda;
if (offset > -1) ao2 += 2; else ao2 += lda;
if (offset > -2) ao3 += 2; else ao3 += lda;
if (offset > -3) ao4 += 2; else ao4 += lda;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;
b[ 4] = data05;
b[ 5] = data06;
b[ 6] = data07;
b[ 7] = data08;

b += 8;

offset --;
i --;
}

posX += 4;
}

if (n & 2) {

offset = posX - posY;

if (offset > 0) ao1 = a + posY * 2 + (posX + 0) * lda; else ao1 = a + (posX + 0) * 2 + posY * lda;
if (offset > -1) ao2 = a + posY * 2 + (posX + 1) * lda; else ao2 = a + (posX + 1) * 2 + posY * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);
data03 = *(ao2 + 0);
data04 = *(ao2 + 1);

if (offset > 0) ao1 += 2; else ao1 += lda;
if (offset > -1) ao2 += 2; else ao2 += lda;

b[ 0] = data01;
b[ 1] = data02;
b[ 2] = data03;
b[ 3] = data04;

b += 4;

offset --;
i --;
}

posX += 2;
}

if (n & 1) {

offset = posX - posY;

if (offset > 0) ao1 = a + posY * 2 + (posX + 0) * lda; else ao1 = a + (posX + 0) * 2 + posY * lda;

i = m;

while (i > 0) {
data01 = *(ao1 + 0);
data02 = *(ao1 + 1);

if (offset > 0) ao1 += 2; else ao1 += lda;

b[ 0] = data01;
b[ 1] = data02;

b += 2;

offset --;
i --;
}

}

return 0;
}

+ 2310
- 0
kernel/generic/ztrmm_lncopy_16.c
File diff suppressed because it is too large
View File


+ 2313
- 0
kernel/generic/ztrmm_ltcopy_16.c
File diff suppressed because it is too large
View File


+ 2316
- 0
kernel/generic/ztrmm_uncopy_16.c
File diff suppressed because it is too large
View File


+ 2318
- 0
kernel/generic/ztrmm_utcopy_16.c
File diff suppressed because it is too large
View File


+ 308
- 0
kernel/generic/ztrsm_lncopy_16.c View File

@@ -0,0 +1,308 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){

BLASLONG i, ii, j, jj, k;

FLOAT *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
FLOAT *a9, *a10, *a11, *a12, *a13, *a14, *a15, *a16;

FLOAT data1, data2;

lda *= 2;
jj = offset;

j = (n >> 4);
while (j > 0){

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a5 = a + 4 * lda;
a6 = a + 5 * lda;
a7 = a + 6 * lda;
a8 = a + 7 * lda;
a9 = a + 8 * lda;
a10 = a + 9 * lda;
a11 = a + 10 * lda;
a12 = a + 11 * lda;
a13 = a + 12 * lda;
a14 = a + 13 * lda;
a15 = a + 14 * lda;
a16 = a + 15 * lda;

a += 16 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 16)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 16) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
*(b + 8) = *(a5 + 0);
*(b + 9) = *(a5 + 1);
*(b + 10) = *(a6 + 0);
*(b + 11) = *(a6 + 1);
*(b + 12) = *(a7 + 0);
*(b + 13) = *(a7 + 1);
*(b + 14) = *(a8 + 0);
*(b + 15) = *(a8 + 1);
*(b + 16) = *(a9 + 0);
*(b + 17) = *(a9 + 1);
*(b + 18) = *(a10 + 0);
*(b + 19) = *(a10 + 1);
*(b + 20) = *(a11 + 0);
*(b + 21) = *(a11 + 1);
*(b + 22) = *(a12 + 0);
*(b + 23) = *(a12 + 1);
*(b + 24) = *(a13 + 0);
*(b + 25) = *(a13 + 1);
*(b + 26) = *(a14 + 0);
*(b + 27) = *(a14 + 1);
*(b + 28) = *(a15 + 0);
*(b + 29) = *(a15 + 1);
*(b + 30) = *(a16 + 0);
*(b + 31) = *(a16 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
a5 += 2;
a6 += 2;
a7 += 2;
a8 += 2;
a9 += 2;
a10 += 2;
a11 += 2;
a12 += 2;
a13 += 2;
a14 += 2;
a15 += 2;
a16 += 2;
b += 32;
ii ++;
}

jj += 16;
j --;
}

if (n & 8) {
a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a5 = a + 4 * lda;
a6 = a + 5 * lda;
a7 = a + 6 * lda;
a8 = a + 7 * lda;

a += 8 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 8)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 8) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
*(b + 8) = *(a5 + 0);
*(b + 9) = *(a5 + 1);
*(b + 10) = *(a6 + 0);
*(b + 11) = *(a6 + 1);
*(b + 12) = *(a7 + 0);
*(b + 13) = *(a7 + 1);
*(b + 14) = *(a8 + 0);
*(b + 15) = *(a8 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
a5 += 2;
a6 += 2;
a7 += 2;
a8 += 2;
b += 16;
ii ++;
}

jj += 8;
}

if (n & 4) {

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a += 4 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 4)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 4) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
b += 8;
ii ++;
}

jj += 4;
}

if (n & 2) {

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a += 2 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 2)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 2) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
}

a1 += 2;
a2 += 2;
b += 4;
ii ++;
}

jj += 2;
}

if (n & 1) {

a1 = a + 0 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 1)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 1) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
}

a1 += 2;
b += 2;
ii ++;
}
}

return 0;
}

+ 264
- 0
kernel/generic/ztrsm_ltcopy_16.c View File

@@ -0,0 +1,264 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){

BLASLONG i, ii, j, jj, k;

FLOAT *a1;
FLOAT data1, data2;

lda *= 2;
jj = offset;

j = (n >> 4);
while (j > 0){

a1 = a;
a += 32;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 16)) {

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 16; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
*(b + 8) = *(a1 + 8);
*(b + 9) = *(a1 + 9);
*(b + 10) = *(a1 + 10);
*(b + 11) = *(a1 + 11);
*(b + 12) = *(a1 + 12);
*(b + 13) = *(a1 + 13);
*(b + 14) = *(a1 + 14);
*(b + 15) = *(a1 + 15);
*(b + 16) = *(a1 + 16);
*(b + 17) = *(a1 + 17);
*(b + 18) = *(a1 + 18);
*(b + 19) = *(a1 + 19);
*(b + 20) = *(a1 + 20);
*(b + 21) = *(a1 + 21);
*(b + 22) = *(a1 + 22);
*(b + 23) = *(a1 + 23);
*(b + 24) = *(a1 + 24);
*(b + 25) = *(a1 + 25);
*(b + 26) = *(a1 + 26);
*(b + 27) = *(a1 + 27);
*(b + 28) = *(a1 + 28);
*(b + 29) = *(a1 + 29);
*(b + 30) = *(a1 + 30);
*(b + 31) = *(a1 + 31);
}

b += 32;
a1 += lda;
ii ++;
}

jj += 16;
j --;
}

j = (n & 8);
if (j > 0) {
a1 = a;
a += 16;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 8)) {

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 8; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
*(b + 8) = *(a1 + 8);
*(b + 9) = *(a1 + 9);
*(b + 10) = *(a1 + 10);
*(b + 11) = *(a1 + 11);
*(b + 12) = *(a1 + 12);
*(b + 13) = *(a1 + 13);
*(b + 14) = *(a1 + 14);
*(b + 15) = *(a1 + 15);
}

b += 16;
a1 += lda;
ii ++;
}

jj += 8;
}

j = (n & 4);
if (j > 0) {

a1 = a;
a += 8;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 4)) {

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 4; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
}

b += 8;
a1 += lda;
ii ++;
}

jj += 4;
}

j = (n & 2);
if (j > 0) {

a1 = a;
a += 4;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 2)) {

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 2; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
}

b += 4;
a1 += lda;
ii ++;
}

jj += 2;
}

j = (n & 1);
if (j > 0) {

a1 = a;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 1)) {
data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
}

b += 2;
a1 += lda;
ii ++;
}
}

return 0;
}

+ 313
- 0
kernel/generic/ztrsm_uncopy_16.c View File

@@ -0,0 +1,313 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){

BLASLONG i, ii, j, jj, k;

FLOAT *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8;
FLOAT *a9, *a10, *a11, *a12, *a13, *a14, *a15, *a16;

FLOAT data1, data2;

lda *= 2;
jj = offset;

j = (n >> 4);
while (j > 0){

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a5 = a + 4 * lda;
a6 = a + 5 * lda;
a7 = a + 6 * lda;
a8 = a + 7 * lda;
a9 = a + 8 * lda;
a10 = a + 9 * lda;
a11 = a + 10 * lda;
a12 = a + 11 * lda;
a13 = a + 12 * lda;
a14 = a + 13 * lda;
a15 = a + 14 * lda;
a16 = a + 15 * lda;

a += 16 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 16)) {

data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 16; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
*(b + 8) = *(a5 + 0);
*(b + 9) = *(a5 + 1);
*(b + 10) = *(a6 + 0);
*(b + 11) = *(a6 + 1);
*(b + 12) = *(a7 + 0);
*(b + 13) = *(a7 + 1);
*(b + 14) = *(a8 + 0);
*(b + 15) = *(a8 + 1);
*(b + 16) = *(a9 + 0);
*(b + 17) = *(a9 + 1);
*(b + 18) = *(a10 + 0);
*(b + 19) = *(a10 + 1);
*(b + 20) = *(a11 + 0);
*(b + 21) = *(a11 + 1);
*(b + 22) = *(a12 + 0);
*(b + 23) = *(a12 + 1);
*(b + 24) = *(a13 + 0);
*(b + 25) = *(a13 + 1);
*(b + 26) = *(a14 + 0);
*(b + 27) = *(a14 + 1);
*(b + 28) = *(a15 + 0);
*(b + 29) = *(a15 + 1);
*(b + 30) = *(a16 + 0);
*(b + 31) = *(a16 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
a5 += 2;
a6 += 2;
a7 += 2;
a8 += 2;
a9 += 2;
a10 += 2;
a11 += 2;
a12 += 2;
a13 += 2;
a14 += 2;
a15 += 2;
a16 += 2;
b += 32;
ii ++;
}

jj += 16;
j --;
}

if (n & 8) {
a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a5 = a + 4 * lda;
a6 = a + 5 * lda;
a7 = a + 6 * lda;
a8 = a + 7 * lda;

a += 8 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 8)) {

data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 8; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
*(b + 8) = *(a5 + 0);
*(b + 9) = *(a5 + 1);
*(b + 10) = *(a6 + 0);
*(b + 11) = *(a6 + 1);
*(b + 12) = *(a7 + 0);
*(b + 13) = *(a7 + 1);
*(b + 14) = *(a8 + 0);
*(b + 15) = *(a8 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
a5 += 2;
a6 += 2;
a7 += 2;
a8 += 2;
b += 16;
ii ++;
}

jj += 8;
}

if (n & 4) {

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a3 = a + 2 * lda;
a4 = a + 3 * lda;
a += 4 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 4)) {
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);

for (k = ii - jj + 1; k < 4; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
*(b + 4) = *(a3 + 0);
*(b + 5) = *(a3 + 1);
*(b + 6) = *(a4 + 0);
*(b + 7) = *(a4 + 1);
}

a1 += 2;
a2 += 2;
a3 += 2;
a4 += 2;
b += 8;
ii ++;
}

jj += 4;
}

if (n & 2) {

a1 = a + 0 * lda;
a2 = a + 1 * lda;
a += 2 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 2)) {
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
for (k = ii - jj + 1; k < 2; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a2 + 0);
*(b + 3) = *(a2 + 1);
}

a1 += 2;
a2 += 2;
b += 4;
ii ++;
}

jj += 2;
}

if (n & 1) {

a1 = a + 0 * lda;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 1)) {
data1 = *(a1 + (ii - jj) * lda + 0);
data2 = *(a1 + (ii - jj) * lda + 1);

compinv(b + (ii - jj) * 2, data1, data2);
for (k = ii - jj + 1; k < 1; k ++) {
*(b + k * 2 + 0) = *(a1 + k * lda + 0);
*(b + k * 2 + 1) = *(a1 + k * lda + 1);
}
}

if (ii - jj < 0) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
}

a1 += 2;
b += 2;
ii ++;
}
}

return 0;
}

+ 261
- 0
kernel/generic/ztrsm_utcopy_16.c View File

@@ -0,0 +1,261 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/

#include <stdio.h>
#include "common.h"

int CNAME(BLASLONG m, BLASLONG n, FLOAT *a, BLASLONG lda, BLASLONG offset, FLOAT *b){

BLASLONG i, ii, j, jj, k;

FLOAT *a1, data1, data2;

lda *= 2;

jj = offset;

j = (n >> 4);
while (j > 0){

a1 = a;
a += 32;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 16)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 16) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
*(b + 8) = *(a1 + 8);
*(b + 9) = *(a1 + 9);
*(b + 10) = *(a1 + 10);
*(b + 11) = *(a1 + 11);
*(b + 12) = *(a1 + 12);
*(b + 13) = *(a1 + 13);
*(b + 14) = *(a1 + 14);
*(b + 15) = *(a1 + 15);
*(b + 16) = *(a1 + 16);
*(b + 17) = *(a1 + 17);
*(b + 18) = *(a1 + 18);
*(b + 19) = *(a1 + 19);
*(b + 20) = *(a1 + 20);
*(b + 21) = *(a1 + 21);
*(b + 22) = *(a1 + 22);
*(b + 23) = *(a1 + 23);
*(b + 24) = *(a1 + 24);
*(b + 25) = *(a1 + 25);
*(b + 26) = *(a1 + 26);
*(b + 27) = *(a1 + 27);
*(b + 28) = *(a1 + 28);
*(b + 29) = *(a1 + 29);
*(b + 30) = *(a1 + 30);
*(b + 31) = *(a1 + 31);
}

b += 32;
a1 += lda;
ii ++;
}

jj += 16;
j --;
}

j = (n & 8);
if (j > 0) {
a1 = a;
a += 16;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 8)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 8) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
*(b + 8) = *(a1 + 8);
*(b + 9) = *(a1 + 9);
*(b + 10) = *(a1 + 10);
*(b + 11) = *(a1 + 11);
*(b + 12) = *(a1 + 12);
*(b + 13) = *(a1 + 13);
*(b + 14) = *(a1 + 14);
*(b + 15) = *(a1 + 15);
}

b += 16;
a1 += lda;
ii ++;
}

jj += 8;
}

j = (n & 4);
if (j > 0) {

a1 = a;
a += 8;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 4)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 4) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
*(b + 4) = *(a1 + 4);
*(b + 5) = *(a1 + 5);
*(b + 6) = *(a1 + 6);
*(b + 7) = *(a1 + 7);
}

b += 8;
a1 += lda;
ii ++;
}

jj += 4;
}

j = (n & 2);
if (j > 0) {

a1 = a;
a += 4;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 2)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 2) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
*(b + 2) = *(a1 + 2);
*(b + 3) = *(a1 + 3);
}

b += 4;
a1 += lda;
ii ++;
}

jj += 2;
}

j = (n & 1);
if (j > 0) {

a1 = a;
ii = 0;

for (i = 0; i < m; i++) {

if ((ii >= jj ) && (ii - jj < 1)) {
for (k = 0; k < ii - jj; k ++) {
*(b + k * 2 + 0) = *(a1 + k * 2 + 0);
*(b + k * 2 + 1) = *(a1 + k * 2 + 1);
}

data1 = *(a1 + (ii - jj) * 2 + 0);
data2 = *(a1 + (ii - jj) * 2 + 1);

compinv(b + (ii - jj) * 2, data1, data2);
}

if (ii - jj >= 1) {
*(b + 0) = *(a1 + 0);
*(b + 1) = *(a1 + 1);
}

b += 2;
a1 += lda;
ii ++;
}
}

return 0;
}

+ 7
- 3
kernel/loongarch64/KERNEL.LOONGSON3R5 View File

@@ -111,9 +111,13 @@ SGEMMOTCOPYOBJ = sgemm_otcopy$(TSUFFIX).$(SUFFIX)
SGEMVNKERNEL = sgemv_n_8_lasx.S
SGEMVTKERNEL = sgemv_t_8_lasx.S

CGEMMKERNEL = cgemm_kernel_2x2_lsx.S
CGEMMONCOPY = cgemm_ncopy_2_lsx.S
CGEMMOTCOPY = cgemm_tcopy_2_lsx.S
CGEMMKERNEL = cgemm_kernel_16x4_lasx.S
CGEMMINCOPY = cgemm_ncopy_16_lasx.S
CGEMMITCOPY = cgemm_tcopy_16_lasx.S
CGEMMONCOPY = cgemm_ncopy_4_lasx.S
CGEMMOTCOPY = cgemm_tcopy_4_lasx.S
CGEMMINCOPYOBJ = cgemm_incopy$(TSUFFIX).$(SUFFIX)
CGEMMITCOPYOBJ = cgemm_itcopy$(TSUFFIX).$(SUFFIX)
CGEMMONCOPYOBJ = cgemm_oncopy$(TSUFFIX).$(SUFFIX)
CGEMMOTCOPYOBJ = cgemm_otcopy$(TSUFFIX).$(SUFFIX)



+ 3757
- 0
kernel/loongarch64/cgemm_kernel_16x4_lasx.S
File diff suppressed because it is too large
View File


+ 691
- 0
kernel/loongarch64/cgemm_ncopy_16_lasx.S View File

@@ -0,0 +1,691 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#define ASSEMBLER

#include "common.h"

/* Function parameters */
#define M $r4 // param 1: m
#define N $r5 // param 2: n
#define SRC $r6 // param 3: src
#define LDA $r7 // param 4: lda
#define DST $r8 // param 5: dst

#define I $r9
#define J $r10
#define S1 $r12
#define S2 $r13
#define S3 $r14
#define S4 $r15
#define S5 $r16
#define S6 $r17
#define S7 $r18
#define S8 $r19
#define S9 $r20
#define S10 $r23
#define S11 $r24
#define S12 $r25
#define S13 $r26
#define S14 $r27
#define S15 $r28
#define S16 $r29
#define TD $r30
#define TS $r31
#define TL $r7
#define T0 $r6
#define ZERO $r0

#define F0 $f0
#define F1 $f1
#define F2 $f2
#define F3 $f3
#define F4 $f4
#define F5 $f5
#define F6 $f6
#define F7 $f7
/* LASX vectors */
#define U0 $xr0
#define U1 $xr1
#define U2 $xr2
#define U3 $xr3
#define U4 $xr4
#define U5 $xr5
#define U6 $xr6
#define U7 $xr7
#define U8 $xr8
#define U9 $xr9
#define U10 $xr10
#define U11 $xr11
#define U12 $xr12
#define U13 $xr13
#define U14 $xr14
#define U15 $xr15
#define D0 $xr16
#define D1 $xr17
#define D2 $xr18
#define D3 $xr19
#define D4 $xr20
#define D5 $xr21
#define D6 $xr22
#define D7 $xr23
#define D8 $xr24
#define D9 $xr25
#define D10 $xr26
#define D11 $xr27
#define D12 $xr28
#define D13 $xr29
#define D14 $xr30
#define D15 $xr31

PROLOGUE

addi.d $sp, $sp, -0x90
SDARG $r23, $sp, 0x00
SDARG $r24, $sp, 0x08
SDARG $r25, $sp, 0x10
SDARG $r26, $sp, 0x18
SDARG $r27, $sp, 0x20
SDARG $r28, $sp, 0x28
SDARG $r29, $sp, 0x30
SDARG $r30, $sp, 0x38
SDARG $r31, $sp, 0x40
ST $f23, $sp, 0x48
ST $f24, $sp, 0x50
ST $f25, $sp, 0x58
ST $f26, $sp, 0x60
ST $f27, $sp, 0x68
ST $f28, $sp, 0x70
ST $f29, $sp, 0x78
ST $f30, $sp, 0x80
ST $f31, $sp, 0x88

move TD, DST
move TS, SRC
slli.d TL, LDA, 0x03
slli.d T0, TL, 0x01
srai.d J, N, 0x04
beq J, ZERO, .L_N8

.L_J1: /* J-- */
move S1, TS
add.d S2, TS, TL
srai.d I, M, 0x03
add.d S3, S2, TL
addi.d J, J, -1
add.d S4, S3, TL
add.d S5, S3, T0
add.d S6, S4, T0
add.d S7, S5, T0
add.d S8, S6, T0
add.d S9, S7, T0
add.d S10, S8, T0
add.d S11, S9, T0
add.d S12, S10, T0
add.d S13, S11, T0
add.d S14, S12, T0
add.d S15, S13, T0
add.d S16, S14, T0
add.d TS, S15, T0
beq I, ZERO, .L_I7

.L_I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00
xvld U4, S5, 0x00
xvld U5, S6, 0x00
xvld U6, S7, 0x00
xvld U7, S8, 0x00
xvld U8, S9, 0x00
xvld U9, S10, 0x00
xvld U10, S11, 0x00
xvld U11, S12, 0x00
xvld U12, S13, 0x00
xvld U13, S14, 0x00
xvld U14, S15, 0x00
xvld U15, S16, 0x00

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0
xvpackev.d D2, U3, U2
xvpackod.d D3, U3, U2
xvpackev.d D4, U5, U4
xvpackod.d D5, U5, U4
xvpackev.d D6, U7, U6
xvpackod.d D7, U7, U6

xvpackev.d D8, U9, U8
xvpackod.d D9, U9, U8
xvpackev.d D10, U11, U10
xvpackod.d D11, U11, U10
xvpackev.d D12, U13, U12
xvpackod.d D13, U13, U12
xvpackev.d D14, U15, U14
xvpackod.d D15, U15, U14

xvand.v U0, D0, D0
xvpermi.q D0, D2, 0x02 // 0
xvand.v U4, D4, D4
xvpermi.q D4, D6, 0x02 // 1
xvand.v U1, D1, D1
xvpermi.q D1, D3, 0x02 // 4
xvand.v U5, D5, D5
xvpermi.q D5, D7, 0x02 // 5
xvpermi.q D2, U0, 0x31 // 8
xvpermi.q D6, U4, 0x31 // 9
xvpermi.q D3, U1, 0x31 // 12
xvpermi.q D7, U5, 0x31 // 13

xvand.v U8, D8, D8
xvpermi.q D8, D10, 0x02 // 2
xvand.v U12, D12, D12
xvpermi.q D12, D14, 0x02 // 3
xvand.v U9, D9, D9
xvpermi.q D9, D11, 0x02 // 6
xvand.v U13, D13, D13
xvpermi.q D13, D15, 0x02 // 7
xvpermi.q D10, U8, 0x31 // 10
xvpermi.q D14, U12, 0x31 // 11
xvpermi.q D11, U9, 0x31 // 14
xvpermi.q D15, U13, 0x31 // 15

xvst D0, TD, 0x00 // 0
xvst D4, TD, 0x20 // 1
xvst D8, TD, 0x40 // 2
xvst D12, TD, 0x60 // 3
xvst D1, TD, 0x80 // 4
xvst D5, TD, 0xA0 // 5
xvst D9, TD, 0xC0 // 6
xvst D13, TD, 0xE0 // 7
addi.d TD, TD, 0x100
xvst D2, TD, 0x00 // 8
xvst D6, TD, 0x20 // 9
xvst D10, TD, 0x40 // 10
xvst D14, TD, 0x60 // 11
xvst D3, TD, 0x80 // 12
xvst D7, TD, 0xA0 // 13
xvst D11, TD, 0xC0 // 14
xvst D15, TD, 0xE0 // 15
addi.d TD, TD, 0x100

xvld U0, S1, 0x20
xvld U1, S2, 0x20
xvld U2, S3, 0x20
xvld U3, S4, 0x20
xvld U4, S5, 0x20
xvld U5, S6, 0x20
xvld U6, S7, 0x20
xvld U7, S8, 0x20
xvld U8, S9, 0x20
xvld U9, S10, 0x20
xvld U10, S11, 0x20
xvld U11, S12, 0x20
xvld U12, S13, 0x20
xvld U13, S14, 0x20
xvld U14, S15, 0x20
xvld U15, S16, 0x20

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0
xvpackev.d D2, U3, U2
xvpackod.d D3, U3, U2
xvpackev.d D4, U5, U4
xvpackod.d D5, U5, U4
xvpackev.d D6, U7, U6
xvpackod.d D7, U7, U6

xvpackev.d D8, U9, U8
xvpackod.d D9, U9, U8
xvpackev.d D10, U11, U10
xvpackod.d D11, U11, U10
xvpackev.d D12, U13, U12
xvpackod.d D13, U13, U12
xvpackev.d D14, U15, U14
xvpackod.d D15, U15, U14

xvand.v U0, D0, D0
xvpermi.q D0, D2, 0x02 // 0
xvand.v U4, D4, D4
xvpermi.q D4, D6, 0x02 // 1
xvand.v U1, D1, D1
xvpermi.q D1, D3, 0x02 // 4
xvand.v U5, D5, D5
xvpermi.q D5, D7, 0x02 // 5
xvpermi.q D2, U0, 0x31 // 8
xvpermi.q D6, U4, 0x31 // 9
xvpermi.q D3, U1, 0x31 // 12
xvpermi.q D7, U5, 0x31 // 13

xvand.v U8, D8, D8
xvpermi.q D8, D10, 0x02 // 2
xvand.v U12, D12, D12
xvpermi.q D12, D14, 0x02 // 3
xvand.v U9, D9, D9
xvpermi.q D9, D11, 0x02 // 6
xvand.v U13, D13, D13
xvpermi.q D13, D15, 0x02 // 7
xvpermi.q D10, U8, 0x31 // 10
xvpermi.q D14, U12, 0x31 // 11
xvpermi.q D11, U9, 0x31 // 14
xvpermi.q D15, U13, 0x31 // 15

xvst D0, TD, 0x00 // 0
xvst D4, TD, 0x20 // 1
xvst D8, TD, 0x40 // 2
xvst D12, TD, 0x60 // 3
xvst D1, TD, 0x80 // 4
xvst D5, TD, 0xA0 // 5
xvst D9, TD, 0xC0 // 6
xvst D13, TD, 0xE0 // 7
addi.d TD, TD, 0x100
xvst D2, TD, 0x00 // 8
xvst D6, TD, 0x20 // 9
xvst D10, TD, 0x40 // 10
xvst D14, TD, 0x60 // 11
xvst D3, TD, 0x80 // 12
xvst D7, TD, 0xA0 // 13
xvst D11, TD, 0xC0 // 14
xvst D15, TD, 0xE0 // 15
addi.d TD, TD, 0x100


addi.d S1, S1, 0x40
addi.d S2, S2, 0x40
addi.d S3, S3, 0x40
addi.d S4, S4, 0x40
addi.d S5, S5, 0x40
addi.d S6, S6, 0x40
addi.d S7, S7, 0x40
addi.d S8, S8, 0x40
addi.d S9, S9, 0x40
addi.d S10, S10, 0x40
addi.d S11, S11, 0x40
addi.d S12, S12, 0x40
addi.d S13, S13, 0x40
addi.d S14, S14, 0x40
addi.d S15, S15, 0x40
addi.d S16, S16, 0x40

addi.d I, I, -1
blt ZERO, I, .L_I1

.L_I7:
andi I, M, 0x07
beq I, ZERO, .L_I0

.L_II1: /* I-- */
fld.d F0, S1, 0x00
fld.d F1, S2, 0x00
fld.d F2, S3, 0x00
fld.d F3, S4, 0x00
fld.d F4, S5, 0x00
fld.d F5, S6, 0x00
fld.d F6, S7, 0x00
fld.d F7, S8, 0x00

fst.d F0, TD, 0x00
addi.d S1, S1, 0x08
fst.d F1, TD, 0x08
addi.d S2, S2, 0x08
fst.d F2, TD, 0x10
addi.d S3, S3, 0x08
fst.d F3, TD, 0x18
addi.d S4, S4, 0x08
fst.d F4, TD, 0x20
addi.d S5, S5, 0x08
fst.d F5, TD, 0x28
addi.d S6, S6, 0x08
fst.d F6, TD, 0x30
addi.d S7, S7, 0x08
fst.d F7, TD, 0x38
addi.d S8, S8, 0x08
addi.d TD, TD, 0x40

fld.d F0, S9, 0x00
fld.d F1, S10, 0x00
fld.d F2, S11, 0x00
fld.d F3, S12, 0x00
fld.d F4, S13, 0x00
fld.d F5, S14, 0x00
fld.d F6, S15, 0x00
fld.d F7, S16, 0x00

fst.d F0, TD, 0x00
addi.d S9, S9, 0x08
fst.d F1, TD, 0x08
addi.d S10, S10, 0x08
fst.d F2, TD, 0x10
addi.d S11, S11, 0x08
fst.d F3, TD, 0x18
addi.d S12, S12, 0x08
fst.d F4, TD, 0x20
addi.d S13, S13, 0x08
fst.d F5, TD, 0x28
addi.d S14, S14, 0x08
fst.d F6, TD, 0x30
addi.d S15, S15, 0x08
fst.d F7, TD, 0x38
addi.d S16, S16, 0x08
addi.d TD, TD, 0x40

addi.d I, I, -1
blt ZERO, I, .L_II1

.L_I0:
blt ZERO, J, .L_J1

.L_N8:
andi J, N, 0x08
beq ZERO, J, .L_N4

move S1, TS
add.d S2, TS, TL
srai.d I, M, 0x03
add.d S3, S2, TL
add.d S4, S2, T0
add.d S5, S3, T0
add.d S6, S4, T0
add.d S7, S5, T0
add.d S8, S6, T0
add.d TS, S7, T0
beq I, ZERO, .L_8I3

.L_8I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00
xvld U4, S5, 0x00
xvld U5, S6, 0x00
xvld U6, S7, 0x00
xvld U7, S8, 0x00

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0
xvpackev.d D2, U3, U2
xvpackod.d D3, U3, U2
xvpackev.d D4, U5, U4
xvpackod.d D5, U5, U4
xvpackev.d D6, U7, U6
xvpackod.d D7, U7, U6

xvand.v U0, D0, D0
xvpermi.q D0, D2, 0x02 // 0
xvand.v U4, D4, D4
xvpermi.q D4, D6, 0x02 // 1
xvand.v U1, D1, D1
xvpermi.q D1, D3, 0x02 // 2
xvand.v U5, D5, D5
xvpermi.q D5, D7, 0x02 // 3
xvpermi.q D2, U0, 0x31 // 4
xvpermi.q D6, U4, 0x31 // 5
xvpermi.q D3, U1, 0x31 // 6
xvpermi.q D7, U5, 0x31 // 7

xvst D0, TD, 0x00
xvst D4, TD, 0x20
xvst D1, TD, 0x40
xvst D5, TD, 0x60
xvst D2, TD, 0x80
xvst D6, TD, 0xA0
xvst D3, TD, 0xC0
xvst D7, TD, 0xE0
addi.d TD, TD, 0x100

xvld U0, S1, 0x20
xvld U1, S2, 0x20
xvld U2, S3, 0x20
xvld U3, S4, 0x20
xvld U4, S5, 0x20
xvld U5, S6, 0x20
xvld U6, S7, 0x20
xvld U7, S8, 0x20

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0
xvpackev.d D2, U3, U2
xvpackod.d D3, U3, U2
xvpackev.d D4, U5, U4
xvpackod.d D5, U5, U4
xvpackev.d D6, U7, U6
xvpackod.d D7, U7, U6

xvand.v U0, D0, D0
xvpermi.q D0, D2, 0x02 // 0
xvand.v U4, D4, D4
xvpermi.q D4, D6, 0x02 // 1
xvand.v U1, D1, D1
xvpermi.q D1, D3, 0x02 // 2
xvand.v U5, D5, D5
xvpermi.q D5, D7, 0x02 // 3
xvpermi.q D2, U0, 0x31 // 4
xvpermi.q D6, U4, 0x31 // 5
xvpermi.q D3, U1, 0x31 // 6
xvpermi.q D7, U5, 0x31 // 7

xvst D0, TD, 0x00
xvst D4, TD, 0x20
xvst D1, TD, 0x40
xvst D5, TD, 0x60
xvst D2, TD, 0x80
xvst D6, TD, 0xA0
xvst D3, TD, 0xC0
xvst D7, TD, 0xE0
addi.d TD, TD, 0x100

addi.d S1, S1, 0x40
addi.d S2, S2, 0x40
addi.d S3, S3, 0x40
addi.d S4, S4, 0x40
addi.d S5, S5, 0x40
addi.d S6, S6, 0x40
addi.d S7, S7, 0x40
addi.d S8, S8, 0x40

addi.d I, I, -1
blt ZERO, I, .L_8I1

.L_8I3:
andi I, M, 0x07
beq I, ZERO, .L_N4

.L_8I11:
fld.d F0, S1, 0x00
fld.d F1, S2, 0x00
fld.d F2, S3, 0x00
fld.d F3, S4, 0x00
fld.d F4, S5, 0x00
fld.d F5, S6, 0x00
fld.d F6, S7, 0x00
fld.d F7, S8, 0x00

fst.d F0, TD, 0x00
addi.d S1, S1, 0x08
fst.d F1, TD, 0x08
addi.d S2, S2, 0x08
fst.d F2, TD, 0x10
addi.d S3, S3, 0x08
fst.d F3, TD, 0x18
addi.d S4, S4, 0x08
fst.d F4, TD, 0x20
addi.d S5, S5, 0x08
fst.d F5, TD, 0x28
addi.d S6, S6, 0x08
fst.d F6, TD, 0x30
addi.d S7, S7, 0x08
fst.d F7, TD, 0x38
addi.d S8, S8, 0x08

addi.d TD, TD, 0x40
addi.d I, I, -1
blt ZERO, I, .L_8I11

.L_N4:
andi J, N, 0x04
beq ZERO, J, .L_N2

move S1, TS
add.d S2, TS, TL
srai.d I, M, 0x02
add.d S3, S2, TL
add.d S4, S2, T0
add.d TS, S3, T0
beq I, ZERO, .L_I3

.L_4I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0
xvpackev.d D2, U3, U2
xvpackod.d D3, U3, U2

xvand.v U0, D0, D0
xvpermi.q D0, D2, 0x02 // 0
xvand.v U1, D1, D1
xvpermi.q D1, D3, 0x02 // 1
xvpermi.q D2, U0, 0x31 // 2
xvpermi.q D3, U1, 0x31 // 3

xvst D0, TD, 0x00
xvst D1, TD, 0x20
xvst D2, TD, 0x40
xvst D3, TD, 0x60

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
addi.d S3, S3, 0x20
addi.d S4, S4, 0x20
addi.d TD, TD, 0x80

addi.d I, I, -1
blt ZERO, I, .L_4I1

.L_I3:
andi I, M, 0x03
beq I, ZERO, .L_N2

.L_4II1:
fld.d F0, S1, 0x00
fld.d F1, S2, 0x00
fld.d F2, S3, 0x00
fld.d F3, S4, 0x00

fst.d F0, TD, 0x00
addi.d S1, S1, 0x08
fst.d F1, TD, 0x08
addi.d S2, S2, 0x08
fst.d F2, TD, 0x10
addi.d S3, S3, 0x08
fst.d F3, TD, 0x18
addi.d S4, S4, 0x08

addi.d TD, TD, 0x20
addi.d I, I, -1
blt ZERO, I, .L_4II1

.L_N2:
andi J, N, 0x02
beq ZERO, J, .L_N1

move S1, TS
add.d S2, TS, TL
srai.d I, M, 0x01
add.d TS, S2, TL
beq I, ZERO, .L_NI1

.L_2I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S2, 0x00

xvpackev.d D0, U1, U0
xvpackod.d D1, U1, U0

xvpermi.q D0, D1, 0x02 // 0

xvst D0, TD, 0x00

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d TD, TD, 0x20

addi.d I, I, -1
blt ZERO, I, .L_2I1

.L_NI1:
andi I, M, 0x01
beq I, ZERO, .L_N1


fld.d F0, S1, 0x00
fld.d F1, S2, 0x00

fst.d F0, TD, 0x00
addi.d S1, S1, 0x08
fst.d F1, TD, 0x08
addi.d S2, S2, 0x08
addi.d TD, TD, 0x10

.L_N1:
move S1, TS
beq ZERO, M, .L_N0

.L_M1:
fld.d F0, S1, 0x00
addi.d S1, S1, 0x08
fst.d F0, TD, 0x00
addi.d TD, TD, 0x08
addi.d M, M, -1
blt ZERO, M, .L_M1

.L_N0:
LDARG $r23, $sp, 0x00
LDARG $r24, $sp, 0x08
LDARG $r25, $sp, 0x10
LDARG $r26, $sp, 0x18
LDARG $r27, $sp, 0x20
LDARG $r28, $sp, 0x28
LDARG $r29, $sp, 0x30
LDARG $r30, $sp, 0x38
LDARG $r31, $sp, 0x40
LD $f23, $sp, 0x48
LD $f24, $sp, 0x50
LD $f25, $sp, 0x58
LD $f26, $sp, 0x60
LD $f27, $sp, 0x68
LD $f28, $sp, 0x70
LD $f29, $sp, 0x78
LD $f30, $sp, 0x80
LD $f31, $sp, 0x88
addi.d $sp, $sp, 0x90
jirl $r0, $r1, 0x00

EPILOGUE

+ 325
- 0
kernel/loongarch64/cgemm_ncopy_4_lasx.S View File

@@ -0,0 +1,325 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#define ASSEMBLER

#include "common.h"

/* Function parameters */
#define M $r4 // param 1: m
#define N $r5 // param 2: n
#define SRC $r6 // param 3: src
#define LDA $r7 // param 4: lda
#define DST $r8 // param 5: dst

#define I $r9
#define J $r10
#define S1 $r12
#define S2 $r13
#define S3 $r14
#define S4 $r15
#define S5 $r16
#define S6 $r17
#define S7 $r18
#define TD $r20
#define TS $r11
#define TL $r19
#define T0 $r23
#define ZERO $r0

#define F0 $f0
#define F1 $f1
#define F2 $f2
#define F3 $f3
#define F4 $f4
#define F5 $f5
#define F6 $f6
#define F7 $f7

/* LASX vectors */
#define U0 $xr0
#define U1 $xr1
#define U2 $xr2
#define U3 $xr3
#define U4 $xr4
#define U5 $xr5
#define U6 $xr6
#define U7 $xr7
#define D0 $xr8
#define D1 $xr9
#define D2 $xr10
#define D3 $xr11
#define D4 $xr12
#define D5 $xr13
#define D6 $xr14
#define D7 $xr15
#define D8 $xr16

PROLOGUE

addi.d $sp, $sp, -8
SDARG $r23, $sp, 0

move TD, DST //boffset
move TS, SRC //aoffset

slli.d TL, LDA, 0x02
slli.d TL, TL, 0x01

srai.d J, N, 0x02
beq J, ZERO, .L_N0

.L_J1: /* J-- */
move S1, TS
add.d S2, S1, TL
add.d S3, S2, TL
add.d S4, S3, TL

slli.d T0, TL, 0x02
add.d TS, TS, T0

srai.d I, M, 0x02
beq I, ZERO, .L_I3

.L_I1: /* I-- */
xvld U0, S1, 0x00 //1 2 3 4 5 6 7 8
xvld U1, S2, 0x00 //9 10 11 12 13 14 15 16
xvld U2, S3, 0x00 //17 18 19 20 21 22 23 24
xvld U3, S4, 0x00 //25 26 27 28 29 30 31 32

xvand.v D0, U0, U0
xvand.v D1, U1, U1
xvand.v D2, U2, U2
xvand.v D3, U3, U3

xvshuf4i.d D0, U1, 0x88 //1 2 9 10 5 6 13 14
xvshuf4i.d D2, U3, 0x88 //17 18 25 26 21 22 29 30
xvshuf4i.d D1, U0, 0x77 //3 4 11 12 7 8 15 16
xvshuf4i.d D3, U2, 0x77 //19 20 27 28 23 24 31 32

xvand.v U4, D0, D0
xvand.v U5, D1, D1

xvpermi.q U4, D2, 0x02 //1 2 9 10 17 18 25 26
xvpermi.q U5, D3, 0x02 //3 4 11 12 19 20 27 28
xvpermi.q D2, D0, 0x31 //5 6 13 14 21 22 29 30
xvpermi.q D3, D1, 0x31 //7 8 15 16 23 24 31 32

xvst U4, TD, 0x00
xvst U5, TD, 0x20
xvst D2, TD, 0x40
xvst D3, TD, 0x60

addi.d S1, S1, 0x20 // a_offset
addi.d S2, S2, 0x20
addi.d S3, S3, 0x20
addi.d S4, S4, 0x20
addi.d TD, TD, 0x80 // b_offset

addi.d I, I, -1
blt ZERO, I, .L_I1

.L_I3: /* if(m&2) */
andi I, M, 0x02
beq I, ZERO, .L_II20

vld $vr0, S1, 0x00
vld $vr1, S2, 0x00
vld $vr2, S3, 0x00
vld $vr3, S4, 0x00

vand.v $vr8, $vr1, $vr1
vand.v $vr9, $vr1, $vr1
vand.v $vr10, $vr3, $vr3
vand.v $vr11, $vr3, $vr3

vpermi.w $vr8, $vr0, 0x44
vpermi.w $vr10, $vr2, 0x44
vpermi.w $vr9, $vr0, 0xee
vpermi.w $vr11, $vr2, 0xee

vst $vr8, TD, 0x00
vst $vr10, TD, 0x10
vst $vr9, TD, 0x20
vst $vr11, TD, 0x30

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d S3, S3, 0x10
addi.d S4, S4, 0x10
addi.d TD, TD, 0x40

.L_II20: /* if(m&1) */
andi I, M, 0x01
beq I, ZERO, .L_J0

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fld.s F2, S2, 0x00
fld.s F3, S2, 0x04

fld.s F4, S3, 0x00
fld.s F5, S3, 0x04

fld.s F6, S4, 0x00
fld.s F7, S4, 0x04

fst.s F0, TD, 0x00
fst.s F1, TD, 0x04
fst.s F2, TD, 0x08
fst.s F3, TD, 0x0c
fst.s F4, TD, 0x10
fst.s F5, TD, 0x14
fst.s F6, TD, 0x18
fst.s F7, TD, 0x1c

addi.d TD, TD, 0x20

.L_J0:
addi.d J, J, -1
blt ZERO, J, .L_J1

.L_N0: /* if(n&2) */
andi I, N, 0x02
beq ZERO, I, .L_N20

move S1, TS
add.d S2, S1, TL

slli.d T0, TL, 0x01
add.d TS, TS, T0

srai.d I, M, 0x02
beq ZERO, I, .L_N10

.L_N11: /* if(i>0) */
xvld U0, S1, 0x00 //1 2 3 4 5 6 7 8
xvld U1, S2, 0x00 //9 10 11 12 13 14 15 16

xvand.v D0, U0, U0
xvand.v D1, U1, U1

xvshuf4i.d D0, U1, 0x88 //1 2 9 10 5 6 13 14
xvshuf4i.d D1, U0, 0x77 //3 4 11 12 7 8 15 16

xvand.v U4, D0, D0

xvpermi.q U4, D1, 0x02 //1 2 9 10 3 4 11 12
xvpermi.q D1, D0, 0x31 //5 6 13 14 7 8 15 16

xvst U4, TD, 0x00
xvst D1, TD, 0x20

addi.d S1, S1, 0x20 // a_offset
addi.d S2, S2, 0x20
addi.d TD, TD, 0x40 // b_offset

addi.d I, I, -1
blt ZERO, I, .L_N11

.L_N10: /* if(m&2) */
andi I, M, 0x02
beq I, ZERO, .L_N130

vld $vr0, S1, 0x00
vld $vr1, S2, 0x00
vand.v $vr8, $vr1, $vr1

vpermi.w $vr8, $vr0, 0x44
vpermi.w $vr1, $vr0, 0xee

vst $vr8, TD, 0x00
vst $vr1, TD, 0x10

addi.d S1, S1, 0x10 // a_offset
addi.d S2, S2, 0x10
addi.d TD, TD, 0x20 // b_offset

.L_N130: /* if(m&1) */
andi I, M, 0x01
beq I, ZERO, .L_N20

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fld.s F2, S2, 0x00
fld.s F3, S2, 0x04

fst.s F0, TD, 0x00
fst.s F1, TD, 0x04
fst.s F2, TD, 0x08
fst.s F3, TD, 0x0c

addi.d TD, TD, 0x10

.L_N20: /* if(n&1) */
andi I, N, 0x01
beq I, ZERO, .L_N00

move S1, TS
srai.d I, M, 0x02

beq I, ZERO, .L_N30

.L_N21: /* if(i>0) */
xvld U0, S1, 0x00

xvst U0, TD, 0x00

addi.d S1, S1, 0x20 // aoffset1
addi.d TD, TD, 0x20 // b_offset

addi.d I, I, -1
blt ZERO, I, .L_N21

.L_N30: /* if(m&2) */
andi I, M, 0x02
beq I, ZERO, .L_N330

vld $vr0, S1, 0x00

vst $vr0, TD, 0x00

addi.d S1, S1, 0x10 // aoffset1
addi.d TD, TD, 0x10 // b_offset

.L_N330: /* if(m&1) */
andi I, M, 0x01
beq I, ZERO, .L_N00

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fst.s F0, TD, 0x00
fst.s F1, TD, 0x04

.L_N00:
LDARG $r23, $sp, 0
addi.d $sp, $sp, 8
jirl $r0, $r1, 0x00

EPILOGUE

+ 741
- 0
kernel/loongarch64/cgemm_tcopy_16_lasx.S View File

@@ -0,0 +1,741 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#define ASSEMBLER

#include "common.h"
/* Function parameters */
#define M $r4 // param 1: m
#define N $r5 // param 2: n
#define SRC $r6 // param 3: src
#define LDA $r7 // param 4: lda
#define DST $r8 // param 5: dst

#define I $r9
#define J $r10
#define S0 $r11
#define S1 $r12
#define S2 $r13
#define S3 $r14
#define S4 $r15
#define S5 $r16
#define S6 $r17
#define S7 $r18
#define S8 $r19
#define P0 $r20
#define P1 $r23
#define P2 $r24
#define P3 $r25
#define P4 $r26
#define P5 $r27
#define T0 $r28
#define T1 $r29
#define TL $r7
#define ZERO $r0

#define F0 $f0
#define F1 $f1
#define F2 $f2
#define F3 $f3
#define F4 $f4
#define F5 $f5
#define F6 $f6
#define F7 $f7
#define F8 $f8
#define F9 $f9
#define F10 $f10
#define F11 $f11
#define F12 $f12
#define F13 $f13
#define F14 $f14
#define F15 $f15
/* LASX vectors */
#define U0 $xr0
#define U1 $xr1
#define U2 $xr2
#define U3 $xr3
#define U4 $xr4
#define U5 $xr5
#define U6 $xr6
#define U7 $xr7

PROLOGUE

addi.d $sp, $sp, -56
SDARG $r23, $sp, 0
SDARG $r24, $sp, 8
SDARG $r25, $sp, 16
SDARG $r26, $sp, 24
SDARG $r27, $sp, 32
SDARG $r28, $sp, 40
SDARG $r29, $sp, 48

move S0, SRC
move P0, DST

srai.d T0, N, 0x04
srai.d T1, N, 0x03
slli.d T0, T0, 0x04
slli.d T1, T1, 0x03
mul.d P2, M, T0
mul.d P3, M, T1
slli.d P2, P2, 0x03
slli.d P3, P3, 0x03
add.d P2, DST, P2
add.d P3, DST, P3

srai.d T0, N, 0x02
srai.d T1, N, 0x01
slli.d T0, T0, 0x02
slli.d T1, T1, 0x01
mul.d P4, M, T0
mul.d P5, M, T1
slli.d P4, P4, 0x03
slli.d P5, P5, 0x03
add.d P4, DST, P4
add.d P5, DST, P5

slli.d TL, LDA, 0x03
srai.d J, M, 0x03
slli.d T0, TL, 0x01
slli.d T1, M, 0x07
beq ZERO, J, .L_M7

.L_J1: /* J-- */
move S1, S0
add.d S2, S0, TL
add.d S3, S1, T0
add.d S4, S2, T0
add.d S5, S3, T0
add.d S6, S4, T0
add.d S7, S5, T0
add.d S8, S6, T0
add.d S0, S7, T0

move P1, P0
addi.d P0, P0, 0x400

srai.d I, N, 0x04
addi.d J, J, -1
beq ZERO, I, .L_N15

.L_I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S1, 0x40
xvld U3, S1, 0x60
xvld U4, S2, 0x00
xvld U5, S2, 0x20
xvld U6, S2, 0x40
xvld U7, S2, 0x60

xvst U0, P1, 0x00
xvst U1, P1, 0x20
xvst U2, P1, 0x40
xvst U3, P1, 0x60
xvst U4, P1, 0x80
xvst U5, P1, 0xA0
xvst U6, P1, 0xC0
xvst U7, P1, 0xE0

xvld U0, S3, 0x00
xvld U1, S3, 0x20
xvld U2, S3, 0x40
xvld U3, S3, 0x60
xvld U4, S4, 0x00
xvld U5, S4, 0x20
xvld U6, S4, 0x40
xvld U7, S4, 0x60

xvst U0, P1, 0x100
xvst U1, P1, 0x120
xvst U2, P1, 0x140
xvst U3, P1, 0x160
xvst U4, P1, 0x180
xvst U5, P1, 0x1A0
xvst U6, P1, 0x1C0
xvst U7, P1, 0x1E0

xvld U0, S5, 0x00
xvld U1, S5, 0x20
xvld U2, S5, 0x40
xvld U3, S5, 0x60
xvld U4, S6, 0x00
xvld U5, S6, 0x20
xvld U6, S6, 0x40
xvld U7, S6, 0x60

xvst U0, P1, 0x200
xvst U1, P1, 0x220
xvst U2, P1, 0x240
xvst U3, P1, 0x260
xvst U4, P1, 0x280
xvst U5, P1, 0x2A0
xvst U6, P1, 0x2C0
xvst U7, P1, 0x2E0

xvld U0, S7, 0x00
xvld U1, S7, 0x20
xvld U2, S7, 0x40
xvld U3, S7, 0x60
xvld U4, S8, 0x00
xvld U5, S8, 0x20
xvld U6, S8, 0x40
xvld U7, S8, 0x60

xvst U0, P1, 0x300
xvst U1, P1, 0x320
xvst U2, P1, 0x340
xvst U3, P1, 0x360
xvst U4, P1, 0x380
xvst U5, P1, 0x3A0
xvst U6, P1, 0x3C0
xvst U7, P1, 0x3E0

addi.d S1, S1, 0x80
addi.d S2, S2, 0x80
addi.d S3, S3, 0x80
addi.d S4, S4, 0x80
addi.d S5, S5, 0x80
addi.d S6, S6, 0x80
addi.d S7, S7, 0x80
addi.d S8, S8, 0x80
addi.d I, I, -1
add.d P1, P1, T1
blt ZERO, I, .L_I1

.L_N15:
andi I, N, 0x08
beq ZERO, I, .L_N7

xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S2, 0x00
xvld U3, S2, 0x20
xvld U4, S3, 0x00
xvld U5, S3, 0x20
xvld U6, S4, 0x00
xvld U7, S4, 0x20

xvst U0, P2, 0x00
xvst U1, P2, 0x20
xvst U2, P2, 0x40
xvst U3, P2, 0x60
xvst U4, P2, 0x80
xvst U5, P2, 0xA0
xvst U6, P2, 0xC0
xvst U7, P2, 0xE0

xvld U0, S5, 0x00
xvld U1, S5, 0x20
xvld U2, S6, 0x00
xvld U3, S6, 0x20
xvld U4, S7, 0x00
xvld U5, S7, 0x20
xvld U6, S8, 0x00
xvld U7, S8, 0x20

xvst U0, P2, 0x100
xvst U1, P2, 0x120
xvst U2, P2, 0x140
xvst U3, P2, 0x160
xvst U4, P2, 0x180
xvst U5, P2, 0x1A0
xvst U6, P2, 0x1C0
xvst U7, P2, 0x1E0

addi.d S1, S1, 0x40
addi.d S2, S2, 0x40
addi.d S3, S3, 0x40
addi.d S4, S4, 0x40
addi.d S5, S5, 0x40
addi.d S6, S6, 0x40
addi.d S7, S7, 0x40
addi.d S8, S8, 0x40
addi.d P2, P2, 0x200

.L_N7:
andi I, N, 0x04
beq ZERO, I, .L_N3

xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00
xvld U4, S5, 0x00
xvld U5, S6, 0x00
xvld U6, S7, 0x00
xvld U7, S8, 0x00

xvst U0, P3, 0x00
xvst U1, P3, 0x20
xvst U2, P3, 0x40
xvst U3, P3, 0x60
xvst U4, P3, 0x80
xvst U5, P3, 0xA0
xvst U6, P3, 0xC0
xvst U7, P3, 0xE0

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
addi.d S3, S3, 0x20
addi.d S4, S4, 0x20
addi.d S5, S5, 0x20
addi.d S6, S6, 0x20
addi.d S7, S7, 0x20
addi.d S8, S8, 0x20
addi.d P3, P3, 0x100

.L_N3:
andi I, N, 0x02
beq ZERO, I, .L_N1

xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00
xvld U4, S5, 0x00
xvld U5, S6, 0x00
xvld U6, S7, 0x00
xvld U7, S8, 0x00

xvpermi.q U0, U1, 0x02
xvpermi.q U2, U3, 0x02
xvpermi.q U4, U5, 0x02
xvpermi.q U6, U7, 0x02

xvst U0, P4, 0x00
xvst U2, P4, 0x20
xvst U4, P4, 0x40
xvst U6, P4, 0x60

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d S3, S3, 0x10
addi.d S4, S4, 0x10
addi.d S5, S5, 0x10
addi.d S6, S6, 0x10
addi.d S7, S7, 0x10
addi.d S8, S8, 0x10
addi.d P4, P4, 0x80

.L_N1:
andi I, N, 0x01
beq ZERO, I, .L_N0

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fld.s F2, S2, 0x00
fld.s F3, S2, 0x04

fld.s F4, S3, 0x00
fld.s F5, S3, 0x04

fld.s F6, S4, 0x00
fld.s F7, S4, 0x04

fld.s F8, S5, 0x00
fld.s F9, S5, 0x04

fld.s F10, S6, 0x00
fld.s F11, S6, 0x04

fld.s F12, S7, 0x00
fld.s F13, S7, 0x04

fld.s F14, S8, 0x00
fld.s F15, S8, 0x04

fst.s F0, P5, 0x00
fst.s F1, P5, 0x04
fst.s F2, P5, 0x08
fst.s F3, P5, 0x0c
fst.s F4, P5, 0x10
fst.s F5, P5, 0x14
fst.s F6, P5, 0x18
fst.s F7, P5, 0x1c
fst.s F8, P5, 0x20
fst.s F9, P5, 0x24
fst.s F10, P5, 0x28
fst.s F11, P5, 0x2c
fst.s F12, P5, 0x30
fst.s F13, P5, 0x34
fst.s F14, P5, 0x38
fst.s F15, P5, 0x3c

addi.d S1, S1, 0x08
addi.d S2, S2, 0x08
addi.d S3, S3, 0x08
addi.d S4, S4, 0x08
addi.d S5, S5, 0x08
addi.d S6, S6, 0x08
addi.d S7, S7, 0x08
addi.d S8, S8, 0x08
addi.d P5, P5, 0x40

.L_N0:
blt ZERO, J, .L_J1

.L_M7:
andi J, M, 0x04
beq ZERO, J, .L_M3

move S1, S0
add.d S2, S0, TL
add.d S3, S1, T0
add.d S4, S2, T0
add.d S0, S3, T0

move P1, P0
addi.d P0, P0, 0x200

srai.d I, N, 0x04
beq ZERO, I, .L_4N15

.L_4I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S1, 0x40
xvld U3, S1, 0x60
xvld U4, S2, 0x00
xvld U5, S2, 0x20
xvld U6, S2, 0x40
xvld U7, S2, 0x60

xvst U0, P1, 0x00
xvst U1, P1, 0x20
xvst U2, P1, 0x40
xvst U3, P1, 0x60
xvst U4, P1, 0x80
xvst U5, P1, 0xA0
xvst U6, P1, 0xC0
xvst U7, P1, 0xE0

xvld U0, S3, 0x00
xvld U1, S3, 0x20
xvld U2, S3, 0x40
xvld U3, S3, 0x60
xvld U4, S4, 0x00
xvld U5, S4, 0x20
xvld U6, S4, 0x40
xvld U7, S4, 0x60

xvst U0, P1, 0x100
xvst U1, P1, 0x120
xvst U2, P1, 0x140
xvst U3, P1, 0x160
xvst U4, P1, 0x180
xvst U5, P1, 0x1A0
xvst U6, P1, 0x1C0
xvst U7, P1, 0x1E0

addi.d S1, S1, 0x80
addi.d S2, S2, 0x80
addi.d S3, S3, 0x80
addi.d S4, S4, 0x80
addi.d I, I, -1
add.d P1, P1, T1
blt ZERO, I, .L_4I1

.L_4N15:
andi I, N, 0x08
beq ZERO, I, .L_4N7

xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S2, 0x00
xvld U3, S2, 0x20
xvld U4, S3, 0x00
xvld U5, S3, 0x20
xvld U6, S4, 0x00
xvld U7, S4, 0x20

xvst U0, P2, 0x00
xvst U1, P2, 0x20
xvst U2, P2, 0x40
xvst U3, P2, 0x60
xvst U4, P2, 0x80
xvst U5, P2, 0xA0
xvst U6, P2, 0xC0
xvst U7, P2, 0xE0

addi.d S1, S1, 0x40
addi.d S2, S2, 0x40
addi.d S3, S3, 0x40
addi.d S4, S4, 0x40
addi.d P2, P2, 0x100

.L_4N7:
andi I, N, 0x04
beq ZERO, I, .L_4N3

xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00

xvst U0, P3, 0x00
xvst U1, P3, 0x20
xvst U2, P3, 0x40
xvst U3, P3, 0x60

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
addi.d S3, S3, 0x20
addi.d S4, S4, 0x20
addi.d P3, P3, 0x80

.L_4N3:
andi I, N, 0x02
beq ZERO, I, .L_4N1

xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00

xvpermi.q U0, U1, 0x02
xvpermi.q U2, U3, 0x02

xvst U0, P4, 0x00
xvst U2, P4, 0x20

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d S3, S3, 0x10
addi.d S4, S4, 0x10
addi.d P4, P4, 0x40

.L_4N1:
andi I, N, 0x01
beq ZERO, I, .L_M3

fld.d F0, S1, 0x00
fld.d F1, S2, 0x00
fld.d F2, S3, 0x00
fld.d F3, S4, 0x00

fst.d F0, P5, 0x00
fst.d F1, P5, 0x08
fst.d F2, P5, 0x10
fst.d F3, P5, 0x18

addi.d S1, S1, 0x08
addi.d S2, S2, 0x08
addi.d S3, S3, 0x08
addi.d S4, S4, 0x08
addi.d P5, P5, 0x20

.L_M3:
andi J, M, 0x02
beq ZERO, J, .L_M1

move S1, S0
add.d S2, S0, TL
add.d S0, S0, T0

move P1, P0
addi.d P0, P0, 0x100

srai.d I, N, 0x04
beq ZERO, I, .L_2N15

.L_2I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S1, 0x40
xvld U3, S1, 0x60
xvld U4, S2, 0x00
xvld U5, S2, 0x20
xvld U6, S2, 0x40
xvld U7, S2, 0x60

xvst U0, P1, 0x00
xvst U1, P1, 0x20
xvst U2, P1, 0x40
xvst U3, P1, 0x60
xvst U4, P1, 0x80
xvst U5, P1, 0xA0
xvst U6, P1, 0xC0
xvst U7, P1, 0xE0

addi.d S1, S1, 0x80
addi.d S2, S2, 0x80
addi.d I, I, -1
add.d P1, P1, T1
blt ZERO, I, .L_2I1

.L_2N15:
andi I, N, 0x08
beq ZERO, I, .L_2N7

xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S2, 0x00
xvld U3, S2, 0x20

xvst U0, P2, 0x00
xvst U1, P2, 0x20
xvst U2, P2, 0x40
xvst U3, P2, 0x60

addi.d S1, S1, 0x40
addi.d S2, S2, 0x40
addi.d P2, P2, 0x80

.L_2N7:
andi I, N, 0x04
beq ZERO, I, .L_2N3

xvld U0, S1, 0x00
xvld U1, S2, 0x00

xvst U0, P3, 0x00
xvst U1, P3, 0x20

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
addi.d P3, P3, 0x40

.L_2N3:
andi I, N, 0x02
beq ZERO, I, .L_2N1

xvld U0, S1, 0x00
xvld U1, S2, 0x00

xvpermi.q U0, U1, 0x02

xvst U0, P4, 0x00

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d P4, P4, 0x20

.L_2N1:
andi I, N, 0x01
beq ZERO, I, .L_M1

fld.d F0, S1, 0x00
fld.d F1, S2, 0x00

fst.d F0, P5, 0x00
fst.d F1, P5, 0x08

addi.d S1, S1, 0x08
addi.d S2, S2, 0x08
addi.d P5, P5, 0x10

.L_M1:
andi J, M, 0x01
beq ZERO, J, .L_M0

move S1, S0
add.d S2, S0, TL

move P1, P0
addi.d P0, P0, 0x80

srai.d I, N, 0x04
beq ZERO, I, .L_1N15

.L_1I1: /* I-- */
xvld U0, S1, 0x00
xvld U1, S1, 0x20
xvld U2, S1, 0x40
xvld U3, S1, 0x60

xvst U0, P1, 0x00
xvst U1, P1, 0x20
xvst U2, P1, 0x40
xvst U3, P1, 0x60

addi.d S1, S1, 0x80
addi.d I, I, -1
add.d P1, P1, T1
blt ZERO, I, .L_1I1

.L_1N15:
andi I, N, 0x08
beq ZERO, I, .L_1N7

xvld U0, S1, 0x00
xvld U1, S1, 0x20

xvst U0, P2, 0x00
xvst U1, P2, 0x20

addi.d S1, S1, 0x40
addi.d P2, P2, 0x40

.L_1N7:
andi I, N, 0x04
beq ZERO, I, .L_1N3

xvld U0, S1, 0x00

xvst U0, P3, 0x00

addi.d S1, S1, 0x20
addi.d P3, P3, 0x20

.L_1N3:
andi I, N, 0x02
beq ZERO, I, .L_1N1

fld.d F0, S1, 0x00
fld.d F1, S1, 0x08

fst.d F0, P4, 0x00
fst.d F1, P4, 0x08

addi.d S1, S1, 0x10
addi.d P4, P4, 0x10

.L_1N1:
andi I, N, 0x01
beq ZERO, I, .L_M0

fld.d F0, S1, 0x00

fst.d F0, P5, 0x00

addi.d S1, S1, 0x08
addi.d P5, P5, 0x08

.L_M0:
LDARG $r23, $sp, 0
LDARG $r24, $sp, 8
LDARG $r25, $sp, 16
LDARG $r26, $sp, 24
LDARG $r27, $sp, 32
LDARG $r28, $sp, 40
LDARG $r29, $sp, 48
addi.d $sp, $sp, 56
jirl $r0, $r1, 0x00

EPILOGUE

+ 306
- 0
kernel/loongarch64/cgemm_tcopy_4_lasx.S View File

@@ -0,0 +1,306 @@
/*******************************************************************************
Copyright (c) 2024, The OpenBLAS Project
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. Neither the name of the OpenBLAS project nor the names of
its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************/
#define ASSEMBLER

#include "common.h"

/* Function parameters */
#define M $r4 // param 1: m
#define N $r5 // param 2: n
#define SRC $r6 // param 3: src
#define LDA $r7 // param 4: lda
#define DST $r8 // param 5: dst

#define I $r9
#define J $r10
#define S1 $r12
#define S2 $r13
#define S3 $r14
#define S4 $r15
#define TD $r16
#define TS $r17
#define TL $r18
#define T0 $r19
#define S8 $r20
#define S9 $r23
#define S10 $r11
#define ZERO $r0

#define F0 $f0
#define F1 $f1
#define F2 $f2
#define F3 $f3
#define F4 $f4
#define F5 $f5
#define F6 $f6
#define F7 $f7

/* LASX vectors */
#define U0 $xr0
#define U1 $xr1
#define U2 $xr2
#define U3 $xr3
#define U4 $xr4
#define U5 $xr5
#define U6 $xr6
#define U7 $xr7
#define U8 $xr8
#define U9 $xr9
#define U10 $xr10
#define U11 $xr11
#define U12 $xr12
#define U13 $xr13
#define U14 $xr14
#define U15 $xr15


PROLOGUE

addi.d $sp, $sp, -8
SDARG $r23, $sp, 0

move TS, SRC //aoffset
move TD, DST //boffset
slli.d TL, LDA, 0x02 //lda
slli.d TL, TL, 0x01 //lda

ori T0, ZERO, 0x03
andn T0, N, T0
mul.w T0, M, T0
slli.d T0, T0, 0x01
slli.d T0, T0, 0x02
add.d S9, DST, T0 //boffset2

ori T0, ZERO, 0x01
andn T0, N, T0
mul.w T0, M, T0
slli.d T0, T0, 0x01
slli.d T0, T0, 0x02
add.d S10, DST, T0 //boffset3

srai.d J, M, 0x02 //j

beq J, ZERO, .L_M1

.L_J1: /* if(j>0) j--*/
move S1, TS //aoffset1
add.d S2, S1, TL
add.d S3, S2, TL
add.d S4, S3, TL

slli.d T0, TL, 0x02
add.d TS, TS, T0

move S8, TD //boffset1
addi.d TD, TD, 0x80

srai.d I, N, 0x02

beq ZERO, I, .L_JN1

.L_JI1: /* if(i>0) i--*/
xvld U0, S1, 0x00
xvld U1, S2, 0x00
xvld U2, S3, 0x00
xvld U3, S4, 0x00

xvst U0, S8, 0x00
xvst U1, S8, 0x20
xvst U2, S8, 0x40
xvst U3, S8, 0x60

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
addi.d S3, S3, 0x20
addi.d S4, S4, 0x20
slli.d T0, M, 0x05
add.d S8, S8, T0

addi.d I, I, -1
blt ZERO, I, .L_JI1

.L_JN1: /* if(n&2) */
andi I, N, 0x02
beq ZERO, I, .L_JN2

vld $vr0, S1, 0x00
vld $vr1, S2, 0x00
vld $vr2, S3, 0x00
vld $vr3, S4, 0x00

vst $vr0, S9, 0x00
vst $vr1, S9, 0x10
vst $vr2, S9, 0x20
vst $vr3, S9, 0x30

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d S3, S3, 0x10
addi.d S4, S4, 0x10
addi.d S9, S9, 0x40

.L_JN2: /* if(n&1) */
andi I, N, 0x01
beq ZERO, I, .L_J0

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fld.s F2, S2, 0x00
fld.s F3, S2, 0x04

fld.s F4, S3, 0x00
fld.s F5, S3, 0x04

fld.s F6, S4, 0x00
fld.s F7, S4, 0x04

fst.s F0, S10, 0x00
fst.s F1, S10, 0x04
fst.s F2, S10, 0x08
fst.s F3, S10, 0x0c
fst.s F4, S10, 0x10
fst.s F5, S10, 0x14
fst.s F6, S10, 0x18
fst.s F7, S10, 0x1c

addi.d S10, S10, 0x20

.L_J0:
addi.d J, J, -1
blt ZERO, J, .L_J1

.L_M1: /* if(m&2) */
andi I, M, 0x02
beq ZERO, I, .L_M2

move S1, TS //aoffset1
add.d S2, S1, TL

slli.d T0, TL, 0x01
add.d TS, TS, T0

move S8, TD //boffset1
addi.d TD, TD, 0x40

srai.d I, N, 0x02
beq ZERO, I, .L_M1N1

.L_M1I1: /* if(i>0) */
xvld U0, S1, 0x00
xvld U1, S2, 0x00

xvst U0, S8, 0x00
xvst U1, S8, 0x20

addi.d S1, S1, 0x20
addi.d S2, S2, 0x20
slli.d T0, M, 0x05
add.d S8, S8, T0

addi.d I, I, -1
blt ZERO, I, .L_M1I1

.L_M1N1: /* if(n&2) */
andi I, N, 0x02
beq ZERO, I, .L_M1N2

vld $vr0, S1, 0x00
vld $vr1, S2, 0x00

vst $vr0, S9, 0x00
vst $vr1, S9, 0x10

addi.d S1, S1, 0x10
addi.d S2, S2, 0x10
addi.d S9, S9, 0x20

.L_M1N2: /* if(n&1) */
andi I, N, 0x01
beq ZERO, I, .L_M2

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fld.s F2, S2, 0x00
fld.s F3, S2, 0x04

fst.s F0, S10, 0x00
fst.s F1, S10, 0x04
fst.s F2, S10, 0x08
fst.s F3, S10, 0x0c

addi.d S10, S10, 0x10

.L_M2: /* if(m&1) */
andi I, M, 0x01
beq ZERO, I, .L_M0

move S1, TS //aoffset1
move S8, TD //boffset1

srai.d I, N, 0x02
beq ZERO, I, .L_M2N1

.L_M2I1: /* if(i>0) */
xvld U0, S1, 0x00

xvst U0, S8, 0x00

addi.d S1, S1, 0x20
slli.d T0, M, 0x05
add.d S8, S8, T0

addi.d I, I, -1
blt ZERO, I, .L_M2I1

.L_M2N1: /* if(n&2) */
andi I, N, 0x02
beq ZERO, I, .L_M2N2

vld $vr0, S1, 0x00

vst $vr0, S9, 0x00

addi.d S1, S1, 0x10

.L_M2N2: /* if(n&1) */
andi I, N, 0x01
beq ZERO, I, .L_M0

fld.s F0, S1, 0x00
fld.s F1, S1, 0x04

fst.s F0, S10, 0x00
fst.s F1, S10, 0x04

.L_M0:
LDARG $r23, $sp, 0
addi.d $sp, $sp, 8
jirl $r0, $r1, 0x00

EPILOGUE

+ 8
- 4
param.h View File

@@ -2845,21 +2845,25 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DGEMM_DEFAULT_UNROLL_M 2
#define SGEMM_DEFAULT_UNROLL_N 8
#define SGEMM_DEFAULT_UNROLL_M 2
#define CGEMM_DEFAULT_UNROLL_N 4
#define CGEMM_DEFAULT_UNROLL_M 1
#define ZGEMM_DEFAULT_UNROLL_N 4
#define ZGEMM_DEFAULT_UNROLL_M 1
#else
#define DGEMM_DEFAULT_UNROLL_N 4
#define DGEMM_DEFAULT_UNROLL_M 16
#define SGEMM_DEFAULT_UNROLL_N 8
#define SGEMM_DEFAULT_UNROLL_M 16
#define CGEMM_DEFAULT_UNROLL_N 4
#define CGEMM_DEFAULT_UNROLL_M 16
#define ZGEMM_DEFAULT_UNROLL_N 4
#define ZGEMM_DEFAULT_UNROLL_M 8
#endif

#define QGEMM_DEFAULT_UNROLL_N 2
#define CGEMM_DEFAULT_UNROLL_N 2
#define ZGEMM_DEFAULT_UNROLL_N 4
#define XGEMM_DEFAULT_UNROLL_N 1

#define QGEMM_DEFAULT_UNROLL_M 2
#define CGEMM_DEFAULT_UNROLL_M 2
#define ZGEMM_DEFAULT_UNROLL_M 8
#define XGEMM_DEFAULT_UNROLL_M 1

#define SGEMM_DEFAULT_P 256


Loading…
Cancel
Save