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
#ifdef FUNCTION_PROFILE
kusano 2b45e8
#include "functable.h"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
#define ERROR_NAME "QGEMM "
kusano 2b45e8
#elif defined(DOUBLE)
kusano 2b45e8
#define ERROR_NAME "DGEMM "
kusano 2b45e8
#else
kusano 2b45e8
#define ERROR_NAME "SGEMM "
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
#ifndef GEMM3M
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
#define ERROR_NAME "XGEMM "
kusano 2b45e8
#elif defined(DOUBLE)
kusano 2b45e8
#define ERROR_NAME "ZGEMM "
kusano 2b45e8
#else
kusano 2b45e8
#define ERROR_NAME "CGEMM "
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
#ifdef XDOUBLE
kusano 2b45e8
#define ERROR_NAME "XGEMM3M "
kusano 2b45e8
#elif defined(DOUBLE)
kusano 2b45e8
#define ERROR_NAME "ZGEMM3M "
kusano 2b45e8
#else
kusano 2b45e8
#define ERROR_NAME "CGEMM3M "
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
static int (*gemm[])(blas_arg_t *, BLASLONG *, BLASLONG *, FLOAT *, FLOAT *, BLASLONG) = {
kusano 2b45e8
#ifndef GEMM3M
kusano 2b45e8
  GEMM_NN, GEMM_TN, GEMM_RN, GEMM_CN,
kusano 2b45e8
  GEMM_NT, GEMM_TT, GEMM_RT, GEMM_CT,
kusano 2b45e8
  GEMM_NR, GEMM_TR, GEMM_RR, GEMM_CR,
kusano 2b45e8
  GEMM_NC, GEMM_TC, GEMM_RC, GEMM_CC,
kusano 2b45e8
#if defined(SMP) && !defined(USE_SIMPLE_THREADED_LEVEL3)
kusano 2b45e8
  GEMM_THREAD_NN, GEMM_THREAD_TN, GEMM_THREAD_RN, GEMM_THREAD_CN,
kusano 2b45e8
  GEMM_THREAD_NT, GEMM_THREAD_TT, GEMM_THREAD_RT, GEMM_THREAD_CT,
kusano 2b45e8
  GEMM_THREAD_NR, GEMM_THREAD_TR, GEMM_THREAD_RR, GEMM_THREAD_CR,
kusano 2b45e8
  GEMM_THREAD_NC, GEMM_THREAD_TC, GEMM_THREAD_RC, GEMM_THREAD_CC,
kusano 2b45e8
#endif
kusano 2b45e8
#else
kusano 2b45e8
  GEMM3M_NN, GEMM3M_TN, GEMM3M_RN, GEMM3M_CN,
kusano 2b45e8
  GEMM3M_NT, GEMM3M_TT, GEMM3M_RT, GEMM3M_CT,
kusano 2b45e8
  GEMM3M_NR, GEMM3M_TR, GEMM3M_RR, GEMM3M_CR,
kusano 2b45e8
  GEMM3M_NC, GEMM3M_TC, GEMM3M_RC, GEMM3M_CC,
kusano 2b45e8
#if defined(SMP) && !defined(USE_SIMPLE_THREADED_LEVEL3)
kusano 2b45e8
  GEMM3M_THREAD_NN, GEMM3M_THREAD_TN, GEMM3M_THREAD_RN, GEMM3M_THREAD_CN,
kusano 2b45e8
  GEMM3M_THREAD_NT, GEMM3M_THREAD_TT, GEMM3M_THREAD_RT, GEMM3M_THREAD_CT,
kusano 2b45e8
  GEMM3M_THREAD_NR, GEMM3M_THREAD_TR, GEMM3M_THREAD_RR, GEMM3M_THREAD_CR,
kusano 2b45e8
  GEMM3M_THREAD_NC, GEMM3M_THREAD_TC, GEMM3M_THREAD_RC, GEMM3M_THREAD_CC,
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
};
kusano 2b45e8
kusano 2b45e8
#ifndef CBLAS
kusano 2b45e8
kusano 2b45e8
void NAME(char *TRANSA, char *TRANSB,
kusano 2b45e8
	  blasint *M, blasint *N, blasint *K,
kusano 2b45e8
	  FLOAT *alpha,
kusano 2b45e8
	  FLOAT *a, blasint *ldA,
kusano 2b45e8
	  FLOAT *b, blasint *ldB,
kusano 2b45e8
	  FLOAT *beta,
kusano 2b45e8
	  FLOAT *c, blasint *ldC){
kusano 2b45e8
  
kusano 2b45e8
  blas_arg_t args;
kusano 2b45e8
kusano 2b45e8
  int transa, transb, nrowa, nrowb;
kusano 2b45e8
  blasint info;
kusano 2b45e8
kusano 2b45e8
  char transA, transB;
kusano 2b45e8
  FLOAT *buffer;
kusano 2b45e8
  FLOAT *sa, *sb;
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
#if defined(SMP) && !defined(NO_AFFINITY) && !defined(USE_SIMPLE_THREADED_LEVEL3)
kusano 2b45e8
  int nodes;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  PRINT_DEBUG_NAME;
kusano 2b45e8
kusano 2b45e8
  args.m = *M;
kusano 2b45e8
  args.n = *N;
kusano 2b45e8
  args.k = *K;
kusano 2b45e8
kusano 2b45e8
  args.a = (void *)a;
kusano 2b45e8
  args.b = (void *)b;
kusano 2b45e8
  args.c = (void *)c;
kusano 2b45e8
kusano 2b45e8
  args.lda = *ldA;
kusano 2b45e8
  args.ldb = *ldB;
kusano 2b45e8
  args.ldc = *ldC;
kusano 2b45e8
kusano 2b45e8
  args.alpha = (void *)alpha;
kusano 2b45e8
  args.beta  = (void *)beta;
kusano 2b45e8
kusano 2b45e8
  transA = *TRANSA;
kusano 2b45e8
  transB = *TRANSB;
kusano 2b45e8
kusano 2b45e8
  TOUPPER(transA);
kusano 2b45e8
  TOUPPER(transB);
kusano 2b45e8
kusano 2b45e8
  transa = -1;
kusano 2b45e8
  transb = -1;
kusano 2b45e8
kusano 2b45e8
  if (transA == 'N') transa = 0;
kusano 2b45e8
  if (transA == 'T') transa = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
  if (transA == 'R') transa = 0;
kusano 2b45e8
  if (transA == 'C') transa = 1;
kusano 2b45e8
#else
kusano 2b45e8
  if (transA == 'R') transa = 2;
kusano 2b45e8
  if (transA == 'C') transa = 3;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  if (transB == 'N') transb = 0;
kusano 2b45e8
  if (transB == 'T') transb = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
  if (transB == 'R') transb = 0;
kusano 2b45e8
  if (transB == 'C') transb = 1;
kusano 2b45e8
#else
kusano 2b45e8
  if (transB == 'R') transb = 2;
kusano 2b45e8
  if (transB == 'C') transb = 3;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  nrowa = args.m;
kusano 2b45e8
  if (transa & 1) nrowa = args.k;
kusano 2b45e8
  nrowb = args.k;
kusano 2b45e8
  if (transb & 1) nrowb = args.n;
kusano 2b45e8
kusano 2b45e8
  info = 0;
kusano 2b45e8
kusano 2b45e8
  if (args.ldc < args.m) info = 13;
kusano 2b45e8
  if (args.ldb < nrowb)  info = 10;
kusano 2b45e8
  if (args.lda < nrowa)  info =  8; 
kusano 2b45e8
  if (args.k < 0)        info =  5;
kusano 2b45e8
  if (args.n < 0)        info =  4;
kusano 2b45e8
  if (args.m < 0)        info =  3;
kusano 2b45e8
  if (transb < 0)        info =  2;
kusano 2b45e8
  if (transa < 0)        info =  1;
kusano 2b45e8
kusano 2b45e8
  if (info){
kusano 2b45e8
    BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
kusano 2b45e8
    return;
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANSPOSE TransB,
kusano 2b45e8
	   blasint m, blasint n, blasint k,
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
	   FLOAT alpha,
kusano 2b45e8
#else
kusano 2b45e8
	   FLOAT *alpha,
kusano 2b45e8
#endif
kusano 2b45e8
	   FLOAT *a, blasint lda,
kusano 2b45e8
	   FLOAT *b, blasint ldb, 
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
	   FLOAT beta,
kusano 2b45e8
#else
kusano 2b45e8
	   FLOAT *beta,
kusano 2b45e8
#endif
kusano 2b45e8
	   FLOAT *c, blasint ldc) {
kusano 2b45e8
kusano 2b45e8
  blas_arg_t args;
kusano 2b45e8
  int transa, transb;
kusano 2b45e8
  blasint nrowa, nrowb, info;
kusano 2b45e8
kusano 2b45e8
  XFLOAT *buffer;
kusano 2b45e8
  XFLOAT *sa, *sb;
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
#if defined(SMP) && !defined(NO_AFFINITY) && !defined(USE_SIMPLE_THREADED_LEVEL3)
kusano 2b45e8
  int nodes;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  PRINT_DEBUG_CNAME;
kusano 2b45e8
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
  args.alpha = (void *)α
kusano 2b45e8
  args.beta  = (void *)β
kusano 2b45e8
#else
kusano 2b45e8
  args.alpha = (void *)alpha;
kusano 2b45e8
  args.beta  = (void *)beta;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  transa = -1;
kusano 2b45e8
  transb = -1;
kusano 2b45e8
  info   =  0;
kusano 2b45e8
kusano 2b45e8
  if (order == CblasColMajor) {
kusano 2b45e8
    args.m = m;
kusano 2b45e8
    args.n = n;
kusano 2b45e8
    args.k = k;
kusano 2b45e8
    
kusano 2b45e8
    args.a = (void *)a;
kusano 2b45e8
    args.b = (void *)b;
kusano 2b45e8
    args.c = (void *)c;
kusano 2b45e8
    
kusano 2b45e8
    args.lda = lda;
kusano 2b45e8
    args.ldb = ldb;
kusano 2b45e8
    args.ldc = ldc;
kusano 2b45e8
    
kusano 2b45e8
    if (TransA == CblasNoTrans)     transa = 0;
kusano 2b45e8
    if (TransA == CblasTrans)       transa = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
    if (TransA == CblasConjNoTrans) transa = 0;
kusano 2b45e8
    if (TransA == CblasConjTrans)   transa = 1;
kusano 2b45e8
#else
kusano 2b45e8
    if (TransA == CblasConjNoTrans) transa = 2;
kusano 2b45e8
    if (TransA == CblasConjTrans)   transa = 3;
kusano 2b45e8
#endif
kusano 2b45e8
    if (TransB == CblasNoTrans)     transb = 0;
kusano 2b45e8
    if (TransB == CblasTrans)       transb = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
    if (TransB == CblasConjNoTrans) transb = 0;
kusano 2b45e8
    if (TransB == CblasConjTrans)   transb = 1;
kusano 2b45e8
#else
kusano 2b45e8
    if (TransB == CblasConjNoTrans) transb = 2;
kusano 2b45e8
    if (TransB == CblasConjTrans)   transb = 3;
kusano 2b45e8
#endif
kusano 2b45e8
    
kusano 2b45e8
    nrowa = args.m;
kusano 2b45e8
    if (transa & 1) nrowa = args.k;
kusano 2b45e8
    nrowb = args.k;
kusano 2b45e8
    if (transb & 1) nrowb = args.n;
kusano 2b45e8
kusano 2b45e8
    info = -1;
kusano 2b45e8
kusano 2b45e8
    if (args.ldc < args.m) info = 13;
kusano 2b45e8
    if (args.ldb < nrowb)  info = 10;
kusano 2b45e8
    if (args.lda < nrowa)  info =  8; 
kusano 2b45e8
    if (args.k < 0)        info =  5;
kusano 2b45e8
    if (args.n < 0)        info =  4;
kusano 2b45e8
    if (args.m < 0)        info =  3;
kusano 2b45e8
    if (transb < 0)        info =  2;
kusano 2b45e8
    if (transa < 0)        info =  1;
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
  if (order == CblasRowMajor) {
kusano 2b45e8
    args.m = n;
kusano 2b45e8
    args.n = m;
kusano 2b45e8
    args.k = k;
kusano 2b45e8
    
kusano 2b45e8
    args.a = (void *)b;
kusano 2b45e8
    args.b = (void *)a;
kusano 2b45e8
    args.c = (void *)c;
kusano 2b45e8
    
kusano 2b45e8
    args.lda = ldb;
kusano 2b45e8
    args.ldb = lda;
kusano 2b45e8
    args.ldc = ldc;
kusano 2b45e8
kusano 2b45e8
    if (TransB == CblasNoTrans)     transa = 0;
kusano 2b45e8
    if (TransB == CblasTrans)       transa = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
    if (TransB == CblasConjNoTrans) transa = 0;
kusano 2b45e8
    if (TransB == CblasConjTrans)   transa = 1;
kusano 2b45e8
#else
kusano 2b45e8
    if (TransB == CblasConjNoTrans) transa = 2;
kusano 2b45e8
    if (TransB == CblasConjTrans)   transa = 3;
kusano 2b45e8
#endif
kusano 2b45e8
    if (TransA == CblasNoTrans)     transb = 0;
kusano 2b45e8
    if (TransA == CblasTrans)       transb = 1;
kusano 2b45e8
#ifndef COMPLEX
kusano 2b45e8
    if (TransA == CblasConjNoTrans) transb = 0;
kusano 2b45e8
    if (TransA == CblasConjTrans)   transb = 1;
kusano 2b45e8
#else
kusano 2b45e8
    if (TransA == CblasConjNoTrans) transb = 2;
kusano 2b45e8
    if (TransA == CblasConjTrans)   transb = 3;
kusano 2b45e8
#endif
kusano 2b45e8
    
kusano 2b45e8
    nrowa = args.m;
kusano 2b45e8
    if (transa & 1) nrowa = args.k;
kusano 2b45e8
    nrowb = args.k;
kusano 2b45e8
    if (transb & 1) nrowb = args.n;
kusano 2b45e8
kusano 2b45e8
    info = -1;
kusano 2b45e8
kusano 2b45e8
    if (args.ldc < args.m) info = 13;
kusano 2b45e8
    if (args.ldb < nrowb)  info = 10;
kusano 2b45e8
    if (args.lda < nrowa)  info =  8; 
kusano 2b45e8
    if (args.k < 0)        info =  5;
kusano 2b45e8
    if (args.n < 0)        info =  4;
kusano 2b45e8
    if (args.m < 0)        info =  3;
kusano 2b45e8
    if (transb < 0)        info =  2;
kusano 2b45e8
    if (transa < 0)        info =  1;
kusano 2b45e8
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
  if (info >= 0) {
kusano 2b45e8
    BLASFUNC(xerbla)(ERROR_NAME, &info, sizeof(ERROR_NAME));
kusano 2b45e8
    return;
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  if ((args.m == 0) || (args.n == 0)) return;
kusano 2b45e8
kusano 2b45e8
#if 0
kusano 2b45e8
  fprintf(stderr, "m = %4d  n = %d  k = %d  lda = %4d  ldb = %4d  ldc = %4d\n",
kusano 2b45e8
	 args.m, args.n, args.k, args.lda, args.ldb, args.ldc);
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  IDEBUG_START;
kusano 2b45e8
kusano 2b45e8
  FUNCTION_PROFILE_START();
kusano 2b45e8
kusano 2b45e8
  buffer = (XFLOAT *)blas_memory_alloc(0);
kusano 2b45e8
  
kusano 2b45e8
  sa = (XFLOAT *)((BLASLONG)buffer +GEMM_OFFSET_A);
kusano 2b45e8
  sb = (XFLOAT *)(((BLASLONG)sa + ((GEMM_P * GEMM_Q * COMPSIZE * SIZE + GEMM_ALIGN) & ~GEMM_ALIGN)) + GEMM_OFFSET_B);
kusano 2b45e8
  
kusano 2b45e8
#ifdef SMP
kusano 2b45e8
  mode |= (transa << BLAS_TRANSA_SHIFT);
kusano 2b45e8
  mode |= (transb << BLAS_TRANSB_SHIFT);
kusano 2b45e8
kusano 2b45e8
  args.common = NULL;
kusano 2b45e8
kusano 2b45e8
  if(args.m <= GEMM_MULTITHREAD_THRESHOLD || args.n <= GEMM_MULTITHREAD_THRESHOLD 
kusano 2b45e8
     || args.k <=GEMM_MULTITHREAD_THRESHOLD){
kusano 2b45e8
    args.nthreads = 1;
kusano 2b45e8
  }else{
kusano 2b45e8
    args.nthreads = num_cpu_avail(3);
kusano 2b45e8
  }
kusano 2b45e8
 if (args.nthreads == 1) {
kusano 2b45e8
#endif
kusano 2b45e8
    
kusano 2b45e8
    (gemm[(transb << 2) | transa])(&args, NULL, NULL, sa, sb, 0);
kusano 2b45e8
    
kusano 2b45e8
#ifdef SMP
kusano 2b45e8
    
kusano 2b45e8
  } else {
kusano 2b45e8
    
kusano 2b45e8
#ifndef USE_SIMPLE_THREADED_LEVEL3
kusano 2b45e8
kusano 2b45e8
#ifndef NO_AFFINITY
kusano 2b45e8
      nodes = get_num_nodes();
kusano 2b45e8
      
kusano 2b45e8
      if ((nodes > 1) && get_node_equal()) {
kusano 2b45e8
	
kusano 2b45e8
	args.nthreads /= nodes;
kusano 2b45e8
	
kusano 2b45e8
	gemm_thread_mn(mode, &args, NULL, NULL, gemm[16 | (transb << 2) | transa], sa, sb, nodes);
kusano 2b45e8
	
kusano 2b45e8
      } else {
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
	(gemm[16 | (transb << 2) | transa])(&args, NULL, NULL, sa, sb, 0);
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
	GEMM_THREAD(mode, &args, NULL, NULL, gemm[(transb << 2) | transa], sa, sb, args.nthreads);
kusano 2b45e8
	
kusano 2b45e8
#endif
kusano 2b45e8
	
kusano 2b45e8
#ifndef USE_SIMPLE_THREADED_LEVEL3
kusano 2b45e8
#ifndef NO_AFFINITY
kusano 2b45e8
      }
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
    
kusano 2b45e8
#endif
kusano 2b45e8
    
kusano 2b45e8
#ifdef SMP
kusano 2b45e8
  }
kusano 2b45e8
#endif
kusano 2b45e8
  
kusano 2b45e8
 blas_memory_free(buffer);
kusano 2b45e8
kusano 2b45e8
  FUNCTION_PROFILE_END(COMPSIZE * COMPSIZE, args.m * args.k + args.k * args.n + args.m * args.n, 2 * args.m * args.n * args.k);
kusano 2b45e8
kusano 2b45e8
  IDEBUG_END;
kusano 2b45e8
kusano 2b45e8
  return;
kusano 2b45e8
}