⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gemm_kernel_1x4.s

📁 Optimized GotoBLAS libraries
💻 S
📖 第 1 页 / 共 2 页
字号:
/*********************************************************************//*                                                                   *//*             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 STACK	16#define ARGS	16	#define J	 0 + STACK(%esp)#define I	 4 + STACK(%esp)#define KK	 8 + STACK(%esp)#define KKK	12 + STACK(%esp)#define M	 4 + STACK + ARGS(%esp)#define N	 8 + STACK + ARGS(%esp)#define K	12 + STACK + ARGS(%esp)#define ALPHA	16 + STACK + ARGS(%esp)#ifdef DOUBLE#define STACK_A	24 + STACK + ARGS(%esp)#define STACK_B	28 + STACK + ARGS(%esp)#define C	32 + STACK + ARGS(%esp)#define STACK_LDC	36 + STACK + ARGS(%esp)#define OFFSET	40 + STACK + ARGS(%esp)#else#define STACK_A	20 + STACK + ARGS(%esp)#define STACK_B	24 + STACK + ARGS(%esp)#define C	28 + STACK + ARGS(%esp)#define STACK_LDC	32 + STACK + ARGS(%esp)#define OFFSET	36 + STACK + ARGS(%esp)#endif#define A	%edx#define B	%ecx#define B_ORIG	%ebx#define LDC	%ebp#define PREFETCHSIZE (5 + 8 * 10)/*  A hint of scheduling is received from following URL  http://www.netlib.org/atlas/atlas-comm/msg00260.html  Julian's code is still faster than mine, since Athlon has big  defect ... So this is a sample coding and please don't expect too  much.*/	PROLOGUE	subl	$ARGS, %esp	# Generate Stack Frame	pushl	%ebp	pushl	%edi	pushl	%esi	pushl	%ebx	PROFCODE#if defined(TRMMKERNEL) && !defined(LEFT)	movl	OFFSET, %eax	negl	%eax	movl	%eax, KK#endif	movl	STACK_B, B_ORIG	movl	STACK_LDC, LDC	leal	(, LDC, SIZE), LDC	subl	$-16 * SIZE, B_ORIG	subl	$-16 * SIZE, STACK_A	FLD	ALPHA	movl	M, %eax	testl	%eax, %eax	jle	.L999	movl	N, %eax	testl	%eax, %eax	jle	.L999	movl	K, %eax	testl	%eax, %eax	jle	.L999	movl	N,   %eax	sarl	$2,  %eax	movl	%eax, J	je	.L20	ALIGN_3.L11:#if defined(TRMMKERNEL) && defined(LEFT)	movl	OFFSET, %eax	movl	%eax, KK#endif		movl	STACK_A, A	movl	C, %edi#if !defined(TRMMKERNEL) || \	(defined(TRMMKERNEL) &&  defined(LEFT) &&  defined(TRANSA)) || \	(defined(TRMMKERNEL) && !defined(LEFT) && !defined(TRANSA))	movl	B_ORIG, B#else	movl	KK,   %eax	leal	(, %eax, SIZE), %eax	leal	(B_ORIG, %eax, 4), B#endif#ifndef TRMMKERNEL	movl	K,  %eax#elif (defined(LEFT) && !defined(TRANSA)) || (!defined(LEFT) && defined(TRANSA))	movl	K, %eax	subl	KK, %eax	movl	%eax, KKK	#else	movl	KK, %eax#ifdef LEFT	addl	$1, %eax#else	addl	$4, %eax#endif	movl	%eax, KKK#endif	sarl	$4, %eax	jle	.L13	ALIGN_4.L12:		movl	 -16 * SIZE(B), %esi	movl	  -8 * SIZE(B), %esi	movl	   0 * SIZE(B), %esi	movl	   8 * SIZE(B), %esi	movl	  16 * SIZE(B), %esi	movl	  24 * SIZE(B), %esi	movl	  32 * SIZE(B), %esi	movl	  40 * SIZE(B), %esi	subl	 $-64 * SIZE, B	decl	  %eax	jne	  .L12	ALIGN_3.L13:	movl	M, %esi	movl	%esi, I	ALIGN_3.L14:#if !defined(TRMMKERNEL) || \	(defined(TRMMKERNEL) &&  defined(LEFT) &&  defined(TRANSA)) || \	(defined(TRMMKERNEL) && !defined(LEFT) && !defined(TRANSA))	movl	B_ORIG, B#else	movl	KK,   %eax	leal	(, %eax, SIZE), %eax	leal	(A,      %eax, 1), A	leal	(B_ORIG, %eax, 4), B#endif	leal	(%edi, LDC, 2), %eax	fldz	fldz	fldz	fldz	FLD	  -8 * SIZE(A)	FLD	 -16 * SIZE(A)	FLD	 -16 * SIZE(B)	movl	$32 * SIZE, %esi#ifdef HAVE_3DNOW	prefetchw	1 * SIZE(%edi)	prefetchw	1 * SIZE(%edi, LDC)	prefetchw	1 * SIZE(%eax)	prefetchw	1 * SIZE(%eax, LDC)#elif defined(HAVE_SSE)	prefetcht0	1 * SIZE(%edi)	prefetcht0	1 * SIZE(%edi, LDC)	prefetcht0	1 * SIZE(%eax)	prefetcht0	1 * SIZE(%eax, LDC)#endif#ifndef TRMMKERNEL	movl	K,  %eax#elif (defined(LEFT) && !defined(TRANSA)) || (!defined(LEFT) && defined(TRANSA))	movl	K, %eax	subl	KK, %eax	movl	%eax, KKK	#else	movl	KK, %eax#ifdef LEFT	addl	$1, %eax#else	addl	$4, %eax#endif	movl	%eax, KKK#endif	sarl	$3, %eax 	je	.L16	ALIGN_3.L15:	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	-15 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	-14 * SIZE(B)#if L1_DATA_LINESIZE == 32#ifdef HAVE_3DNOW	PADDING prefetch	(PREFETCHSIZE - 4) * SIZE(A)#elif defined(HAVE_SSE)	PADDING prefetcht0	(PREFETCHSIZE - 4) * SIZE(A)#endif#endif	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	-13 * SIZE(B)	faddp	%st, %st(5)	FLD	-15 * SIZE(A)	FLD	-12 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	-11 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	-10 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	 -9 * SIZE(B)	faddp	%st, %st(5)	FLD	-14 * SIZE(A)	FLD	 -8 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	 -7 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	 -6 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	 -5 * SIZE(B)	faddp	%st, %st(5)	FLD	-13 * SIZE(A)	FLD	 -4 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	 -3 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	 -2 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	 -1 * SIZE(B)	faddp	%st, %st(5)	FLD	-12 * SIZE(A)	FLD	  0 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	  1 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	  2 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	  3 * SIZE(B)	faddp	%st, %st(5)	FLD	-11 * SIZE(A)	FLD	  4 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	  5 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	  6 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	  7 * SIZE(B)	faddp	%st, %st(5)	FLD	-10 * SIZE(A)	FLD	  8 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	  9 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	 10 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	 11 * SIZE(B)	faddp	%st, %st(5)	FLD	 -9 * SIZE(A)	FLD	 12 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(3)	PADDING	FLD	 13 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	PADDING	FLD	 14 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	PADDING	FMUL	 15 * SIZE(B)	faddp	%st, %st(5)	FLD	  0 * SIZE(A)#ifdef HAVE_3DNOW	PADDING prefetch	PREFETCHSIZE * SIZE(A)#elif defined(HAVE_SSE)	PADDING prefetcht0	PREFETCHSIZE * SIZE(A)#endif	addl	$8 * SIZE, A	fxch	%st(1)	addl	$32 * SIZE, B	FLD	-16 * SIZE(B)	decl	%eax	jne	.L15	ALIGN_4.L16:#ifndef TRMMKERNEL	movl	K, %eax#else	movl	KKK, %eax#endif	and	$7, %eax	je	.L19	ALIGN_4.L17:	fmul	%st(1), %st	faddp	%st, %st(3)	FLD	-15 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(4)	FLD	-14 * SIZE(B)	fmul	%st(1), %st	faddp	%st, %st(5)	FMUL	-13 * SIZE(B)	faddp	%st, %st(5)	FLD	-15 * SIZE(A)	FLD	-12 * SIZE(B)	addl	$1 * SIZE,A	addl	$4 * SIZE,B	decl	%eax	jne	 .L17	ALIGN_4.L19:	ffreep	%st	ffreep	%st	ffreep	%st	fxch	%st(4)	fmul	%st, %st(1)	fmul	%st, %st(2)	fmul	%st, %st(3)	fmul	%st, %st(4)	leal	(%edi, LDC, 2), %eax	fxch	%st(4)#ifndef TRMMKERNEL	FADD	(%edi)	FST	(%edi)	FADD	(%edi,LDC)	FST	(%edi,LDC)	FADD	(%eax)	FST	(%eax)	FADD	(%eax,LDC)	FST	(%eax,LDC)#else	FST	(%edi)	FST	(%edi,LDC)	FST	(%eax)	FST	(%eax,LDC)#endif#if (defined(TRMMKERNEL) &&  defined(LEFT) &&  defined(TRANSA)) || \    (defined(TRMMKERNEL) && !defined(LEFT) && !defined(TRANSA))	movl	K, %eax	subl	KKK, %eax	leal	(,%eax, SIZE), %eax	leal	(A, %eax, 1), A	leal	(B, %eax, 4), B#endif#if defined(TRMMKERNEL) && defined(LEFT)	addl	$1, KK#endif	addl	$1 * SIZE, %edi	decl	I

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -