|
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 dm1 = -1.;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#define TRSM_KERNEL TRSM_KERNEL_LT
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define TRSM_KERNEL TRSM_KERNEL_LC
|
|
kusano |
2b45e8 |
#undef SYRK_KERNEL_U
|
|
kusano |
2b45e8 |
#ifdef XDOUBLE
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL_U xherk_kernel_UC
|
|
kusano |
2b45e8 |
#elif defined(DOUBLE)
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL_U zherk_kernel_UC
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define SYRK_KERNEL_U cherk_kernel_UC
|
|
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 |
#if 0
|
|
kusano |
2b45e8 |
#define SHARED_ARRAY
|
|
kusano |
2b45e8 |
#define SA aa
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#undef SHARED_ARRAY
|
|
kusano |
2b45e8 |
#define SA sa
|
|
kusano |
2b45e8 |
#endif
|
|
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 info;
|
|
kusano |
2b45e8 |
BLASLONG bk, blocking;
|
|
kusano |
2b45e8 |
BLASLONG is, min_i;
|
|
kusano |
2b45e8 |
BLASLONG jjs, min_jj;
|
|
kusano |
2b45e8 |
BLASLONG range_N[2];
|
|
kusano |
2b45e8 |
BLASLONG j, js, min_j;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef SHARED_ARRAY
|
|
kusano |
2b45e8 |
FLOAT *aa;
|
|
kusano |
2b45e8 |
#endif
|
|
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 |
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 / 2) {
|
|
kusano |
2b45e8 |
info = POTF2_U(args, NULL, range_n, sa, sb, 0);
|
|
kusano |
2b45e8 |
return info;
|
|
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 = n - j;
|
|
kusano |
2b45e8 |
if (bk > blocking) bk = blocking;
|
|
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 |
info = CNAME(args, NULL, range_N, sa, sb, 0);
|
|
kusano |
2b45e8 |
if (info) return info + j;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (n - j - bk > 0) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
TRSM_IUNCOPY(bk, bk, a + (j + j * lda) * COMPSIZE, lda, 0, sb);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(js = j + bk; js < n; js += REAL_GEMM_R) {
|
|
kusano |
2b45e8 |
min_j = n - js;
|
|
kusano |
2b45e8 |
if (min_j > REAL_GEMM_R) min_j = REAL_GEMM_R;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for(jjs = js; jjs < js + min_j; jjs += GEMM_UNROLL_N){
|
|
kusano |
2b45e8 |
min_jj = min_j + js - jjs;
|
|
kusano |
2b45e8 |
if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
GEMM_ONCOPY(bk, min_jj, a + (j + jjs * lda) * COMPSIZE, lda, sb2 + bk * (jjs - js) * COMPSIZE);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (is = 0; is < bk; is += GEMM_P) {
|
|
kusano |
2b45e8 |
min_i = bk - is;
|
|
kusano |
2b45e8 |
if (min_i > GEMM_P) min_i = GEMM_P;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
TRSM_KERNEL (min_i, min_jj, bk, dm1,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
sb + bk * is * COMPSIZE,
|
|
kusano |
2b45e8 |
sb2 + bk * (jjs - js) * COMPSIZE,
|
|
kusano |
2b45e8 |
a + (j + is + jjs * lda) * COMPSIZE, lda, is);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (is = j + bk; is < js + min_j; is += min_i) {
|
|
kusano |
2b45e8 |
min_i = js + min_j - 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 |
#ifdef SHARED_ARRAY
|
|
kusano |
2b45e8 |
if ((is >= js) && (is + min_i <= js + min_j)) {
|
|
kusano |
2b45e8 |
aa = sb2 + bk * (is - js) * COMPSIZE;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + is * lda) * COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
aa = sa;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
GEMM_INCOPY(bk, min_i, a + (j + is * lda) * COMPSIZE, lda, sa);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SYRK_KERNEL_U(min_i, min_j, bk,
|
|
kusano |
2b45e8 |
dm1,
|
|
kusano |
2b45e8 |
SA, sb2,
|
|
kusano |
2b45e8 |
a + (is + js * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
is - js);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|