fc.c

来自「基于Blas CLapck的.用过的人知道是干啥的」· C语言 代码 · 共 635 行 · 第 1/2 页

C
635
字号
/* *             Automatically Tuned Linear Algebra Software v3.8.0 *                    (C) Copyright 1997 R. Clint Whaley * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *   1. Redistributions of source code must retain the above copyright *      notice, this list of conditions and the following disclaimer. *   2. Redistributions in binary form must reproduce the above copyright *      notice, this list of conditions, and the following disclaimer in the *      documentation and/or other materials provided with the distribution. *   3. The name of the ATLAS group or the names of its contributers may *      not be used to endorse or promote products derived from this *      software without specific written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ATLAS GROUP OR ITS CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * */#include <stdio.h>#include <stdlib.h>#include <assert.h>#include <string.h>#define dumb_seed(iseed_) srand(iseed_)#ifndef RAND_MAX  /* rather dangerous non-ansi workaround */   #define RAND_MAX ((unsigned long)(1<<30))#endif#define dumb_rand() ( 0.5 - ((double)rand())/((double)RAND_MAX) )#if defined(PentiumCPS) && !defined(WALL)   #define WALL#endif#if defined(WALL)   #define time00 ATL_walltime#else   #define time00 ATL_cputime#endif#define SAFE_ALPHA -3#ifndef REPS   #define REPS 1500#endif#ifndef L2SIZE   #define L2SIZE 4194304#endif#define Mjoin(pre, nam) my_join(pre, nam)#define my_join(pre, nam) pre ## nam#define Mjoin(pre, nam) my_join(pre, nam)#define my_join(pre, nam) pre ## nam#define Mstr2(m) # m#define Mstr(m) Mstr2(m)#define Mmin(x, y) ( (x) > (y) ? (y) : (x) )#ifdef FULLMM   #define LANG 'M'#elif !defined(LangF77)   #define LANG 'C'#else   #define LANG 'F'#endif#if defined(sREAL)   #include "atlas_ssysinfo.h"   #define PRE 's'   #define pre s   #define TYPE float   #define SCALAR float   #define ATL_sizeof sizeof(TYPE)   #define TREAL   #define SHIFT   #define EPS 1.0e-7#elif defined(dREAL)   #include "atlas_dsysinfo.h"   #define PRE 'd'   #define pre d   #define TYPE double   #define SCALAR double   #define ATL_sizeof sizeof(TYPE)   #define TREAL   #define SHIFT   #define EPS 1.0e-16#elif defined (qREAL)   #include "atlas_qsysinfo.h"   #define PRE 'q'   #define pre q   #define TYPE long double   #define SCALAR long double   #define ATL_sizeof sizeof(TYPE)   #define TREAL   #define SHIFT#elif defined(sCPLX) || defined(cCPLX) || defined(cREAL)   #include "atlas_csysinfo.h"   #define PRE 'c'   #define pre c   #define TYPE float   #define ATL_sizeof (sizeof(TYPE)<<1)   #define SCALAR float *   #define TCPLX   #define SHIFT <<1   #define EPS 1.0e-7#else   #include "atlas_zsysinfo.h"   #define PRE 'z'   #define pre z   #define TYPE double   #define ATL_sizeof (sizeof(TYPE)<<1)   #define SCALAR double*   #define TCPLX   #define SHIFT <<1   #define EPS 1.0e-16#endif#ifdef TCPLX   #define bn1 bX  /* don't use bn1 case anymore */#endif#define Mabs(x) ( (x) < 0 ? (x) * -1 : (x) )#ifndef MB   #define MB NB#endif#ifndef KB   #define KB NB#endif#ifndef csA   #define csA 2#endif#ifndef csB   #define csB 2#endif#if defined(tranAt) || defined(tranAT)   #define TransA#elif defined(tranAc) || defined(tranAC)   #define ConjTransA#else   #define NoTransA#endif#if defined(tranBt) || defined(tranBT)   #define TransB#elif defined(tranBc) || defined(tranBC)   #define ConjTransB#else   #define NoTransB#endif#ifdef NoTransA   #define Ma MB   #define Na KB#else   #define Ma KB   #define Na MB#endif#ifdef NoTransB   #define Mb KB   #define Nb NB#else   #define Mb NB   #define Nb KB#endif#ifdef IJK   #undef IJK   #define LOOPO IJK#else   #undef JIK   #define  LOOPO JIK#endif#ifdef LDA2   #if (LDA2 <= 0)      #undef LDA2   #endif#endif#ifdef LDB2   #if (LDB2 <= 0)      #undef LDB2   #endif#endif#ifdef LDC2   #if (LDC2 <= 0)      #undef LDC2   #endif#endif#ifdef TransA   #define TA T   #ifndef LDA2      #define LDA2 KB   #endif#elif defined(ConjTransA)   #define TA C   #ifndef LDA2      #define LDA2 KB   #endif#else   #define TA N   #ifndef LDA2      #define LDA2 MB   #endif#endif#ifdef TransB   #define TB T   #ifndef LDB2      #define LDB2 NB   #endif#elif defined(ConjTransB)   #define TB C   #ifndef LDB2      #define LDB2 NB   #endif#else   #define TB N   #ifndef LDB2      #define LDB2 KB   #endif#endif#ifndef LDC2   #define LDC2 MB#endif#if (ALPHA == 1)   #define ALPHAnam _a1#elif (ALPHA == -1)   #define ALPHAnam _an1#elif (ALPHA == SAFE_ALPHA)   #define ALPHAnam _aXX#else   #define ALPHAnam _aX#endif#if (BETA == 1)   #define BETAnam _b1   #define NBETAnam _bn1#elif (BETA == 0)   #define BETAnam _b0   #define NBETAnam _b0#elif (BETA == -1)   #define BETAnam _bn1   #define NBETAnam _b1#else   #define BETAnam _bX   #define NBETAnam _bX#endif#define ppre Mjoin(Mjoin(ATL_,pre),LOOPO)#define MNKnam Mjoin(Mjoin(Mjoin(Mjoin(MB0,x),NB0),x),KB0)#define TRnam Mjoin(TA, TB)#define ldnam Mjoin(Mjoin(Mjoin(Mjoin(LDA,x),LDB),x),LDC)#ifdef TREAL   #define NBmm Mjoin(Mjoin(Mjoin(Mjoin(Mjoin(ppre,MNKnam), TRnam),ldnam), ALPHAnam), BETAnam)   void NBmm(const int, const int, const int, const SCALAR, const TYPE*,             const int, const TYPE*, const int, const SCALAR, TYPE*, const int);#else   #define NBmm0 Mjoin(Mjoin(Mjoin(Mjoin(ppre,MNKnam), TRnam),ldnam), ALPHAnam)   #define _bn1 _bX   void Mjoin(NBmm0,BETAnam)(const int, const int, const int, const TYPE,                             const TYPE*, const int, const TYPE*, const int,                             const TYPE, TYPE*, const int);   void Mjoin(NBmm0,_bn1)(const int, const int, const int, const TYPE,                        const TYPE*, const int, const TYPE*, const int,                        const TYPE, TYPE*, const int);   void Mjoin(NBmm0,_b1)(const int, const int, const int, const TYPE,                       const TYPE*, const int, const TYPE*, const int,                       const TYPE, TYPE*, const int);#if csA == 1 && csB == 1   #if csC == 2      #define NBmm(m_, n_, k_, alp_, a_, lda_, b_, ldb_, bet_, c_, ldc_) \      { \         Mjoin(NBmm0,NBETAnam)(m_, n_, k_, *(alp_), (a_), lda_, (b_), \                               ldb_, -(*(bet_)), c_, ldc_); \         Mjoin(NBmm0,BETAnam)(m_, n_, k_, *(alp_), a_, lda_, (b_)+incb, ldb_, \                              *(bet_), (c_)+1, ldc_); \         Mjoin(NBmm0,_bn1)(m_, n_, k_, *(alp_), (a_)+inca, lda_, (b_)+incb, \                           ldb_, rnone, c_, ldc_); \         Mjoin(NBmm0,_b1)(m_, n_, k_, *(alp_), (a_)+inca, lda_, (b_), ldb_, \                          rone, (c_)+1, ldc_); \      }   #elif csC == 1      #define NBmm(m_, n_, k_, alp_, a_, lda_, b_, ldb_, bet_, c_, ldc_) \      { \         Mjoin(NBmm0,NBETAnam)(m_, n_, k_, *(alp_), (a_), lda_, (b_), \                               ldb_, -(*(bet_)), c_, ldc_); \         Mjoin(NBmm0,BETAnam)(m_, n_, k_, *(alp_), a_, lda_, (b_)+incb, ldb_, \                              *(bet_), (c_)+incc, ldc_); \         Mjoin(NBmm0,_bn1)(m_, n_, k_, *(alp_), (a_)+inca, lda_, (b_)+incb, \                           ldb_, rnone, c_, ldc_); \         Mjoin(NBmm0,_b1)(m_, n_, k_, *(alp_), (a_)+inca, lda_, (b_), ldb_, \                          rone, (c_)+incc, ldc_); \      }   #endif#else /* csA == 2 && csB == 2 && csC == 2 */   #define NBmm(m_, n_, k_, alp_, a_, lda_, b_, ldb_, bet_, c_, ldc_) \   { \      Mjoin(NBmm0,NBETAnam)(m_, n_, k_, *(alp_), (a_)+1, lda_, (b_)+1, ldb_, \                            -(*(bet_)), c_, ldc_); \      Mjoin(NBmm0,BETAnam)(m_, n_, k_, *(alp_), (a_)+1, lda_, b_, ldb_, \                           *(bet_), (c_)+1, ldc_); \      Mjoin(NBmm0,_bn1)(m_, n_, k_, *(alp_), a_, lda_, b_, ldb_, \                        rnone, c_, ldc_); \      Mjoin(NBmm0,_b1)(m_, n_, k_, *(alp_), a_, lda_, (b_)+1, ldb_, \                       rone, (c_)+1, ldc_); \   }#endif#if 0   #undef NBmm

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?