📄 trsm_kernel_rt_8x4_sse.s
字号:
/*********************************************************************//* *//* Optimized BLAS libraries *//* By Kazushige Goto <kgoto@tacc.utexas.edu> *//* *//* Copyright (c) The University of Texas, 2005. All rights reserved. *//* UNIVERSITY EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES CONCERNING *//* THIS SOFTWARE AND DOCUMENTATION, INCLUDING ANY WARRANTIES OF *//* MERCHANTABILITY, FITNESS FOR ANY PARTICULAR PURPOSE, *//* NON-INFRINGEMENT AND WARRANTIES OF PERFORMANCE, AND ANY WARRANTY *//* THAT MIGHT OTHERWISE ARISE FROM COURSE OF DEALING OR USAGE OF *//* TRADE. NO WARRANTY IS EITHER EXPRESS OR IMPLIED WITH RESPECT TO *//* THE USE OF THE SOFTWARE OR DOCUMENTATION. *//* Under no circumstances shall University be liable for incidental, *//* special, indirect, direct or consequential damages or loss of *//* profits, interruption of business, or related expenses which may *//* arise from use of Software or Documentation, including but not *//* limited to those resulting from defects in Software and/or *//* Documentation, or loss or inaccuracy of data of any kind. *//*********************************************************************/#define ASSEMBLER#include "common.h" #define M %rdi#define N %rsi#define K %rdx#define A %rcx#define B %r8#define C %r9#define LDC %r10#define I %r11#define J %r12#define AO %r13#define BO %r14#define CO1 %r15#define CO2 %rbp #ifndef WINDOWS_ABI#define STACKSIZE 64#define OLD_LDC 8 + STACKSIZE(%rsp)#define OLD_OFFSET 16 + STACKSIZE(%rsp)#else#define STACKSIZE 256#define OLD_A 40 + STACKSIZE(%rsp)#define OLD_B 48 + STACKSIZE(%rsp)#define OLD_C 56 + STACKSIZE(%rsp)#define OLD_LDC 64 + STACKSIZE(%rsp)#define OLD_OFFSET 72 + STACKSIZE(%rsp)#endif#define ALPHA 0(%rsp)#define OFFSET 16(%rsp)#define KK 24(%rsp)#define KKK 32(%rsp)#define AORIG 40(%rsp)#define BORIG 48(%rsp)#define BUFFER 128(%rsp)#ifdef PENTIUM4#define PREFETCH prefetcht0#define PREFETCHW prefetcht0#endif#ifdef OPTERON#define PREFETCH prefetch#define PREFETCHW prefetchw#define movsd movlps#endif#ifdef GENERIC#define PREFETCH prefetcht0#define PREFETCHW prefetcht0#endif PROLOGUE PROFCODE subq $STACKSIZE, %rsp EMMS movq %rbx, 0(%rsp) movq %rbp, 8(%rsp) movq %r12, 16(%rsp) movq %r13, 24(%rsp) movq %r14, 32(%rsp) movq %r15, 40(%rsp)#ifdef WINDOWS_ABI movq %rdi, 48(%rsp) movq %rsi, 56(%rsp) movups %xmm6, 64(%rsp) movups %xmm7, 80(%rsp) movups %xmm8, 96(%rsp) movups %xmm9, 112(%rsp) movups %xmm10, 128(%rsp) movups %xmm11, 144(%rsp) movups %xmm12, 160(%rsp) movups %xmm13, 176(%rsp) movups %xmm14, 192(%rsp) movups %xmm15, 208(%rsp) movq ARG1, M movq ARG2, N movq ARG3, K movq OLD_A, A movq OLD_B, B movq OLD_C, C movq OLD_LDC, LDC movsd OLD_OFFSET, %xmm4 movaps %xmm3, %xmm0#else movq OLD_LDC, LDC movsd OLD_OFFSET, %xmm4#endif movq %rsp, %rbx # save old stack subq $128 + GEMM_Q * 64, %rsp andq $-4096, %rsp # align stack#ifdef WINDOWS_ABI#if GEMM_Q > 192 movq $0, 4096 * 3(%rsp)#endif#if GEMM_Q > 128 movq $0, 4096 * 2(%rsp)#endif#if GEMM_Q > 64 movq $0, 4096 * 1(%rsp)#endif movq $0, 4096 * 0(%rsp)#endif movsd %xmm4, OFFSET movsd %xmm4, KK leaq (, LDC, SIZE), LDC#ifdef LN leaq (, M, SIZE), %rax addq %rax, C imulq K, %rax addq %rax, A#endif#ifdef RT leaq (, N, SIZE), %rax imulq K, %rax addq %rax, B movq N, %rax imulq LDC, %rax addq %rax, C#endif#ifdef RN negq KK#endif #ifdef RT movq N, %rax subq OFFSET, %rax movq %rax, KK#endif testq $1, N je .L50#ifdef LN movq OFFSET, %rax addq M, %rax movq %rax, KK#endif leaq BUFFER, BO #ifdef RT movq K, %rax salq $BASE_SHIFT, %rax subq %rax, B#endif#if defined(LN) || defined(RT) movq KK, %rax movq B, BORIG salq $BASE_SHIFT, %rax leaq (B, %rax, 1), B leaq (BO, %rax, 4), BO#endif #ifdef LT movq OFFSET, %rax movq %rax, KK#endif#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif sarq $3, %rax jle .L103 ALIGN_4.L102: movlps 0 * SIZE(B), %xmm3 movhps 2 * SIZE(B), %xmm3 movlps 4 * SIZE(B), %xmm7 movhps 6 * SIZE(B), %xmm7 pshufd $0x00, %xmm3, %xmm0 pshufd $0x55, %xmm3, %xmm1 pshufd $0xaa, %xmm3, %xmm2 pshufd $0xff, %xmm3, %xmm3 pshufd $0x00, %xmm7, %xmm4 pshufd $0x55, %xmm7, %xmm5 pshufd $0xaa, %xmm7, %xmm6 pshufd $0xff, %xmm7, %xmm7 movaps %xmm0, 0 * SIZE(BO) movaps %xmm1, 4 * SIZE(BO) movaps %xmm2, 8 * SIZE(BO) movaps %xmm3, 12 * SIZE(BO) movaps %xmm4, 16 * SIZE(BO) movaps %xmm5, 20 * SIZE(BO) movaps %xmm6, 24 * SIZE(BO) movaps %xmm7, 28 * SIZE(BO) addq $ 8 * SIZE, B addq $32 * SIZE, BO decq %rax jne .L102 ALIGN_4.L103:#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif andq $7, %rax BRANCH jle .L110 ALIGN_4.L104: movss 0 * SIZE(B), %xmm3 pshufd $0x00, %xmm3, %xmm0 movaps %xmm0, 0 * SIZE(BO) addq $ 1 * SIZE, B addq $ 4 * SIZE, BO decq %rax jne .L104 ALIGN_4 .L110:#if defined(LT) || defined(RN) movq A, AO#else movq A, AORIG#endif#ifdef RT subq LDC, C#endif movq C, CO1 # coffset1 = c#ifndef RT addq LDC, C#endif movq M, I sarq $3, I # i = (m >> 3) jle .L120 ALIGN_4.L111:#ifdef LN movq K, %rax salq $3 + BASE_SHIFT, %rax subq %rax, AORIG#endif#if defined(LN) || defined(RT) movq KK, %rax movq AORIG, AO leaq (, %rax, SIZE), %rax leaq (AO, %rax, 8), AO#endif leaq BUFFER, BO#if defined(LN) || defined(RT) movq KK, %rax salq $BASE_SHIFT, %rax leaq (BO, %rax, 4), BO#endif movaps 0 * SIZE(AO), %xmm8 movaps 16 * SIZE(AO), %xmm10 movaps 32 * SIZE(AO), %xmm12 movaps 48 * SIZE(AO), %xmm14 movaps 0 * SIZE(BO), %xmm9 movaps 16 * SIZE(BO), %xmm11 movaps 32 * SIZE(BO), %xmm13 movaps 48 * SIZE(BO), %xmm15 pxor %xmm0, %xmm0 pxor %xmm1, %xmm1 PREFETCHW 4 * SIZE(CO1) pxor %xmm4, %xmm4 pxor %xmm5, %xmm5#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif sarq $3, %rax je .L115 ALIGN_4.L112: mulps %xmm9, %xmm8#if defined(OPTERON) && defined(HAVE_PREFETCH) PREFETCH (PREFETCHSIZE + 0) * SIZE(AO)#endif mulps 4 * SIZE(AO), %xmm9 addps %xmm8, %xmm0 movaps 8 * SIZE(AO), %xmm8 addps %xmm9, %xmm4 movaps 4 * SIZE(BO), %xmm9 mulps %xmm9, %xmm8 mulps 12 * SIZE(AO), %xmm9 addps %xmm8, %xmm0 movaps 64 * SIZE(AO), %xmm8 addps %xmm9, %xmm4 movaps 8 * SIZE(BO), %xmm9#if defined(OPTERON) && defined(HAVE_PREFETCH) PREFETCH (PREFETCHSIZE + 16) * SIZE(AO)#endif mulps %xmm9, %xmm10 mulps 20 * SIZE(AO), %xmm9 addps %xmm10, %xmm0 movaps 24 * SIZE(AO), %xmm10 addps %xmm9, %xmm4 movaps 12 * SIZE(BO), %xmm9 mulps %xmm9, %xmm10 mulps 28 * SIZE(AO), %xmm9 addps %xmm10, %xmm0 movaps 80 * SIZE(AO), %xmm10 addps %xmm9, %xmm4 movaps 32 * SIZE(BO), %xmm9#if defined(OPTERON) && defined(HAVE_PREFETCH) PREFETCH (PREFETCHSIZE + 32) * SIZE(AO)#endif mulps %xmm11, %xmm12 mulps 36 * SIZE(AO), %xmm11 addps %xmm12, %xmm0 movaps 40 * SIZE(AO), %xmm12 addps %xmm11, %xmm4 movaps 20 * SIZE(BO), %xmm11 mulps %xmm11, %xmm12 mulps 44 * SIZE(AO), %xmm11 addps %xmm12, %xmm0 movaps 96 * SIZE(AO), %xmm12 addps %xmm11, %xmm4 movaps 24 * SIZE(BO), %xmm11#if defined(OPTERON) && defined(HAVE_PREFETCH) PREFETCH (PREFETCHSIZE + 48) * SIZE(AO)#endif mulps %xmm11, %xmm14 mulps 52 * SIZE(AO), %xmm11 addps %xmm14, %xmm0 movaps 56 * SIZE(AO), %xmm14 addps %xmm11, %xmm4 movaps 28 * SIZE(BO), %xmm11 mulps %xmm11, %xmm14 mulps 60 * SIZE(AO), %xmm11 addps %xmm14, %xmm0 movaps 112 * SIZE(AO), %xmm14 addps %xmm11, %xmm4 movaps 48 * SIZE(BO), %xmm11 addq $64 * SIZE, AO addq $32 * SIZE, BO decq %rax jne .L112 ALIGN_4.L115:#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif andq $7, %rax # if (k & 1) BRANCH je .L118 ALIGN_4.L116: mulps %xmm9, %xmm8 mulps 4 * SIZE(AO), %xmm9 addps %xmm8, %xmm0 movaps 8 * SIZE(AO), %xmm8 addps %xmm9, %xmm4 movaps 4 * SIZE(BO), %xmm9 addq $8 * SIZE, AO # aoffset += 4 addq $4 * SIZE, BO # boffset1 += 8 decq %rax jg .L116 ALIGN_4.L118:#if defined(LN) || defined(RT) movq KK, %rax#ifdef LN subq $8, %rax#else subq $1, %rax#endif movq AORIG, AO movq BORIG, B leaq BUFFER, BO salq $BASE_SHIFT, %rax leaq (AO, %rax, 8), AO leaq (B, %rax, 1), B leaq (BO, %rax, 4), BO#endif#if defined(LN) || defined(LT) movaps %xmm0, %xmm8 unpcklps %xmm2, %xmm0 unpckhps %xmm2, %xmm8 movaps %xmm1, %xmm14 unpcklps %xmm3, %xmm1 unpckhps %xmm3, %xmm14 movaps %xmm0, %xmm2 unpcklps %xmm1, %xmm0 unpckhps %xmm1, %xmm2 movaps %xmm8, %xmm3 unpcklps %xmm14, %xmm8 unpckhps %xmm14, %xmm3 movaps %xmm4, %xmm9 unpcklps %xmm6, %xmm4 unpckhps %xmm6, %xmm9 movaps %xmm5, %xmm14 unpcklps %xmm7, %xmm5 unpckhps %xmm7, %xmm14 movaps %xmm4, %xmm6 unpcklps %xmm5, %xmm4 unpckhps %xmm5, %xmm6 movaps %xmm9, %xmm7 unpcklps %xmm14, %xmm9 unpckhps %xmm14, %xmm7 movss 0 * SIZE(B), %xmm1 movss 1 * SIZE(B), %xmm5 movss 2 * SIZE(B), %xmm10 movss 3 * SIZE(B), %xmm11 movss 4 * SIZE(B), %xmm12 movss 5 * SIZE(B), %xmm13 movss 6 * SIZE(B), %xmm14 movss 7 * SIZE(B), %xmm15 subss %xmm0, %xmm1 subss %xmm2, %xmm5 subss %xmm8, %xmm10 subss %xmm3, %xmm11 subss %xmm4, %xmm12 subss %xmm6, %xmm13 subss %xmm9, %xmm14 subss %xmm7, %xmm15#else movaps 0 * SIZE(AO), %xmm8 movaps 4 * SIZE(AO), %xmm9 subps %xmm0, %xmm8 subps %xmm4, %xmm9#endif#ifdef LN movaps 60 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm8, %xmm15 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm14 pshufd $0x55, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm13 pshufd $0x00, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm12 movaps 56 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm11 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm15, %xmm8 subss %xmm8, %xmm1 movaps 52 * SIZE(AO), %xmm6 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm8, %xmm14 pshufd $0x55, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm13 pshufd $0x00, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm12 movaps 48 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm11 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm14, %xmm8 subss %xmm8, %xmm1 movaps 44 * SIZE(AO), %xmm6 pshufd $0x55, %xmm6, %xmm8 mulss %xmm8, %xmm13 pshufd $0x00, %xmm6, %xmm8 mulss %xmm13, %xmm8 subss %xmm8, %xmm12 movaps 40 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm13, %xmm8 subss %xmm8, %xmm11 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm13, %xmm8 subss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm13, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm13, %xmm8 subss %xmm8, %xmm1 movaps 36 * SIZE(AO), %xmm6 pshufd $0x00, %xmm6, %xmm8 mulss %xmm8, %xmm12 movaps 32 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm12, %xmm8 subss %xmm8, %xmm11 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm12, %xmm8 subss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm12, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm12, %xmm8 subss %xmm8, %xmm1 movaps 24 * SIZE(AO), %xmm6 pshufd $0xff, %xmm6, %xmm8 mulss %xmm8, %xmm11 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm11, %xmm8 subss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm11, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm11, %xmm8 subss %xmm8, %xmm1 movaps 16 * SIZE(AO), %xmm6 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm8, %xmm10 pshufd $0x55, %xmm6, %xmm8 mulss %xmm10, %xmm8 subss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm10, %xmm8 subss %xmm8, %xmm1 movaps 8 * SIZE(AO), %xmm6 pshufd $0x55, %xmm6, %xmm8 mulss %xmm8, %xmm5 pshufd $0x00, %xmm6, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm1 movaps 0 * SIZE(AO), %xmm6 pshufd $0x00, %xmm6, %xmm8 mulss %xmm8, %xmm1#endif#ifdef LT movaps 0 * SIZE(AO), %xmm6 pshufd $0x00, %xmm6, %xmm8 mulss %xmm8, %xmm1 pshufd $0x55, %xmm6, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm5 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm10 pshufd $0xff, %xmm6, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm11 movaps 4 * SIZE(AO), %xmm7 pshufd $0x00, %xmm7, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm12 pshufd $0x55, %xmm7, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm13 pshufd $0xaa, %xmm7, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm14 pshufd $0xff, %xmm7, %xmm8 mulss %xmm1, %xmm8 subss %xmm8, %xmm15 movaps 8 * SIZE(AO), %xmm6 pshufd $0x55, %xmm6, %xmm8 mulss %xmm8, %xmm5 pshufd $0xaa, %xmm6, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm10 pshufd $0xff, %xmm6, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm11 movaps 12 * SIZE(AO), %xmm7 pshufd $0x00, %xmm7, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm12 pshufd $0x55, %xmm7, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm13 pshufd $0xaa, %xmm7, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm14 pshufd $0xff, %xmm7, %xmm8 mulss %xmm5, %xmm8 subss %xmm8, %xmm15 movaps 16 * SIZE(AO), %xmm6 pshufd $0xaa, %xmm6, %xmm8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -