Blame thirdparty/openblas/xianyi-OpenBLAS-e6e87a2/driver/level3/level3_syrk.c

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) \
kusano 2b45e8
	KERNEL_FUNC(M, N, K, ALPHA[0], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y))
kusano 2b45e8
#else
kusano 2b45e8
#define KERNEL_OPERATION(M, N, K, ALPHA, SA, SB, C, LDC, X, Y) \
kusano 2b45e8
	KERNEL_FUNC(M, N, K, ALPHA[0], ALPHA[1], SA, SB, (FLOAT *)(C) + ((X) + (Y) * LDC) * COMPSIZE, LDC, (X) - (Y))
kusano 2b45e8
#endif
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 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 LDC
kusano 2b45e8
#define LDC	args -> ldc
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef TIMING
kusano 2b45e8
#define START_RPCC()		rpcc_counter = rpcc()
kusano 2b45e8
#define STOP_RPCC(COUNTER)	COUNTER  += rpcc() - rpcc_counter
kusano 2b45e8
#else
kusano 2b45e8
#define START_RPCC()
kusano 2b45e8
#define STOP_RPCC(COUNTER)
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, ldc;
kusano 2b45e8
  FLOAT *a, *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
  int shared = ((GEMM_UNROLL_M == GEMM_UNROLL_N) && !HAVE_EX_L2);
kusano 2b45e8
kusano 2b45e8
  FLOAT *aa;
kusano 2b45e8
kusano 2b45e8
#ifdef TIMING
kusano 2b45e8
  unsigned long long rpcc_counter;
kusano 2b45e8
  unsigned long long innercost  = 0;
kusano 2b45e8
  unsigned long long outercost  = 0;
kusano 2b45e8
  unsigned long long kernelcost = 0;
kusano 2b45e8
  double total;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  k = K;
kusano 2b45e8
kusano 2b45e8
  a = (FLOAT *)A;
kusano 2b45e8
  c = (FLOAT *)C;
kusano 2b45e8
kusano 2b45e8
  lda = LDA;
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(HERK)
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
#if defined(COMPLEX) && !defined(HERK)
kusano 2b45e8
      && (alpha[1] == ZERO)
kusano 2b45e8
#endif
kusano 2b45e8
      ) return 0;
kusano 2b45e8
kusano 2b45e8
#if 0
kusano 2b45e8
  fprintf(stderr, "m_from : %ld m_to : %ld n_from : %ld n_to : %ld\n",
kusano 2b45e8
	  m_from, m_to, n_from, n_to);
kusano 2b45e8
#endif
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_end >= js) {
kusano 2b45e8
kusano 2b45e8
	aa = sb + min_l * MAX(m_start - js, 0) * COMPSIZE;
kusano 2b45e8
	if (!shared) aa = sa;
kusano 2b45e8
	
kusano 2b45e8
	for(jjs = MAX(m_start, js); jjs < js + min_j; jjs += min_jj){
kusano 2b45e8
	  min_jj = js + min_j - jjs;
kusano 2b45e8
	  if (min_jj > GEMM_UNROLL_MN) min_jj = GEMM_UNROLL_MN;
kusano 2b45e8
	  
kusano 2b45e8
	  if (!shared && (jjs - MAX(m_start, js) < min_i)) {
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    ICOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sa + min_l * (jjs - js) * COMPSIZE);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(innercost);
kusano 2b45e8
	  }
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(outercost);
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_jj, min_l, alpha, aa, sb + min_l * (jjs - js)  * COMPSIZE, c, ldc, MAX(m_start, js), jjs);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
	for(is = MAX(m_start, js) + 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
	  aa = sb + min_l * (is - js)  * COMPSIZE;
kusano 2b45e8
	
kusano 2b45e8
	  if (!shared) {
kusano 2b45e8
	  
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(innercost);
kusano 2b45e8
kusano 2b45e8
	    aa = sa;
kusano 2b45e8
	  }
kusano 2b45e8
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_j, min_l, alpha, aa, sb, c, ldc, is, js);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	  
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
      }
kusano 2b45e8
kusano 2b45e8
      if (m_start < js) {
kusano 2b45e8
kusano 2b45e8
	if (m_end < js) {
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	
kusano 2b45e8
	  ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(innercost);
kusano 2b45e8
	  
kusano 2b45e8
	  for(jjs = js; 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
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(outercost);
kusano 2b45e8
	    
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_jj, min_l, alpha, sa, sb + min_l * (jjs - js)  * COMPSIZE, c, ldc, m_start, jjs);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
kusano 2b45e8
	  }
kusano 2b45e8
	} else {
kusano 2b45e8
	  min_i = 0;
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
	for(is = m_start + min_i; is < MIN(m_end, js); is += min_i){
kusano 2b45e8
kusano 2b45e8
	  min_i = MIN(m_end, js)- 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
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(innercost);
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_j, min_l, alpha, sa, sb, c, ldc, is, js);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	  
kusano 2b45e8
	}
kusano 2b45e8
      }
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
      if (m_start < js + min_j) {
kusano 2b45e8
	
kusano 2b45e8
	aa = sb + min_l * (m_start - js) * COMPSIZE;
kusano 2b45e8
	
kusano 2b45e8
	if (!shared) {
kusano 2b45e8
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(innercost);
kusano 2b45e8
	  
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
	START_RPCC();
kusano 2b45e8
	
kusano 2b45e8
	OCOPY_OPERATION(min_l, (shared? (min_i) : MIN(min_i, min_j + js - m_start)), a, lda, ls, m_start, aa);
kusano 2b45e8
	
kusano 2b45e8
	STOP_RPCC(outercost);
kusano 2b45e8
kusano 2b45e8
	START_RPCC();
kusano 2b45e8
	
kusano 2b45e8
	KERNEL_OPERATION(min_i, MIN(min_i, min_j + js - m_start), min_l, alpha, (shared? (aa) : (sa)), aa, c, ldc, m_start, m_start);
kusano 2b45e8
	
kusano 2b45e8
	STOP_RPCC(kernelcost);
kusano 2b45e8
kusano 2b45e8
	for(jjs = js; jjs < m_start; jjs += GEMM_UNROLL_N){
kusano 2b45e8
	  min_jj = m_start - jjs;
kusano 2b45e8
	  if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
kusano 2b45e8
	
kusano 2b45e8
	  STOP_RPCC(outercost);
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_jj, min_l, alpha, (shared? (aa) : (sa)), sb + min_l * (jjs - js)  * COMPSIZE, c, ldc, m_start, jjs);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	  
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
	  if (is  < js + min_j) {
kusano 2b45e8
	    
kusano 2b45e8
	    if (!shared) {
kusano 2b45e8
	      START_RPCC();
kusano 2b45e8
	      
kusano 2b45e8
	      ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
kusano 2b45e8
	      
kusano 2b45e8
	      STOP_RPCC(innercost);
kusano 2b45e8
	    }
kusano 2b45e8
kusano 2b45e8
	    aa = sb + min_l * (is - js) * COMPSIZE;
kusano 2b45e8
	  
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    OCOPY_OPERATION(min_l, (shared? (min_i) : MIN(min_i, min_j - is + js)), a, lda, ls, is, aa);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(outercost);
kusano 2b45e8
	    
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    KERNEL_OPERATION(min_i, MIN(min_i, min_j - is + js), min_l, alpha,  (shared? (aa) : (sa)), aa,  c, ldc, is, is);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(kernelcost);
kusano 2b45e8
	    
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    KERNEL_OPERATION(min_i, is - js, min_l, alpha, (shared? (aa) : (sa)), sb,  c, ldc, is, js);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(kernelcost);
kusano 2b45e8
	    
kusano 2b45e8
	  } else {
kusano 2b45e8
	    
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(innercost);
kusano 2b45e8
	    
kusano 2b45e8
	    START_RPCC();
kusano 2b45e8
	    
kusano 2b45e8
	    KERNEL_OPERATION(min_i, min_j, min_l, alpha, sa, sb,  c, ldc, is, js);
kusano 2b45e8
	    
kusano 2b45e8
	    STOP_RPCC(kernelcost);
kusano 2b45e8
	    
kusano 2b45e8
	  }
kusano 2b45e8
	  
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
      } else {
kusano 2b45e8
kusano 2b45e8
	START_RPCC();
kusano 2b45e8
	
kusano 2b45e8
	ICOPY_OPERATION(min_l, min_i, a, lda, ls, m_start, sa);
kusano 2b45e8
	
kusano 2b45e8
	STOP_RPCC(innercost);
kusano 2b45e8
	
kusano 2b45e8
	for(jjs = js; jjs < min_j; jjs += GEMM_UNROLL_N){
kusano 2b45e8
	  min_jj = min_j - jjs;
kusano 2b45e8
	  if (min_jj > GEMM_UNROLL_N) min_jj = GEMM_UNROLL_N;
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  OCOPY_OPERATION(min_l, min_jj, a, lda, ls, jjs, sb + min_l * (jjs - js) * COMPSIZE);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(outercost);
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_jj, min_l, alpha, sa, sb + min_l * (jjs - js)  * COMPSIZE, c, ldc, m_start, jjs);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	  
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
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  ICOPY_OPERATION(min_l, min_i, a, lda, ls, is, sa);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(innercost);
kusano 2b45e8
	  
kusano 2b45e8
	  START_RPCC();
kusano 2b45e8
	  
kusano 2b45e8
	  KERNEL_OPERATION(min_i, min_j, min_l, alpha, sa, sb,  c, ldc, is, js);
kusano 2b45e8
	  
kusano 2b45e8
	  STOP_RPCC(kernelcost);
kusano 2b45e8
	  
kusano 2b45e8
	}
kusano 2b45e8
      }
kusano 2b45e8
#endif
kusano 2b45e8
    }
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
#ifdef TIMING
kusano 2b45e8
  total = (double)outercost + (double)innercost + (double)kernelcost;
kusano 2b45e8
kusano 2b45e8
  printf( "Copy A : %5.2f Copy  B: %5.2f  Kernel : %5.2f  kernel Effi. : %5.2f Total Effi. : %5.2f\n",
kusano 2b45e8
	   innercost / total * 100., outercost / total * 100., kernelcost / total * 100.,
kusano 2b45e8
	  (double)(m_to - m_from) * (double)(n_to - n_from) * (double)k / (double)kernelcost * 100. * (double)COMPSIZE / (double)DNUMOPT,
kusano 2b45e8
	  (double)(m_to - m_from) * (double)(n_to - n_from) * (double)k / total * 100. * (double)COMPSIZE / (double)DNUMOPT);
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  return 0;
kusano 2b45e8
}