|
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 |
#include <stdio.h></stdio.h>
|
|
kusano |
2b45e8 |
#include "common.h"
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
static FLOAT dp1 = 1.;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#define TRMM_KERNEL TRMM_KERNEL_LN
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL SYRK_KERNEL_L
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define TRMM_KERNEL TRMM_KERNEL_LR
|
|
kusano |
2b45e8 |
#ifdef XDOUBLE
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL xherk_kernel_LC
|
|
kusano |
2b45e8 |
#elif defined(DOUBLE)
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL zherk_kernel_LC
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL cherk_kernel_LC
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if 0
|
|
kusano |
2b45e8 |
#undef GEMM_P
|
|
kusano |
2b45e8 |
#undef GEMM_Q
|
|
kusano |
2b45e8 |
#undef GEMM_R
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define GEMM_P 8
|
|
kusano |
2b45e8 |
#define GEMM_Q 20
|
|
kusano |
2b45e8 |
#define GEMM_R 64
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#define GEMM_PQ MAX(GEMM_P, GEMM_Q)
|
|
kusano |
2b45e8 |
#define REAL_GEMM_R (GEMM_R - GEMM_PQ)
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
blasint CNAME(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *sa, FLOAT *sb, BLASLONG myid) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG n, lda;
|
|
kusano |
2b45e8 |
FLOAT *a;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG j, bk, blocking;
|
|
kusano |
2b45e8 |
BLASLONG jjs, min_jj;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG is, ls, ks;
|
|
kusano |
2b45e8 |
BLASLONG min_i, min_l, min_k;
|
|
kusano |
2b45e8 |
BLASLONG range_N[2];
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
FLOAT *sb2 = (FLOAT *)((((BLASLONG)sb
|
|
kusano |
2b45e8 |
+ GEMM_PQ * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)
|
|
kusano |
2b45e8 |
+ GEMM_OFFSET_B);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if 0
|
|
kusano |
2b45e8 |
FLOAT *aa;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
n = args -> n;
|
|
kusano |
2b45e8 |
a = (FLOAT *)args -> a;
|
|
kusano |
2b45e8 |
lda = args -> lda;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (range_n) {
|
|
kusano |
2b45e8 |
n = range_n[1] - range_n[0];
|
|
kusano |
2b45e8 |
a += range_n[0] * (lda + 1) * COMPSIZE;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (n <= DTB_ENTRIES) {
|
|
kusano |
2b45e8 |
LAUU2_L(args, NULL, range_n, sa, sb, 0);
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
blocking = GEMM_Q;
|
|
kusano |
2b45e8 |
if (n <= 4 * GEMM_Q) blocking = (n + 3) / 4;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (j = 0; j < n; j += blocking) {
|
|
kusano |
2b45e8 |
bk = MIN(blocking, n - j);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (j > 0 ){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
TRMM_ILNCOPY(bk, bk, a + (j + j * lda) * COMPSIZE, lda, 0, 0, sb);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (ls = 0; ls < j; ls += REAL_GEMM_R) {
|
|
kusano |
2b45e8 |
min_l = j - ls;
|
|
kusano |
2b45e8 |
if (min_l > REAL_GEMM_R) min_l = REAL_GEMM_R;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if 0
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = j - ls;
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) min_i = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (ls + min_i >= ls + min_l) {
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + ls * lda)* COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
aa = sa;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
aa = sb2;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (jjs = ls; jjs < ls + min_l; jjs += GEMM_P){
|
|
kusano |
2b45e8 |
min_jj = ls + min_l - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_P) min_jj = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_ONCOPY(bk, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sb2 + (jjs - ls) * bk * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SYRK_KERNEL(min_i, min_jj, bk, dp1,
|
|
kusano |
2b45e8 |
aa,
|
|
kusano |
2b45e8 |
sb2 + (jjs - ls) * bk * COMPSIZE,
|
|
kusano |
2b45e8 |
a + (ls + jjs * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
ls - jjs);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = ls + min_i; is < j ; is += GEMM_P){
|
|
kusano |
2b45e8 |
min_i = j - is;
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) min_i = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + is * lda)* COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SYRK_KERNEL(min_i, min_l, bk, dp1,
|
|
kusano |
2b45e8 |
sa,
|
|
kusano |
2b45e8 |
sb2,
|
|
kusano |
2b45e8 |
a + (is + ls * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
is - ls);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (ks = 0; ks < bk; ks += GEMM_P) {
|
|
kusano |
2b45e8 |
min_k = bk - ks;
|
|
kusano |
2b45e8 |
if (min_k > GEMM_P) min_k = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
TRMM_KERNEL(min_k, min_l, bk, dp1,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
sb + ks * bk * COMPSIZE,
|
|
kusano |
2b45e8 |
sb2,
|
|
kusano |
2b45e8 |
a + (ks + j + ls * lda) * COMPSIZE, lda, ks);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = j - ls;
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) min_i = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + ls * lda)* COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (jjs = ls; jjs < ls + min_l; jjs += GEMM_P){
|
|
kusano |
2b45e8 |
min_jj = ls + min_l - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_P) min_jj = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_ONCOPY(bk, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sb2 + (jjs - ls) * bk * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SYRK_KERNEL(min_i, min_jj, bk, dp1,
|
|
kusano |
2b45e8 |
sa,
|
|
kusano |
2b45e8 |
sb2 + (jjs - ls) * bk * COMPSIZE,
|
|
kusano |
2b45e8 |
a + (ls + jjs * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
ls - jjs);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(is = ls + min_i; is < j ; is += GEMM_P){
|
|
kusano |
2b45e8 |
min_i = j - is;
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) min_i = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + is * lda)* COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SYRK_KERNEL(min_i, min_l, bk, dp1,
|
|
kusano |
2b45e8 |
sa,
|
|
kusano |
2b45e8 |
sb2,
|
|
kusano |
2b45e8 |
a + (is + ls * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
is - ls);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (ks = 0; ks < bk; ks += GEMM_P) {
|
|
kusano |
2b45e8 |
min_k = bk - ks;
|
|
kusano |
2b45e8 |
if (min_k > GEMM_P) min_k = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
TRMM_KERNEL(min_k, min_l, bk, dp1,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
sb + ks * bk * COMPSIZE,
|
|
kusano |
2b45e8 |
sb2,
|
|
kusano |
2b45e8 |
a + (ks + j + ls * lda) * COMPSIZE, lda, ks);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (!range_n) {
|
|
kusano |
2b45e8 |
range_N[0] = j;
|
|
kusano |
2b45e8 |
range_N[1] = j + bk;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
range_N[0] = range_n[0] + j;
|
|
kusano |
2b45e8 |
range_N[1] = range_n[0] + j + bk;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
CNAME(args, NULL, range_N, sa, sb, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|