00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _EXMAT_SIMD_SIMDALIGNMENT_H
00024 #define _EXMAT_SIMD_SIMDALIGNMENT_H
00025
00026 #include "../Config.h"
00027
00028 #if EXMAT_ENABLE_SIMD
00029
00030 #if EXMAT_SIMD_FLOAT
00031 # if EXMAT_ENABLE_SSE
00032 # include "SSE/Intrinsics.h"
00033 # define EXMAT_SIMD_FLOAT_UNIT __m128
00034 # ifndef EXMAT_SIMD_DEFAULT_ALIGN
00035 # define EXMAT_SIMD_DEFAULT_ALIGN 16
00036 # endif // EXMAT_SIMD_DEFAULT_ALIGN
00037 # define EXMAT_SIMD_FLOAT_ALIGN 16
00038 # include "SSE/MatMul.h"
00039 # endif // EXMAT_ENABLE_SSE
00040 #endif // EXMAT_SIMD_FLOAT
00041
00042 #if EXMAT_SIMD_DOUBLE
00043 # if EXMAT_ENABLE_SSE2
00044 # include "SSE2/Intrinsics.h"
00045 # define EXMAT_SIMD_DOUBLE_UNIT __m128d
00046 # ifndef EXMAT_SIMD_DEFAULT_ALIGN
00047 # define EXMAT_SIMD_DEFAULT_ALIGN 16
00048 # endif // EXMAT_SIMD_DEFAULT_ALIGN
00049 # define EXMAT_SIMD_DOUBLE_ALIGN 16
00050 # include "SSE2/MatMul.h"
00051 # endif // EXMAT_ENABLE_SSE2
00052 #endif // EXMAT_SIMD_DOUBLE
00053
00054
00055
00056 #if (EXMAT_VC || EXMAT_ICL)
00057 # define EXMAT_VAR_ALIGN(declaration, num) __declspec(align(num)) declaration;
00058 #else
00059 # define EXMAT_VAR_ALIGN(declaration, num) declaration __attribute__((aligned(num)));
00060 #endif
00061
00062
00063
00064 #if (EXMAT_VC || EXMAT_ICL)
00065 # define EXMAT_TYPE_ALIGN_PREFIX(num) __declspec(align(num))
00066 # define EXMAT_TYPE_ALIGN_SUFFIX(num)
00067 #else
00068 # define EXMAT_TYPE_ALIGN_PREFIX(num)
00069 # define EXMAT_TYPE_ALIGN_SUFFIX(num) __attribute__((aligned(num)))
00070 #endif
00071
00072
00073
00074 #if ENABLE_ALIGNMENT_CHECK
00075 # define ALIGNMENT_CHECK(Num) \
00076 if(int(&unitData) % Num != 0) { throw mem_align_error("mem_align_error: struct not #Num aligned\n"); }
00077 #else
00078 # define ALIGNMENT_CHECK(Num)
00079 #endif // ENABLE_ALLIGNMENT_CHECK
00080
00081
00082
00083 #define NEW_ALIGN(Num) \
00084 EXMAT_INLINE2 static void* operator new( size_t size ) { return AlignedMalloc(size, Num); }
00085 #define DELETE_ALIGN() \
00086 EXMAT_INLINE2 static void operator delete(void* addr) { AlignedFree(addr); }
00087
00088 #else
00089
00090 #endif // EXMAT_ENABLE_SIMD
00091
00092 #ifndef EXMAT_SIMD_DEFAULT_ALIGN
00093 # define EXMAT_SIMD_DEFAULT_ALIGN 8
00094 #endif
00095
00096 #endif // _EXMAT_SIMD_SIMDALIGNMENT_H