|
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 <stdlib.h></stdlib.h>
|
|
kusano |
2b45e8 |
#include "common.h"
|
|
kusano |
2b45e8 |
#include "symcopy.h"
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#ifndef TRANSA
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_N
|
|
kusano |
2b45e8 |
#undef TRANS
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_T
|
|
kusano |
2b45e8 |
#define TRANS
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#define MYDOT DOTU_K
|
|
kusano |
2b45e8 |
#define MYAXPY AXPYU_K
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#if TRANSA == 1
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_N
|
|
kusano |
2b45e8 |
#undef TRANS
|
|
kusano |
2b45e8 |
#define MYDOT DOTU_K
|
|
kusano |
2b45e8 |
#define MYAXPY AXPYU_K
|
|
kusano |
2b45e8 |
#elif TRANSA == 2
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_T
|
|
kusano |
2b45e8 |
#define TRANS
|
|
kusano |
2b45e8 |
#define MYDOT DOTU_K
|
|
kusano |
2b45e8 |
#define MYAXPY AXPYU_K
|
|
kusano |
2b45e8 |
#elif TRANSA == 3
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_R
|
|
kusano |
2b45e8 |
#undef TRANS
|
|
kusano |
2b45e8 |
#define MYDOT DOTC_K
|
|
kusano |
2b45e8 |
#define MYAXPY AXPYC_K
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#define MYGEMV GEMV_C
|
|
kusano |
2b45e8 |
#define TRANS
|
|
kusano |
2b45e8 |
#define MYDOT DOTC_K
|
|
kusano |
2b45e8 |
#define MYAXPY AXPYC_K
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
static int trmv_kernel(blas_arg_t *args, BLASLONG *range_m, BLASLONG *range_n, FLOAT *dummy1, FLOAT *buffer, BLASLONG pos){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
FLOAT *a, *x, *y;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG lda, incx;
|
|
kusano |
2b45e8 |
BLASLONG m_from, m_to;
|
|
kusano |
2b45e8 |
BLASLONG i, is, min_i;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef TRANS
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
FLOAT result;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
FLOAT _Complex result;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if defined(COMPLEX) && !defined(UNIT)
|
|
kusano |
2b45e8 |
FLOAT ar, ai, xr, xi;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
a = (FLOAT *)args -> a;
|
|
kusano |
2b45e8 |
x = (FLOAT *)args -> b;
|
|
kusano |
2b45e8 |
y = (FLOAT *)args -> c;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
lda = args -> lda;
|
|
kusano |
2b45e8 |
incx = args -> ldb;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
m_from = 0;
|
|
kusano |
2b45e8 |
m_to = args -> m;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (range_m) {
|
|
kusano |
2b45e8 |
m_from = *(range_m + 0);
|
|
kusano |
2b45e8 |
m_to = *(range_m + 1);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (incx != 1) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
COPY_K(m_to, x, incx, buffer, 1);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
COPY_K(args -> m - m_from, x + m_from * incx * COMPSIZE, incx, buffer + m_from * COMPSIZE, 1);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
x = buffer;
|
|
kusano |
2b45e8 |
buffer += ((COMPSIZE * args -> m + 1023) & ~1023);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
if (range_n) y += *range_n * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
SCAL_K(m_to, 0, 0, ZERO,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
y, 1, NULL, 0, NULL, 0);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
SCAL_K(args -> m - m_from, 0, 0, ZERO,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
y + m_from * COMPSIZE, 1, NULL, 0, NULL, 0);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
SCAL_K(m_to - m_from, 0, 0, ZERO,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
y + m_from * COMPSIZE, 1, NULL, 0, NULL, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (is = m_from; is < m_to; is += DTB_ENTRIES){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
min_i = MIN(m_to - is, DTB_ENTRIES);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
if (is > 0){
|
|
kusano |
2b45e8 |
MYGEMV(is, min_i, 0,
|
|
kusano |
2b45e8 |
ONE,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
a + is * lda * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
x + is * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
y, 1,
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
x, 1,
|
|
kusano |
2b45e8 |
y + is * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
buffer);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
for (i = is; i < is + min_i; i++) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
if (i - is > 0) {
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
MYAXPY(i - is, 0, 0,
|
|
kusano |
2b45e8 |
*(x + i * COMPSIZE + 0),
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
*(x + i * COMPSIZE + 1),
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
a + (is + i * lda) * COMPSIZE, 1, y + is * COMPSIZE, 1, NULL, 0);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
result = MYDOT(i - is, a + (is + i * lda) * COMPSIZE, 1, x + is * COMPSIZE, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += result;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += CREAL(result);
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 1) += CIMAG(result);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#ifdef UNIT
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE) += *(x + i * COMPSIZE);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE) += *(a + (i + i * lda) * COMPSIZE) * *(x + i * COMPSIZE);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#ifdef UNIT
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += *(x + i * COMPSIZE + 0);
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 1) += *(x + i * COMPSIZE + 1);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
ar = *(a + (i + i * lda) * COMPSIZE + 0);
|
|
kusano |
2b45e8 |
ai = *(a + (i + i * lda) * COMPSIZE + 1);
|
|
kusano |
2b45e8 |
xr = *(x + i * COMPSIZE + 0);
|
|
kusano |
2b45e8 |
xi = *(x + i * COMPSIZE + 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#if (TRANSA == 1) || (TRANSA == 2)
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += ar * xr - ai * xi;
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 1) += ar * xi + ai * xr;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += ar * xr + ai * xi;
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 1) += ar * xi - ai * xr;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef LOWER
|
|
kusano |
2b45e8 |
if (is + min_i > i + 1) {
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
MYAXPY(is + min_i - i - 1, 0, 0,
|
|
kusano |
2b45e8 |
*(x + i * COMPSIZE + 0),
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
*(x + i * COMPSIZE + 1),
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
a + (i + 1 + i * lda) * COMPSIZE, 1, y + (i + 1) * COMPSIZE, 1, NULL, 0);
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
result = MYDOT(is + min_i - i - 1, a + (i + 1 + i * lda) * COMPSIZE, 1, x + (i + 1) * COMPSIZE, 1);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += result;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 0) += CREAL(result);
|
|
kusano |
2b45e8 |
*(y + i * COMPSIZE + 1) += CIMAG(result);
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef LOWER
|
|
kusano |
2b45e8 |
if (args -> m > is + min_i){
|
|
kusano |
2b45e8 |
MYGEMV(args -> m - is - min_i, min_i, 0,
|
|
kusano |
2b45e8 |
ONE,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
a + (is + min_i + is * lda) * COMPSIZE, lda,
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
x + is * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
y + (is + min_i) * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
x + (is + min_i) * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
y + is * COMPSIZE, 1,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
buffer);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
int CNAME(BLASLONG m, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG incx, FLOAT *buffer, int nthreads){
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
int CNAME(BLASLONG m, FLOAT *a, BLASLONG lda, FLOAT *x, BLASLONG incx, FLOAT *buffer, int nthreads){
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
blas_arg_t args;
|
|
kusano |
2b45e8 |
blas_queue_t queue[MAX_CPU_NUMBER];
|
|
kusano |
2b45e8 |
BLASLONG range_m[MAX_CPU_NUMBER + 1];
|
|
kusano |
2b45e8 |
BLASLONG range_n[MAX_CPU_NUMBER];
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
BLASLONG width, i, num_cpu;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
double dnum;
|
|
kusano |
2b45e8 |
int mask = 7;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifdef SMP
|
|
kusano |
2b45e8 |
#ifndef COMPLEX
|
|
kusano |
2b45e8 |
#ifdef XDOUBLE
|
|
kusano |
2b45e8 |
int mode = BLAS_XDOUBLE | BLAS_REAL;
|
|
kusano |
2b45e8 |
#elif defined(DOUBLE)
|
|
kusano |
2b45e8 |
int mode = BLAS_DOUBLE | BLAS_REAL;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
int mode = BLAS_SINGLE | BLAS_REAL;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
#ifdef XDOUBLE
|
|
kusano |
2b45e8 |
int mode = BLAS_XDOUBLE | BLAS_COMPLEX;
|
|
kusano |
2b45e8 |
#elif defined(DOUBLE)
|
|
kusano |
2b45e8 |
int mode = BLAS_DOUBLE | BLAS_COMPLEX;
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
int mode = BLAS_SINGLE | BLAS_COMPLEX;
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
args.m = m;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
args.a = (void *)a;
|
|
kusano |
2b45e8 |
args.b = (void *)x;
|
|
kusano |
2b45e8 |
args.c = (void *)(buffer);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
args.lda = lda;
|
|
kusano |
2b45e8 |
args.ldb = incx;
|
|
kusano |
2b45e8 |
args.ldc = incx;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
dnum = (double)m * (double)m / (double)nthreads;
|
|
kusano |
2b45e8 |
num_cpu = 0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
range_m[MAX_CPU_NUMBER] = m;
|
|
kusano |
2b45e8 |
i = 0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
while (i < m){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (nthreads - num_cpu > 1) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
double di = (double)(m - i);
|
|
kusano |
2b45e8 |
if (di * di - dnum > 0) {
|
|
kusano |
2b45e8 |
width = ((BLASLONG)(-sqrt(di * di - dnum) + di) + mask) & ~mask;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
width = m - i;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (width < 16) width = 16;
|
|
kusano |
2b45e8 |
if (width > m - i) width = m - i;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
width = m - i;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
range_m[MAX_CPU_NUMBER - num_cpu - 1] = range_m[MAX_CPU_NUMBER - num_cpu] - width;
|
|
kusano |
2b45e8 |
range_n[num_cpu] = num_cpu * (((m + 15) & ~15) + 16);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
queue[num_cpu].mode = mode;
|
|
kusano |
2b45e8 |
queue[num_cpu].routine = trmv_kernel;
|
|
kusano |
2b45e8 |
queue[num_cpu].args = &args;
|
|
kusano |
2b45e8 |
queue[num_cpu].range_m = &range_m[MAX_CPU_NUMBER - num_cpu - 1];
|
|
kusano |
2b45e8 |
queue[num_cpu].range_n = &range_n[num_cpu];
|
|
kusano |
2b45e8 |
queue[num_cpu].sa = NULL;
|
|
kusano |
2b45e8 |
queue[num_cpu].sb = NULL;
|
|
kusano |
2b45e8 |
queue[num_cpu].next = &queue[num_cpu + 1];
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
num_cpu ++;
|
|
kusano |
2b45e8 |
i += width;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
range_m[0] = 0;
|
|
kusano |
2b45e8 |
i = 0;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
while (i < m){
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (nthreads - num_cpu > 1) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
double di = (double)(m - i);
|
|
kusano |
2b45e8 |
if (di * di - dnum > 0) {
|
|
kusano |
2b45e8 |
width = ((BLASLONG)(-sqrt(di * di - dnum) + di) + mask) & ~mask;
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
width = m - i;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (width < 16) width = 16;
|
|
kusano |
2b45e8 |
if (width > m - i) width = m - i;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
} else {
|
|
kusano |
2b45e8 |
width = m - i;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
range_m[num_cpu + 1] = range_m[num_cpu] + width;
|
|
kusano |
2b45e8 |
range_n[num_cpu] = num_cpu * (((m + 15) & ~15) + 16);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
queue[num_cpu].mode = mode;
|
|
kusano |
2b45e8 |
queue[num_cpu].routine = trmv_kernel;
|
|
kusano |
2b45e8 |
queue[num_cpu].args = &args;
|
|
kusano |
2b45e8 |
queue[num_cpu].range_m = &range_m[num_cpu];
|
|
kusano |
2b45e8 |
queue[num_cpu].range_n = &range_n[num_cpu];
|
|
kusano |
2b45e8 |
queue[num_cpu].sa = NULL;
|
|
kusano |
2b45e8 |
queue[num_cpu].sb = NULL;
|
|
kusano |
2b45e8 |
queue[num_cpu].next = &queue[num_cpu + 1];
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
num_cpu ++;
|
|
kusano |
2b45e8 |
i += width;
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
if (num_cpu) {
|
|
kusano |
2b45e8 |
queue[0].sa = NULL;
|
|
kusano |
2b45e8 |
queue[0].sb = buffer + num_cpu * (((m + 255) & ~255) + 16) * COMPSIZE;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
queue[num_cpu - 1].next = NULL;
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
exec_blas(num_cpu, queue);
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef TRANS
|
|
kusano |
2b45e8 |
for (i = 1; i < num_cpu; i ++) {
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#ifndef LOWER
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
AXPYU_K(range_m[MAX_CPU_NUMBER - i], 0, 0, ONE,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
buffer + range_n[i] * COMPSIZE, 1, buffer, 1, NULL, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#else
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
AXPYU_K(m - range_m[i], 0, 0, ONE,
|
|
kusano |
2b45e8 |
#ifdef COMPLEX
|
|
kusano |
2b45e8 |
ZERO,
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
buffer + (range_n[i] + range_m[i]) * COMPSIZE, 1, buffer + range_m[i] * COMPSIZE, 1, NULL, 0);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
}
|
|
kusano |
2b45e8 |
#endif
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
COPY_K(m, buffer, 1, x, incx);
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
return 0;
|
|
kusano |
2b45e8 |
}
|