From ccddec68116fc6403858ebfa13d4a7b1aa3d5278 Mon Sep 17 00:00:00 2001 From: "N.N." Date: Sun, 18 Oct 2009 20:01:19 +0000 Subject: hi gridflow 0.9.5 svn path=/trunk/; revision=12611 --- externals/gridflow/bundled/Base/GemSIMD.h | 111 ++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 externals/gridflow/bundled/Base/GemSIMD.h (limited to 'externals/gridflow/bundled/Base/GemSIMD.h') diff --git a/externals/gridflow/bundled/Base/GemSIMD.h b/externals/gridflow/bundled/Base/GemSIMD.h new file mode 100644 index 00000000..32cdb32a --- /dev/null +++ b/externals/gridflow/bundled/Base/GemSIMD.h @@ -0,0 +1,111 @@ + +/*----------------------------------------------------------------- +LOG + GEM - Graphics Environment for Multimedia + + include file for SIMD + + Copyright (c) 1997-1999 Mark Danks. mark@danks.org + Copyright (c) Günther Geiger. geiger@epy.co.at + Copyright (c) 2001-2002 IOhannes m zmoelnig. forum::für::umläute. IEM. zmoelnig@iem.kug.ac.at + For information on usage and redistribution, and for a DISCLAIMER OF ALL + WARRANTIES, see the file, "GEM.LICENSE.TERMS" in this distribution. + +-----------------------------------------------------------------*/ + +/* + * compiler-issues: + * + * gcc: when gcc is invoked with "-mmmx" (or "-msse2" or "-maltivec") + * the defines __MMX__ (or corresponding) will be defined automatically + * + * vc6: you will have to install the microsoft processor-pack to use MMX/SSE2 + * you have to have the sp5 for vc6 installed (note: do not install sp6!!) + * vc6/vc7: (i think) you need to define __MMX__ (and friends) by hand + */ + +#ifndef INCLUDE_GEMSIMD_H_ +#define INCLUDE_GEMSIMD_H_ + +#define GEM_VECTORALIGNMENT 128 + +const int GEM_SIMD_NONE=0; +const int GEM_SIMD_MMX=1; +const int GEM_SIMD_SSE2=2; +const int GEM_SIMD_ALTIVEC=3; + + +/* include for SIMD on PC's */ +#ifdef __SSE2__ +#include +// for icc this should be +typedef union{ + unsigned char c[16]; + __m128i v; +} vector_128; +#elif defined __VEC__ +/* for AltiVec (PowerPC) */ +typedef union{ + unsigned char c[16]; + vector unsigned char v; +} vector_128; +#endif + +#if defined __MMX__ +# include +// for icc this should be +typedef union{ + __m64 v; unsigned char c[8]; +} vector64i; + +#endif + + +#ifdef __SSE__ +#include + +typedef union{ + __m128 m; float f[4]; +} vector128f; +#endif + +#include "GemExportDef.h" + + +/* this is a help-class to query the capabilities of the cpu + * whenever you want to use SIMD-optimized code, you should + * make sure you chose the code-block based on the "cpuid" value + * of this class and NOT simply on preprocessor defines. + * + * this class needs only be instantiated once (and it is done in GemMan) + * this sets the cpuid + */ +class GEM_EXTERN GemSIMD +{ + public: + GemSIMD(); + ~GemSIMD(); + + /* this gets the "cpuid" (something like GEM_SIMD_NONE) */ + static int getCPU(); + + /* change the cpuid returned by getCPU() + * you can only set the cpuid to something that is actually supported + * by your processor + */ + static int requestCPU(int cpuid); + + /* performs a runtime-check (if possible) to determine the capabilities + * of the CPU + * sets realcpuid appropriately and returns this value + */ + static int simd_runtime_check(void); + + private: + /* this is the maximum capability of the CPU */ + static int realcpuid; + /* this is the current choosen capability (normally this equals realcpuid) */ + static int cpuid; +}; + +#endif /* INCLUDE_GEMSIMD_H_ */ -- cgit v1.2.1