|
kusano |
2b45e8 |
/*********************************************************************/
|
|
kusano |
2b45e8 |
/* Copyright 2009, 2010 The University of Texas at Austin. */
|
|
kusano |
2b45e8 |
/* All rights reserved. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* Redistribution and use in source and binary forms, with or */
|
|
kusano |
2b45e8 |
/* without modification, are permitted provided that the following */
|
|
kusano |
2b45e8 |
/* conditions are met: */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* 1. Redistributions of source code must retain the above */
|
|
kusano |
2b45e8 |
/* copyright notice, this list of conditions and the following */
|
|
kusano |
2b45e8 |
/* disclaimer. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* 2. Redistributions in binary form must reproduce the above */
|
|
kusano |
2b45e8 |
/* copyright notice, this list of conditions and the following */
|
|
kusano |
2b45e8 |
/* disclaimer in the documentation and/or other materials */
|
|
kusano |
2b45e8 |
/* provided with the distribution. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
|
|
kusano |
2b45e8 |
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
|
|
kusano |
2b45e8 |
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
|
|
kusano |
2b45e8 |
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
|
|
kusano |
2b45e8 |
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
|
|
kusano |
2b45e8 |
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
|
|
kusano |
2b45e8 |
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
|
|
kusano |
2b45e8 |
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
|
|
kusano |
2b45e8 |
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
|
|
kusano |
2b45e8 |
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
|
|
kusano |
2b45e8 |
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
|
|
kusano |
2b45e8 |
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
|
|
kusano |
2b45e8 |
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
|
|
kusano |
2b45e8 |
/* POSSIBILITY OF SUCH DAMAGE. */
|
|
kusano |
2b45e8 |
/* */
|
|
kusano |
2b45e8 |
/* The views and conclusions contained in the software and */
|
|
kusano |
2b45e8 |
/* documentation are those of the authors and should not be */
|
|
kusano |
2b45e8 |
/* interpreted as representing official policies, either expressed */
|
|
kusano |
2b45e8 |
/* or implied, of The University of Texas at Austin. */
|
|
kusano |
2b45e8 |
/*********************************************************************/
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef KERNEL_OPERATION
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#define KERNEL_OPERATION(M, N, K, ALPHA, SA, SB, C, LDC, X, Y, FLAG) \
|
|
kusano |
2b45e8 |
KERNEL_FUNC(M, N, K, ALPHA[0], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y), FLAG)
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define KERNEL_OPERATION(M, N, K, ALPHA, SA, SB, C, LDC, X, Y, FLAG) \
|
|
kusano |
2b45e8 |
KERNEL_FUNC(M, N, K, ALPHA[0], ALPHA[1], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y), FLAG)
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef KERNEL_OPERATION_C
|
|
kusano |
2b45e8 |
#define KERNEL_OPERATION_C KERNEL_OPERATION
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef ICOPY_OPERATION
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
#define ICOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_ITCOPY(M, N, (FLOAT *)(A) + ((Y) + (X) * (LDA)) * COMPSIZE, LDA, BUFFER);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define ICOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_INCOPY(M, N, (FLOAT *)(A) + ((X) + (Y) * (LDA)) * COMPSIZE, LDA, BUFFER);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef OCOPY_OPERATION
|
|
kusano |
2b45e8 |
#ifdef TRANS
|
|
kusano |
2b45e8 |
#define OCOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_ONCOPY(M, N, (FLOAT *)(A) + ((X) + (Y) * (LDA)) * COMPSIZE, LDA, BUFFER);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define OCOPY_OPERATION(M, N, A, LDA, X, Y, BUFFER) GEMM_OTCOPY(M, N, (FLOAT *)(A) + ((Y) + (X) * (LDA)) * COMPSIZE, LDA, BUFFER);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef M
|
|
kusano |
2b45e8 |
#define M args -> n
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef N
|
|
kusano |
2b45e8 |
#define N args -> n
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef K
|
|
kusano |
2b45e8 |
#define K args -> k
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef A
|
|
kusano |
2b45e8 |
#define A args -> a
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef B
|
|
kusano |
2b45e8 |
#define B args -> b
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef C
|
|
kusano |
2b45e8 |
#define C args -> c
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LDA
|
|
kusano |
2b45e8 |
#define LDA args -> lda
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LDB
|
|
kusano |
2b45e8 |
#define LDB args -> ldb
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LDC
|
|
kusano |
2b45e8 |
#define LDC args -> ldc
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
int CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG dummy) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG m_from, m_to, n_from, n_to, k, lda, ldb, ldc;
|
|
kusano |
2b45e8 |
FLOAT *a, *b, *c, *alpha, *beta;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG ls, is, js;
|
|
kusano |
2b45e8 |
BLASLONG min_l, min_i, min_j;
|
|
kusano |
2b45e8 |
BLASLONG jjs, min_jj;
|
|
kusano |
2b45e8 |
BLASLONG m_start, m_end;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
FLOAT *aa;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
k = K;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
a = (FLOAT *)A;
|
|
kusano |
2b45e8 |
b = (FLOAT *)B;
|
|
kusano |
2b45e8 |
c = (FLOAT *)C;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
lda = LDA;
|
|
kusano |
2b45e8 |
ldb = LDB;
|
|
kusano |
2b45e8 |
ldc = LDC;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
alpha = (FLOAT *)args -> alpha;
|
|
kusano |
2b45e8 |
beta = (FLOAT *)args -> beta;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
m_from = 0;
|
|
kusano |
2b45e8 |
m_to = M;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (range_m) {
|
|
kusano |
2b45e8 |
m_from = *(((BLASLONG *)range_m) + 0);
|
|
kusano |
2b45e8 |
m_to = *(((BLASLONG *)range_m) + 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
n_from = 0;
|
|
kusano |
2b45e8 |
n_to = N;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (range_n) {
|
|
kusano |
2b45e8 |
n_from = *(((BLASLONG *)range_n) + 0);
|
|
kusano |
2b45e8 |
n_to = *(((BLASLONG *)range_n) + 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (beta) {
|
|
kusano |
2b45e8 |
#if !defined(COMPLEX) || defined(HER2K)
|
|
kusano |
2b45e8 |
if (beta[0] != ONE)
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
if ((beta[0] != ONE) || (beta[1] != ZERO))
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
syrk_beta(m_from, m_to, n_from, n_to, beta, c, ldc);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if ((k == 0) || (alpha == NULL)) return 0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if ((alpha[0] == ZERO)
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
&& (alpha[1] == ZERO)
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
) return 0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(js = n_from; js < n_to; js += GEMM_R){
|
|
kusano |
2b45e8 |
min_j = n_to - js;
|
|
kusano |
2b45e8 |
if (min_j > GEMM_R) min_j = GEMM_R;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
m_start = m_from;
|
|
kusano |
2b45e8 |
m_end = js + min_j;
|
|
kusano |
2b45e8 |
if (m_end > m_to) m_end = m_to;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
m_start = m_from;
|
|
kusano |
2b45e8 |
m_end = m_to;
|
|
kusano |
2b45e8 |
if (m_start < js) m_start = js;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(ls = 0; ls < k; ls += min_l){
|
|
kusano |
2b45e8 |
min_l = k - ls;
|
|
kusano |
2b45e8 |
if (min_l >= GEMM_Q * 2) {
|
|
kusano |
2b45e8 |
min_l = GEMM_Q;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_l > GEMM_Q) {
|
|
kusano |
2b45e8 |
min_l = (min_l + 1) / 2;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = m_end - m_start;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (m_start >= js) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (m_start - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, b, ldb, ls, m_start, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, min_i, min_l, alpha, sa, aa, c, ldc, m_start, m_start, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
jjs = m_start + min_i;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
jjs = js;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(; jjs < js + min_j; jjs += GEMM_UNROLL_MN){
|
|
kusano |
2b45e8 |
min_jj = min_j + js - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_jj, b, ldb, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, min_jj, min_l, alpha,
|
|
kusano |
2b45e8 |
sa, sb + min_l * (jjs - js) * COMPSIZE,
|
|
kusano |
2b45e8 |
c, ldc, m_start, jjs, 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = m_start + min_i; is < m_end; is += min_i){
|
|
kusano |
2b45e8 |
min_i = m_end - is;
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, min_j, min_l, alpha, sa, sb, c, ldc, is, js, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = m_end - m_start;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (m_start >= js) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (m_start - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, min_i, min_l, alpha, sa, aa, c, ldc, m_start, m_start, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
jjs = m_start + min_i;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
jjs = js;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(; jjs < js + min_j; jjs += GEMM_UNROLL_MN){
|
|
kusano |
2b45e8 |
min_jj = min_j + js - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, min_jj, min_l, alpha,
|
|
kusano |
2b45e8 |
sa, sb + min_l * (jjs - js) * COMPSIZE,
|
|
kusano |
2b45e8 |
c, ldc, m_start, jjs, 0);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = m_start + min_i; is < m_end; is += min_i){
|
|
kusano |
2b45e8 |
min_i = m_end - is;
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, min_j, min_l, alpha, sa, sb, c, ldc, is, js, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (m_start - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, b, ldb, ls, m_start, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, MIN(min_i, min_j + js - m_start), min_l, alpha,
|
|
kusano |
2b45e8 |
sa, aa, c, ldc, m_start, m_start, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(jjs = js; jjs < m_start; jjs += GEMM_UNROLL_MN){
|
|
kusano |
2b45e8 |
min_jj = m_start - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_jj, b, ldb, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, min_jj, min_l, alpha,
|
|
kusano |
2b45e8 |
sa, sb + min_l * (jjs - js) * COMPSIZE, c, ldc, m_start, jjs, 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = m_start + min_i; is < m_end; is += min_i){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = m_end - is;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (is - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (is < js + min_j) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, b, ldb, ls, is, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, MIN(min_i, min_j - is + js), min_l, alpha, sa, aa, c, ldc, is, is, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, is - js, min_l, alpha, sa, sb, c, ldc, is, js, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION(min_i, min_j, min_l, alpha, sa, sb, c, ldc, is, js, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = m_end - m_start;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (m_start - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, m_start, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, MIN(min_i, min_j + js - m_start), min_l, alpha,
|
|
kusano |
2b45e8 |
sa, aa, c, ldc, m_start, m_start, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(jjs = js; jjs < m_start; jjs += GEMM_UNROLL_MN){
|
|
kusano |
2b45e8 |
min_jj = m_start - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, min_jj, min_l, alpha,
|
|
kusano |
2b45e8 |
sa, sb + min_l * (jjs - js) * COMPSIZE, c, ldc, m_start, jjs, 0);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = m_start + min_i; is < m_end; is += min_i){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = m_end - is;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (min_i >= GEMM_P * 2) {
|
|
kusano |
2b45e8 |
min_i = GEMM_P;
|
|
kusano |
2b45e8 |
} else
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = (min_i / 2 + GEMM_UNROLL_MN - 1) & ~(GEMM_UNROLL_MN - 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
aa = sb + min_l * (is - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (is < js + min_j) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
OCOPY_OPERATION(min_l, min_i, a, lda, ls, is, aa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, MIN(min_i, min_j - is + js), min_l, alpha, sa, aa, c, ldc, is, is, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, is - js, min_l, alpha, sa, sb, c, ldc, is, js, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
ICOPY_OPERATION(min_l, min_i, b, ldb, ls, is, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
KERNEL_OPERATION_C(min_i, min_j, min_l, alpha, sa, sb, c, ldc, is, js, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|