kusano 2b45e8
/*****************************************************************************
kusano 2b45e8
Copyright (c) 2011, Lab of Parallel Software and Computational Science,ICSAS
kusano 2b45e8
All rights reserved.
kusano 2b45e8
kusano 2b45e8
Redistribution and use in source and binary forms, with or without
kusano 2b45e8
modification, are permitted provided that the following conditions are
kusano 2b45e8
met:
kusano 2b45e8
kusano 2b45e8
   1. Redistributions of source code must retain the above copyright
kusano 2b45e8
      notice, this list of conditions and the following disclaimer.
kusano 2b45e8
kusano 2b45e8
   2. Redistributions in binary form must reproduce the above copyright
kusano 2b45e8
      notice, this list of conditions and the following disclaimer in
kusano 2b45e8
      the documentation and/or other materials provided with the
kusano 2b45e8
      distribution.
kusano 2b45e8
   3. Neither the name of the ISCAS nor the names of its contributors may 
kusano 2b45e8
      be used to endorse or promote products derived from this software 
kusano 2b45e8
      without specific prior written permission.
kusano 2b45e8
kusano 2b45e8
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
kusano 2b45e8
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
kusano 2b45e8
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
kusano 2b45e8
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
kusano 2b45e8
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
kusano 2b45e8
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
kusano 2b45e8
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
kusano 2b45e8
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
kusano 2b45e8
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
kusano 2b45e8
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kusano 2b45e8
kusano 2b45e8
**********************************************************************************/
kusano 2b45e8
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
#if defined(__WIN32__) || defined(__WIN64__) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
kusano 2b45e8
#define OS_WINDOWS
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#include <stdio.h></stdio.h>
kusano 2b45e8
#include <string.h></string.h>
kusano 2b45e8
#ifdef OS_WINDOWS
kusano 2b45e8
#include <windows.h></windows.h>
kusano 2b45e8
#endif
kusano 2b45e8
#if defined(__FreeBSD__) || defined(__APPLE__)
kusano 2b45e8
#include <sys types.h=""></sys>
kusano 2b45e8
#include <sys sysctl.h=""></sys>
kusano 2b45e8
#endif
kusano 2b45e8
#ifdef linux
kusano 2b45e8
#include <sys sysinfo.h=""></sys>
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
/* #define FORCE_P2		*/
kusano 2b45e8
/* #define FORCE_KATMAI		*/
kusano 2b45e8
/* #define FORCE_COPPERMINE	*/
kusano 2b45e8
/* #define FORCE_NORTHWOOD	*/
kusano 2b45e8
/* #define FORCE_PRESCOTT	*/
kusano 2b45e8
/* #define FORCE_BANIAS		*/
kusano 2b45e8
/* #define FORCE_YONAH		*/
kusano 2b45e8
/* #define FORCE_CORE2		*/
kusano 2b45e8
/* #define FORCE_PENRYN		*/
kusano 2b45e8
/* #define FORCE_DUNNINGTON	*/
kusano 2b45e8
/* #define FORCE_NEHALEM	*/
kusano 2b45e8
/* #define FORCE_ATHLON		*/
kusano 2b45e8
/* #define FORCE_OPTERON	*/
kusano 2b45e8
/* #define FORCE_OPTERON_SSE3	*/
kusano 2b45e8
/* #define FORCE_BARCELONA	*/
kusano 2b45e8
/* #define FORCE_SHANGHAI	*/
kusano 2b45e8
/* #define FORCE_ISTANBUL	*/
kusano 2b45e8
/* #define FORCE_SSE_GENERIC	*/
kusano 2b45e8
/* #define FORCE_VIAC3		*/
kusano 2b45e8
/* #define FORCE_NANO		*/
kusano 2b45e8
/* #define FORCE_POWER3		*/
kusano 2b45e8
/* #define FORCE_POWER4		*/
kusano 2b45e8
/* #define FORCE_POWER5		*/
kusano 2b45e8
/* #define FORCE_POWER6		*/
kusano 2b45e8
/* #define FORCE_PPCG4		*/
kusano 2b45e8
/* #define FORCE_PPC970		*/
kusano 2b45e8
/* #define FORCE_PPC970MP	*/
kusano 2b45e8
/* #define FORCE_PPC440		*/
kusano 2b45e8
/* #define FORCE_PPC440FP2	*/
kusano 2b45e8
/* #define FORCE_CELL		*/
kusano 2b45e8
/* #define FORCE_SICORTEX	*/
kusano 2b45e8
/* #define FORCE_LOONGSON3A      */
kusano 2b45e8
/* #define FORCE_LOONGSON3B      */
kusano 2b45e8
/* #define FORCE_ITANIUM2	*/
kusano 2b45e8
/* #define FORCE_GENERIC	*/
kusano 2b45e8
/* #define FORCE_SPARC		*/
kusano 2b45e8
/* #define FORCE_SPARCV7	*/
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_P2
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENTIUM2"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUM2 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX"
kusano 2b45e8
#define LIBNAME   "p2"
kusano 2b45e8
#define CORENAME  "P5"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_COPPERMINE
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENTIUM3"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUM3 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=262144 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE "
kusano 2b45e8
#define LIBNAME   "coppermine"
kusano 2b45e8
#define CORENAME  "COPPERMINE"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_KATMAI
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENTIUM3"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUM3 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=524288 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE "
kusano 2b45e8
#define LIBNAME   "katmai"
kusano 2b45e8
#define CORENAME  "KATMAI"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_NORTHWOOD
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENTIUM4"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUM4 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=8192 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
kusano 2b45e8
#define LIBNAME   "northwood"
kusano 2b45e8
#define CORENAME  "NORTHWOOD"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PRESCOTT
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENTIUM4"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUM4 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3"
kusano 2b45e8
#define LIBNAME   "prescott"
kusano 2b45e8
#define CORENAME  "PRESCOTT"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_BANIAS
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "BANIAS"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUMM " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
kusano 2b45e8
#define LIBNAME   "banias"
kusano 2b45e8
#define CORENAME  "BANIAS"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_YONAH
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "YONAH"
kusano 2b45e8
#define ARCHCONFIG   "-DPENTIUMM " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
kusano 2b45e8
#define LIBNAME   "yonah"
kusano 2b45e8
#define CORENAME  "YONAH"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_CORE2
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "CONRORE"
kusano 2b45e8
#define ARCHCONFIG   "-DCORE2 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
kusano 2b45e8
#define LIBNAME   "core2"
kusano 2b45e8
#define CORENAME  "CORE2"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PENRYN
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "PENRYN"
kusano 2b45e8
#define ARCHCONFIG   "-DPENRYN " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1"
kusano 2b45e8
#define LIBNAME   "penryn"
kusano 2b45e8
#define CORENAME  "PENRYN"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_DUNNINGTON
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "DUNNINGTON"
kusano 2b45e8
#define ARCHCONFIG   "-DDUNNINGTON " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DL3_SIZE=16777216 -DL3_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1"
kusano 2b45e8
#define LIBNAME   "dunnington"
kusano 2b45e8
#define CORENAME  "DUNNINGTON"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_NEHALEM
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "NEHALEM"
kusano 2b45e8
#define ARCHCONFIG   "-DNEHALEM " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=262144 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3 -DHAVE_SSE4_1 -DHAVE_SSE4_2"
kusano 2b45e8
#define LIBNAME   "nehalem"
kusano 2b45e8
#define CORENAME  "NEHALEM"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_ATOM
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "ATOM"
kusano 2b45e8
#define ARCHCONFIG   "-DATOM " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=24576 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
kusano 2b45e8
#define LIBNAME   "atom"
kusano 2b45e8
#define CORENAME  "ATOM"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_ATHLON
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "ATHLON"
kusano 2b45e8
#define ARCHCONFIG   "-DATHLON " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW  " \
kusano 2b45e8
		     "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE "
kusano 2b45e8
#define LIBNAME   "athlon"
kusano 2b45e8
#define CORENAME  "ATHLON"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_OPTERON
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "OPTERON"
kusano 2b45e8
#define ARCHCONFIG   "-DOPTERON " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
kusano 2b45e8
		     "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 "
kusano 2b45e8
#define LIBNAME   "opteron"
kusano 2b45e8
#define CORENAME  "OPTERON"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_OPTERON_SSE3
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "OPTERON"
kusano 2b45e8
#define ARCHCONFIG   "-DOPTERON " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
kusano 2b45e8
		     "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3"
kusano 2b45e8
#define LIBNAME   "opteron"
kusano 2b45e8
#define CORENAME  "OPTERON"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(FORCE_BARCELONA) || defined(FORCE_SHANGHAI) || defined(FORCE_ISTANBUL)
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "BARCELONA"
kusano 2b45e8
#define ARCHCONFIG   "-DBARCELONA " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=524288 -DL2_LINESIZE=64  -DL3_SIZE=2097152 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=48 -DDTB_SIZE=4096 -DHAVE_3DNOW " \
kusano 2b45e8
		     "-DHAVE_3DNOWEX -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 " \
kusano 2b45e8
		     "-DHAVE_SSE4A -DHAVE_MISALIGNSSE -DHAVE_128BITFPU -DHAVE_FASTMOVU"
kusano 2b45e8
#define LIBNAME   "barcelona"
kusano 2b45e8
#define CORENAME  "BARCELONA"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_SSE_GENERIC
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "GENERIC"
kusano 2b45e8
#define ARCHCONFIG   "-DGENERIC " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=16384 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=524288 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2"
kusano 2b45e8
#define LIBNAME   "generic"
kusano 2b45e8
#define CORENAME  "GENERIC"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_VIAC3
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "VIAC3"
kusano 2b45e8
#define ARCHCONFIG   "-DVIAC3 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=65536 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 " \
kusano 2b45e8
		     "-DHAVE_MMX -DHAVE_SSE "
kusano 2b45e8
#define LIBNAME   "viac3"
kusano 2b45e8
#define CORENAME  "VIAC3"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_NANO
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define FORCE_INTEL
kusano 2b45e8
#define ARCHITECTURE    "X86"
kusano 2b45e8
#define SUBARCHITECTURE "NANO"
kusano 2b45e8
#define ARCHCONFIG   "-DNANO " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1048576 -DL2_LINESIZE=64 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 " \
kusano 2b45e8
		     "-DHAVE_CMOV -DHAVE_MMX -DHAVE_SSE -DHAVE_SSE2 -DHAVE_SSE3 -DHAVE_SSSE3"
kusano 2b45e8
#define LIBNAME   "nano"
kusano 2b45e8
#define CORENAME  "NANO"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_POWER3
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "POWER3"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPOWER3 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=2097152 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=256 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "power3"
kusano 2b45e8
#define CORENAME  "POWER3"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_POWER4
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "POWER4"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPOWER4 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=1509949 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=6 "
kusano 2b45e8
#define LIBNAME   "power4"
kusano 2b45e8
#define CORENAME  "POWER4"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_POWER5
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "POWER5"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPOWER5 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=1509949 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=6 "
kusano 2b45e8
#define LIBNAME   "power5"
kusano 2b45e8
#define CORENAME  "POWER5"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_POWER6
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "POWER6"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPOWER6 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=4194304 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "power6"
kusano 2b45e8
#define CORENAME  "POWER6"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PPCG4
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "PPCG4"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPPCG4 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=262144 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "ppcg4"
kusano 2b45e8
#define CORENAME  "PPCG4"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PPC970
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "PPC970"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPPC970 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "ppc970"
kusano 2b45e8
#define CORENAME  "PPC970"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PPC970MP
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "PPC970"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPPC970 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=1024976 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "ppc970mp"
kusano 2b45e8
#define CORENAME  "PPC970"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PPC440
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "PPC440"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPPC440 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=16384 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=16 "
kusano 2b45e8
#define LIBNAME   "ppc440"
kusano 2b45e8
#define CORENAME  "PPC440"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_PPC440FP2
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "PPC440FP2"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DPPC440FP2 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=16384 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=16 "
kusano 2b45e8
#define LIBNAME   "ppc440FP2"
kusano 2b45e8
#define CORENAME  "PPC440FP2"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_CELL
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "POWER"
kusano 2b45e8
#define SUBARCHITECTURE "CELL"
kusano 2b45e8
#define SUBDIRNAME      "power"
kusano 2b45e8
#define ARCHCONFIG   "-DCELL " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=262144 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "cell"
kusano 2b45e8
#define CORENAME  "CELL"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_SICORTEX
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "MIPS"
kusano 2b45e8
#define SUBARCHITECTURE "SICORTEX"
kusano 2b45e8
#define SUBDIRNAME      "mips"
kusano 2b45e8
#define ARCHCONFIG   "-DSICORTEX " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
		     "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=32 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "mips"
kusano 2b45e8
#define CORENAME  "sicortex"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_LOONGSON3A
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "MIPS"
kusano 2b45e8
#define SUBARCHITECTURE "LOONGSON3A"
kusano 2b45e8
#define SUBDIRNAME      "mips64"
kusano 2b45e8
#define ARCHCONFIG   "-DLOONGSON3A " \
kusano 2b45e8
       "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
       "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
kusano 2b45e8
       "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 "
kusano 2b45e8
#define LIBNAME   "loongson3a"
kusano 2b45e8
#define CORENAME  "LOONGSON3A"
kusano 2b45e8
#else
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_LOONGSON3B
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "MIPS"
kusano 2b45e8
#define SUBARCHITECTURE "LOONGSON3B"
kusano 2b45e8
#define SUBDIRNAME      "mips64"
kusano 2b45e8
#define ARCHCONFIG   "-DLOONGSON3B " \
kusano 2b45e8
       "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=32 " \
kusano 2b45e8
       "-DL2_SIZE=512488 -DL2_LINESIZE=32 " \
kusano 2b45e8
       "-DDTB_DEFAULT_ENTRIES=64 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=4 "
kusano 2b45e8
#define LIBNAME   "loongson3b"
kusano 2b45e8
#define CORENAME  "LOONGSON3B"
kusano 2b45e8
#else
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_ITANIUM2
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "IA64"
kusano 2b45e8
#define SUBARCHITECTURE "ITANIUM2"
kusano 2b45e8
#define SUBDIRNAME      "ia64"
kusano 2b45e8
#define ARCHCONFIG   "-DITANIUM2 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=262144 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=1572864 -DL2_LINESIZE=128 -DDTB_SIZE=16384 -DDTB_DEFAULT_ENTRIES=128 "
kusano 2b45e8
#define LIBNAME   "itanium2"
kusano 2b45e8
#define CORENAME  "itanium2"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_SPARC
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "SPARC"
kusano 2b45e8
#define SUBARCHITECTURE "SPARC"
kusano 2b45e8
#define SUBDIRNAME      "sparc"
kusano 2b45e8
#define ARCHCONFIG   "-DSPARC -DV9 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1572864 -DL2_LINESIZE=64 -DDTB_SIZE=8192 -DDTB_DEFAULT_ENTRIES=64 "
kusano 2b45e8
#define LIBNAME   "sparc"
kusano 2b45e8
#define CORENAME  "sparc"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_SPARCV7
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "SPARC"
kusano 2b45e8
#define SUBARCHITECTURE "SPARC"
kusano 2b45e8
#define SUBDIRNAME      "sparc"
kusano 2b45e8
#define ARCHCONFIG   "-DSPARC -DV7 " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=65536 -DL1_DATA_LINESIZE=64 " \
kusano 2b45e8
		     "-DL2_SIZE=1572864 -DL2_LINESIZE=64 -DDTB_SIZE=8192 -DDTB_DEFAULT_ENTRIES=64 "
kusano 2b45e8
#define LIBNAME   "sparcv7"
kusano 2b45e8
#define CORENAME  "sparcv7"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE_GENERIC
kusano 2b45e8
#define FORCE
kusano 2b45e8
#define ARCHITECTURE    "GENERIC"
kusano 2b45e8
#define SUBARCHITECTURE "GENERIC"
kusano 2b45e8
#define SUBDIRNAME      "generic"
kusano 2b45e8
#define ARCHCONFIG   "-DGENERIC " \
kusano 2b45e8
		     "-DL1_DATA_SIZE=32768 -DL1_DATA_LINESIZE=128 " \
kusano 2b45e8
		     "-DL2_SIZE=512488 -DL2_LINESIZE=128 " \
kusano 2b45e8
		     "-DDTB_DEFAULT_ENTRIES=128 -DDTB_SIZE=4096 -DL2_ASSOCIATIVE=8 "
kusano 2b45e8
#define LIBNAME   "generic"
kusano 2b45e8
#define CORENAME  "generic"
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef FORCE
kusano 2b45e8
kusano 2b45e8
#if defined(__powerpc__) || defined(__powerpc) || defined(powerpc) || \
kusano 2b45e8
    defined(__PPC__) || defined(PPC) || defined(_POWER) || defined(__POWERPC__)
kusano 2b45e8
#ifndef POWER
kusano 2b45e8
#define POWER
kusano 2b45e8
#endif
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#if defined(__i386__) || (__x86_64__)
kusano 2b45e8
#include "cpuid_x86.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef __ia64__
kusano 2b45e8
#include "cpuid_ia64.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef __alpha
kusano 2b45e8
#include "cpuid_alpha.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef POWER
kusano 2b45e8
#include "cpuid_power.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef sparc
kusano 2b45e8
#include "cpuid_sparc.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef __mips__
kusano 2b45e8
#include "cpuid_mips.c"
kusano 2b45e8
#define OPENBLAS_SUPPORTED
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef OPENBLAS_SUPPORTED
kusano 2b45e8
#error "This arch/CPU is not supported by OpenBLAS."
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
static int get_num_cores(void) {
kusano 2b45e8
kusano 2b45e8
#ifdef OS_WINDOWS
kusano 2b45e8
  SYSTEM_INFO sysinfo;
kusano 2b45e8
#elif defined(__FreeBSD__) || defined(__APPLE__)
kusano 2b45e8
  int m[2], count;
kusano 2b45e8
  size_t len;
kusano 2b45e8
#endif
kusano 2b45e8
  
kusano 2b45e8
#ifdef linux
kusano 2b45e8
  return get_nprocs();
kusano 2b45e8
  
kusano 2b45e8
#elif defined(OS_WINDOWS)
kusano 2b45e8
kusano 2b45e8
  GetSystemInfo(&sysinfo);
kusano 2b45e8
  return sysinfo.dwNumberOfProcessors;
kusano 2b45e8
kusano 2b45e8
#elif defined(__FreeBSD__) || defined(__APPLE__)
kusano 2b45e8
  m[0] = CTL_HW;
kusano 2b45e8
  m[1] = HW_NCPU;
kusano 2b45e8
  len = sizeof(int);
kusano 2b45e8
  sysctl(m, 2, &count, &len, NULL, 0);
kusano 2b45e8
kusano 2b45e8
  return count;
kusano 2b45e8
#else
kusano 2b45e8
  return 2;
kusano 2b45e8
#endif
kusano 2b45e8
}
kusano 2b45e8
kusano 2b45e8
int main(int argc, char *argv[]){
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE
kusano 2b45e8
  char buffer[8192], *p, *q;
kusano 2b45e8
  int length;
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
  if (argc == 1) return 0;
kusano 2b45e8
kusano 2b45e8
  switch (argv[1][0]) {
kusano 2b45e8
kusano 2b45e8
  case '0' : /* for Makefile */
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE
kusano 2b45e8
    printf("CORE=%s\n", CORENAME);
kusano 2b45e8
#else    
kusano 2b45e8
#if defined(__i386__) || defined(__x86_64__) || defined(POWER) || defined(__mips__)
kusano 2b45e8
    printf("CORE=%s\n", get_corename());
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifdef FORCE
kusano 2b45e8
    printf("LIBCORE=%s\n", LIBNAME);
kusano 2b45e8
#else
kusano 2b45e8
    printf("LIBCORE=");
kusano 2b45e8
    get_libname();
kusano 2b45e8
    printf("\n");
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
    printf("NUM_CORES=%d\n", get_num_cores());
kusano 2b45e8
kusano 2b45e8
#if defined(__i386__) || defined(__x86_64__)
kusano 2b45e8
#ifndef FORCE
kusano 2b45e8
    get_sse();
kusano 2b45e8
#else
kusano 2b45e8
kusano 2b45e8
    sprintf(buffer, "%s", ARCHCONFIG);
kusano 2b45e8
kusano 2b45e8
    p = &buffer[0];
kusano 2b45e8
kusano 2b45e8
    while (*p) {
kusano 2b45e8
      if ((*p == '-') && (*(p + 1) == 'D')) {
kusano 2b45e8
	p += 2;
kusano 2b45e8
kusano 2b45e8
	while ((*p != ' ') && (*p != '\0')) {
kusano 2b45e8
kusano 2b45e8
	  if (*p == '=') {
kusano 2b45e8
	    printf("=");
kusano 2b45e8
	    p ++;
kusano 2b45e8
	    while ((*p != ' ') && (*p != '\0')) {
kusano 2b45e8
	      printf("%c", *p);
kusano 2b45e8
	      p ++;
kusano 2b45e8
	    }
kusano 2b45e8
	  } else {
kusano 2b45e8
	    printf("%c", *p);
kusano 2b45e8
	    p ++;
kusano 2b45e8
	    if ((*p == ' ') || (*p =='\0')) printf("=1");
kusano 2b45e8
	  }
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
	printf("\n");
kusano 2b45e8
      } else p ++;
kusano 2b45e8
    }
kusano 2b45e8
#endif
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
#ifndef OS_WINDOWS
kusano 2b45e8
    printf("MAKE += -j %d\n", get_num_cores());
kusano 2b45e8
#endif
kusano 2b45e8
kusano 2b45e8
    break;
kusano 2b45e8
kusano 2b45e8
  case '1' : /* For config.h */
kusano 2b45e8
#ifdef FORCE
kusano 2b45e8
    sprintf(buffer, "%s -DCORE_%s\n", ARCHCONFIG, CORENAME);
kusano 2b45e8
kusano 2b45e8
    p = &buffer[0];
kusano 2b45e8
    while (*p) {
kusano 2b45e8
      if ((*p == '-') && (*(p + 1) == 'D')) {
kusano 2b45e8
	p += 2;
kusano 2b45e8
	printf("#define ");
kusano 2b45e8
kusano 2b45e8
	while ((*p != ' ') && (*p != '\0')) {
kusano 2b45e8
kusano 2b45e8
	  if (*p == '=') {
kusano 2b45e8
	    printf(" ");
kusano 2b45e8
	    p ++;
kusano 2b45e8
	    while ((*p != ' ') && (*p != '\0')) {
kusano 2b45e8
	      printf("%c", *p);
kusano 2b45e8
	      p ++;
kusano 2b45e8
	    }
kusano 2b45e8
	  } else {
kusano 2b45e8
	    printf("%c", *p);
kusano 2b45e8
	    p ++;
kusano 2b45e8
	  }
kusano 2b45e8
	}
kusano 2b45e8
kusano 2b45e8
	printf("\n");
kusano 2b45e8
      } else p ++;
kusano 2b45e8
    }
kusano 2b45e8
#else
kusano 2b45e8
    get_cpuconfig();
kusano 2b45e8
#endif
kusano 2b45e8
 break;
kusano 2b45e8
kusano 2b45e8
  case '2' : /* SMP */
kusano 2b45e8
    if (get_num_cores() > 1) printf("SMP=1\n");
kusano 2b45e8
    break;
kusano 2b45e8
  }
kusano 2b45e8
kusano 2b45e8
  fflush(stdout);
kusano 2b45e8
kusano 2b45e8
  return 0;
kusano 2b45e8
}
kusano 2b45e8