📄 ztrsm_kernel_lt_2x2_core2.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 OLD_M %rdi#define OLD_N %rsi#define M %r13#define N %r14#define K %rdx#define A %rcx#define B %r8#define C %r9#define LDC %r10 #define I %r11#define AO %rdi#define BO %rsi#define CO1 %rbx#define CO2 %rbp#define KK %r12#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 48 + STACKSIZE(%rsp)#define OLD_B 56 + STACKSIZE(%rsp)#define OLD_C 64 + STACKSIZE(%rsp)#define OLD_LDC 72 + STACKSIZE(%rsp)#define OLD_OFFSET 80 + STACKSIZE(%rsp)#endif#define POSINV 0(%rsp)#define J 16(%rsp)#define OFFSET 24(%rsp)#define KKK 32(%rsp)#define AORIG 40(%rsp)#define BORIG 48(%rsp)#define BUFFER 128(%rsp) #define PREFETCH_R (8 * 4 + 0)#define PREFETCH_W (PREFETCH_R)#define PREFETCHSIZE (8 * 17 + 2)#define PREFETCH prefetcht0#ifndef CONJ#define NN#else#if defined(LN) || defined(LT)#define CN#else#define NC#endif#endif#define ADD1 addpd#define ADD2 addpd PROLOGUE PROFCODE subq $STACKSIZE, %rsp 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, OLD_M movq ARG2, OLD_N movq ARG3, K movq OLD_A, A movq OLD_B, B movq OLD_C, C#endif movq OLD_LDC, LDC movq OLD_OFFSET, KK movq %rsp, %r15 # 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 movq KK, OFFSET movq OLD_M, M movq OLD_N, N subq $-16 * SIZE, A subq $-16 * SIZE, B pcmpeqb %xmm15, %xmm15 psllq $63, %xmm15 # Generate mask pxor %xmm2, %xmm2 movlpd %xmm2, 0 + POSINV movlpd %xmm15, 8 + POSINV salq $ZBASE_SHIFT, LDC#ifdef LN movq M, %rax salq $ZBASE_SHIFT, %rax addq %rax, C imulq K, %rax addq %rax, A#endif#ifdef RT movq N, %rax salq $ZBASE_SHIFT, %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 movq N, J sarq $1, J # j = (n >> 2) jle .L100 ALIGN_4.L01:#ifdef LN movq OFFSET, %rax addq M, %rax movq %rax, KK#endif leaq 16 * SIZE + BUFFER, BO #ifdef RT movq K, %rax salq $1 + ZBASE_SHIFT, %rax subq %rax, B#endif#if defined(LN) || defined(RT) movq KK, %rax movq B, BORIG salq $ZBASE_SHIFT, %rax leaq (B, %rax, 2), B leaq (BO, %rax, 4), BO#endif #if defined(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 $2, %rax jle .L03 addq %rax, %rax ALIGN_4 .L02: prefetcht0 (PREFETCH_R + 0) * SIZE(B) movddup -16 * SIZE(B), %xmm8 movddup -15 * SIZE(B), %xmm9 movddup -14 * SIZE(B), %xmm10 movddup -13 * SIZE(B), %xmm11 movddup -12 * SIZE(B), %xmm12 movddup -11 * SIZE(B), %xmm13 movddup -10 * SIZE(B), %xmm14 movddup -9 * SIZE(B), %xmm15 prefetcht0 (PREFETCH_W + 0) * SIZE(BO) movapd %xmm8, -16 * SIZE(BO) movapd %xmm9, -14 * SIZE(BO) movapd %xmm10, -12 * SIZE(BO) movapd %xmm11, -10 * SIZE(BO) prefetcht0 (PREFETCH_W + 8) * SIZE(BO) movapd %xmm12, -8 * SIZE(BO) movapd %xmm13, -6 * SIZE(BO) movapd %xmm14, -4 * SIZE(BO) movapd %xmm15, -2 * SIZE(BO) addq $ 8 * SIZE, B subq $-16 * SIZE, BO decq %rax jne .L02 ALIGN_4.L03:#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif andq $3, %rax BRANCH jle .L05 ALIGN_4.L04: movddup -16 * SIZE(B), %xmm8 movddup -15 * SIZE(B), %xmm9 movddup -14 * SIZE(B), %xmm10 movddup -13 * SIZE(B), %xmm11 movapd %xmm8, -16 * SIZE(BO) movapd %xmm9, -14 * SIZE(BO) movapd %xmm10, -12 * SIZE(BO) movapd %xmm11, -10 * SIZE(BO) addq $ 4 * SIZE, B addq $ 8 * SIZE, BO decq %rax jne .L04 ALIGN_4 .L05:#if defined(LT) || defined(RN) movq A, AO#else movq A, AORIG#endif#ifdef RT leaq (, LDC, 2), %rax subq %rax, C#endif movq C, CO1 leaq (C, LDC, 1), CO2#ifndef RT leaq (C, LDC, 2), C#endif movq M, I sarq $1, I # i = (m >> 2) jle .L30 ALIGN_4.L10:#ifdef LN movq K, %rax salq $1 + ZBASE_SHIFT, %rax subq %rax, AORIG#endif#if defined(LN) || defined(RT) movq KK, %rax movq AORIG, AO salq $ZBASE_SHIFT, %rax leaq (AO, %rax, 2), AO#endif leaq 16 * SIZE + BUFFER, BO#if defined(LN) || defined(RT) movq KK, %rax salq $1 + ZBASE_SHIFT, %rax leaq (BO, %rax, 2), BO#endif #ifdef LN pxor %xmm8, %xmm8 prefetcht1 -3 * SIZE(CO1) pxor %xmm9, %xmm9 pxor %xmm10, %xmm10 prefetcht1 -3 * SIZE(CO2) pxor %xmm11, %xmm11#else pxor %xmm8, %xmm8 prefetcht1 3 * SIZE(CO1) pxor %xmm9, %xmm9 pxor %xmm10, %xmm10 prefetcht1 3 * SIZE(CO2) pxor %xmm11, %xmm11#endif pxor %xmm12, %xmm12 pxor %xmm13, %xmm13 pxor %xmm14, %xmm14 pxor %xmm15, %xmm15 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif sarq $2, %rax jle,pn .L15 ALIGN_4.L12: PREFETCH (PREFETCHSIZE + 0) * SIZE(AO) movapd -16 * SIZE(AO), %xmm0 ADD1 %xmm2, %xmm10 movapd -16 * SIZE(BO), %xmm2 ADD1 %xmm3, %xmm14 movapd %xmm2, %xmm3 movapd -14 * SIZE(AO), %xmm1 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm11 movapd -14 * SIZE(BO), %xmm4 ADD2 %xmm5, %xmm15 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 ADD1 %xmm2, %xmm8 movapd -12 * SIZE(BO), %xmm2 ADD1 %xmm3, %xmm12 movapd %xmm2, %xmm3 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm9 movapd -10 * SIZE(BO), %xmm4 ADD2 %xmm5, %xmm13 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 movapd -12 * SIZE(AO), %xmm0 ADD1 %xmm2, %xmm10 movapd -8 * SIZE(BO), %xmm2 ADD1 %xmm3, %xmm14 movapd %xmm2, %xmm3 movapd -10 * SIZE(AO), %xmm1 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm11 ADD2 %xmm5, %xmm15 movapd -6 * SIZE(BO), %xmm4 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 ADD1 %xmm2, %xmm8 ADD1 %xmm3, %xmm12 movapd -4 * SIZE(BO), %xmm2 movapd %xmm2, %xmm3 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm9 ADD2 %xmm5, %xmm13 movapd -2 * SIZE(BO), %xmm4 movapd %xmm4, %xmm5 PREFETCH (PREFETCHSIZE + 8) * SIZE(AO) mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 movapd -8 * SIZE(AO), %xmm0 ADD1 %xmm2, %xmm10 movapd 0 * SIZE(BO), %xmm2 ADD1 %xmm3, %xmm14 movapd %xmm2, %xmm3 movapd -6 * SIZE(AO), %xmm1 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm11 movapd 2 * SIZE(BO), %xmm4 ADD2 %xmm5, %xmm15 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 ADD1 %xmm2, %xmm8 movapd 4 * SIZE(BO), %xmm2 ADD1 %xmm3, %xmm12 movapd %xmm2, %xmm3 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm9 movapd 6 * SIZE(BO), %xmm4 ADD2 %xmm5, %xmm13 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 movapd -4 * SIZE(AO), %xmm0 ADD1 %xmm2, %xmm10 ADD1 %xmm3, %xmm14 movapd 8 * SIZE(BO), %xmm2 movapd %xmm2, %xmm3 mulpd %xmm0, %xmm2 movapd -2 * SIZE(AO), %xmm1 mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm11 movapd 10 * SIZE(BO), %xmm4 ADD2 %xmm5, %xmm15 subq $-32 * SIZE, BO movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 ADD1 %xmm2, %xmm8 ADD1 %xmm3, %xmm12 movapd -20 * SIZE(BO), %xmm2 movapd %xmm2, %xmm3 mulpd %xmm0, %xmm2 subq $-16 * SIZE, AO mulpd %xmm1, %xmm3 ADD2 %xmm4, %xmm9 ADD2 %xmm5, %xmm13 movapd -18 * SIZE(BO), %xmm4 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 subq $1, %rax BRANCH jg,pt .L12 ALIGN_4.L15:#if defined(LT) || defined(RN) movq KK, %rax#else movq K, %rax subq KK, %rax#endif movapd POSINV, %xmm7 andq $3, %rax BRANCH je,pt .L19 ALIGN_4.L16: ADD1 %xmm2, %xmm10 ADD1 %xmm3, %xmm14 ADD2 %xmm4, %xmm11 ADD2 %xmm5, %xmm15 movapd -16 * SIZE(BO), %xmm2 movapd %xmm2, %xmm3 movapd -14 * SIZE(BO), %xmm4 movapd %xmm4, %xmm5 movapd -16 * SIZE(AO), %xmm0 mulpd %xmm0, %xmm2 movapd -14 * SIZE(AO), %xmm1 mulpd %xmm1, %xmm3 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 ADD1 %xmm2, %xmm8 ADD1 %xmm3, %xmm12 ADD2 %xmm4, %xmm9 ADD2 %xmm5, %xmm13 movapd -12 * SIZE(BO), %xmm2 movapd %xmm2, %xmm3 movapd -10 * SIZE(BO), %xmm4 movapd %xmm4, %xmm5 mulpd %xmm0, %xmm2 mulpd %xmm1, %xmm3 mulpd %xmm0, %xmm4 mulpd %xmm1, %xmm5 addq $4 * SIZE, AO addq $8 * SIZE, BO subq $1, %rax jg,pt .L16 ALIGN_4.L19: ADD1 %xmm2, %xmm10 ADD1 %xmm3, %xmm14 ADD2 %xmm4, %xmm11 ADD2 %xmm5, %xmm15#if defined(LN) || defined(RT) movq KK, %rax#ifdef LN subq $2, %rax#else subq $2, %rax#endif movq AORIG, AO movq BORIG, B leaq 16 * SIZE + BUFFER, BO salq $ZBASE_SHIFT, %rax leaq (AO, %rax, 2), AO leaq (B, %rax, 2), B leaq (BO, %rax, 4), BO#endif SHUFPD_1 %xmm9, %xmm9 SHUFPD_1 %xmm11, %xmm11 SHUFPD_1 %xmm13, %xmm13 SHUFPD_1 %xmm15, %xmm15#if defined(NN) || defined(NT) || defined(TN) || defined(TT) || \ defined(NR) || defined(NC) || defined(TR) || defined(TC) xorpd %xmm7, %xmm9 xorpd %xmm7, %xmm11 xorpd %xmm7, %xmm13 xorpd %xmm7, %xmm15#else xorpd %xmm7, %xmm8 xorpd %xmm7, %xmm10 xorpd %xmm7, %xmm12 xorpd %xmm7, %xmm14#endif#if defined(NN) || defined(NT) || defined(TN) || defined(TT) || \ defined(RR) || defined(RC) || defined(CR) || defined(CC) subpd %xmm9, %xmm8 subpd %xmm11, %xmm10 subpd %xmm13, %xmm12 subpd %xmm15, %xmm14#else addpd %xmm9, %xmm8 addpd %xmm11, %xmm10 addpd %xmm13, %xmm12 addpd %xmm15, %xmm14#endif#if defined(LN) || defined(LT) movapd -16 * SIZE(B), %xmm9 movapd -14 * SIZE(B), %xmm11 movapd -12 * SIZE(B), %xmm13 movapd -10 * SIZE(B), %xmm15 subpd %xmm8, %xmm9 subpd %xmm10, %xmm11 subpd %xmm12, %xmm13 subpd %xmm14, %xmm15#else movapd -16 * SIZE(AO), %xmm9 movapd -14 * SIZE(AO), %xmm13 movapd -12 * SIZE(AO), %xmm11 movapd -10 * SIZE(AO), %xmm15 subpd %xmm8, %xmm9 subpd %xmm10, %xmm11 subpd %xmm12, %xmm13 subpd %xmm14, %xmm15#endif#ifndef CONJ SHUFPD_1 %xmm7, %xmm7#endif#ifdef LN movddup -10 * SIZE(AO), %xmm0 movddup -9 * SIZE(AO), %xmm1 movddup -12 * SIZE(AO), %xmm2 movddup -11 * SIZE(AO), %xmm3 movddup -16 * SIZE(AO), %xmm4 movddup -15 * SIZE(AO), %xmm5 pshufd $0x4e, %xmm13, %xmm12 pshufd $0x4e, %xmm15, %xmm14 xorpd %xmm7, %xmm12 xorpd %xmm7, %xmm14 mulpd %xmm0, %xmm13 mulpd %xmm1, %xmm12 mulpd %xmm0, %xmm15 mulpd %xmm1, %xmm14 addpd %xmm12, %xmm13 addpd %xmm14, %xmm15 movapd %xmm13, %xmm8 movapd %xmm15, %xmm10 pshufd $0x4e, %xmm13, %xmm12 pshufd $0x4e, %xmm15, %xmm14 xorpd %xmm7, %xmm12 xorpd %xmm7, %xmm14 mulpd %xmm2, %xmm8 mulpd %xmm2, %xmm10 mulpd %xmm3, %xmm12 mulpd %xmm3, %xmm14 subpd %xmm8, %xmm9 subpd %xmm10, %xmm11 subpd %xmm12, %xmm9 subpd %xmm14, %xmm11 pshufd $0x4e, %xmm9, %xmm8 pshufd $0x4e, %xmm11, %xmm10 xorpd %xmm7, %xmm8 xorpd %xmm7, %xmm10 mulpd %xmm4, %xmm9 mulpd %xmm5, %xmm8 mulpd %xmm4, %xmm11 mulpd %xmm5, %xmm10 addpd %xmm8, %xmm9 addpd %xmm10, %xmm11#endif#ifdef LT movddup -16 * SIZE(AO), %xmm0 movddup -15 * SIZE(AO), %xmm1 movddup -14 * SIZE(AO), %xmm2 movddup -13 * SIZE(AO), %xmm3 movddup -10 * SIZE(AO), %xmm4 movddup -9 * SIZE(AO), %xmm5 pshufd $0x4e, %xmm9, %xmm8 pshufd $0x4e, %xmm11, %xmm10 xorpd %xmm7, %xmm8 xorpd %xmm7, %xmm10 mulpd %xmm0, %xmm9 mulpd %xmm1, %xmm8 mulpd %xmm0, %xmm11 mulpd %xmm1, %xmm10 addpd %xmm8, %xmm9 addpd %xmm10, %xmm11 movapd %xmm9, %xmm8 movapd %xmm11, %xmm10 pshufd $0x4e, %xmm9, %xmm12 pshufd $0x4e, %xmm11, %xmm14
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -