00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef VECTOR_INTRIN
00050 #define VECTOR_INTRIN
00051 #include "common.h"
00052 #include "g_intrin.h"
00053
00059 template<typename Treal, typename Treg>
00060 class Vector_intrin {
00061 public:
00062 inline void ALWAYS_INLINE load_p(Treal const * ptr) {
00063 values = _mm_load_p(ptr);
00064 }
00065 inline void ALWAYS_INLINE load1_p(Treal const * ptr) {
00066 values = _mm_load1_p(ptr);
00067 }
00068 inline void ALWAYS_INLINE store_p(Treal * ptr) const {
00069 _mm_store_p ( ptr, values );
00070 }
00071 inline Vector_intrin<Treal, Treg>& ALWAYS_INLINE operator*= ( Vector_intrin<Treal, Treg> const & other ) {
00072 values = _mm_mul_p ( other.values, values );
00073 return *this;
00074 }
00075 inline Vector_intrin<Treal, Treg>& ALWAYS_INLINE operator+= ( Vector_intrin<Treal, Treg> const & other ) {
00076 values = _mm_add_p ( other.values, values );
00077 return *this;
00078 }
00079 inline Vector_intrin<Treal, Treg>& ALWAYS_INLINE operator+= ( Treal const * ptr ) {
00080 Treg tmp;
00081 tmp = _mm_load_p(ptr);
00082 values = _mm_add_p ( tmp, values );
00083 return *this;
00084 }
00085 #if 0
00086 inline void ALWAYS_INLINE xor_p( Vector_intrin<Treal, Treg> const & other ) {
00087 values = _mm_xor_p ( other.values, values );
00088 }
00089 #endif
00090 inline void ALWAYS_INLINE set_to_zero() {
00091 values = _mm_xor_p ( values, values );
00092 }
00093 protected:
00094 Treg values;
00095 private:
00096 };
00097
00098 template<typename Treal>
00099 class Vector_intrin<Treal, Treal> {
00100 public:
00101 inline void ALWAYS_INLINE load_p(Treal const * ptr) {
00102 values = *ptr;
00103 }
00104 inline void ALWAYS_INLINE load1_p(Treal const * ptr) {
00105 values = *ptr;
00106 }
00107 inline void ALWAYS_INLINE store_p(Treal * ptr) const {
00108 *ptr = values;
00109 }
00110 inline Vector_intrin<Treal, Treal>& ALWAYS_INLINE operator*= ( Vector_intrin<Treal, Treal> const & other ) {
00111 values *= other.values;
00112 return *this;
00113 }
00114 inline Vector_intrin<Treal, Treal>& ALWAYS_INLINE operator+= ( Vector_intrin<Treal, Treal> const & other ) {
00115 values += other.values;
00116 return *this;
00117 }
00118 inline Vector_intrin<Treal, Treal>& ALWAYS_INLINE operator+= ( Treal const * ptr ) {
00119 values += *ptr;
00120 return *this;
00121 }
00122 #if 0
00123 inline void ALWAYS_INLINE xor_p( Vector_intrin<Treal, Treg> const & other ) {
00124 values = _mm_xor_p ( other.values, values );
00125 }
00126 #endif
00127 inline void ALWAYS_INLINE set_to_zero() {
00128 values = 0;
00129 }
00130 protected:
00131 Treal values;
00132 private:
00133 };
00134
00135
00136
00137
00138
00139
00140 #if 0
00141 template<>
00142 class Vector_intrin<double, double> {
00143 public:
00144 inline void ALWAYS_INLINE load_p(double const * ptr) {
00145 values[0] = *ptr;
00146 values[1] = ptr[1];
00147 }
00148 inline void ALWAYS_INLINE load1_p(double const * ptr) {
00149 values[0] = *ptr;
00150 values[1] = *ptr;
00151 }
00152 inline void ALWAYS_INLINE store_p(double * ptr) const {
00153 ptr[0] = values[0];
00154 ptr[1] = values[1];
00155 }
00156 inline Vector_intrin<double, double>& ALWAYS_INLINE operator*= ( Vector_intrin<double, double> const & other ) {
00157 values[0] *= other.values[0];
00158 values[1] *= other.values[1];
00159 }
00160 inline Vector_intrin<double, double>& ALWAYS_INLINE operator+= ( Vector_intrin<double, double> const & other ) {
00161 values[0] += other.values[0];
00162 values[1] += other.values[1];
00163 }
00164 inline Vector_intrin<double, double>& ALWAYS_INLINE operator+= ( double const * ptr ) {
00165 values[0] += *ptr;
00166 values[1] += ptr[1];
00167 }
00168 #if 0
00169 inline void ALWAYS_INLINE xor_p( Vector_intrin<double, Treg> const & other ) {
00170 values = _mm_xor_p ( other.values, values );
00171 }
00172 #endif
00173 inline void ALWAYS_INLINE set_to_zero() {
00174 values[0] = 0;
00175 values[1] = 0;
00176 }
00177 protected:
00178 double values[2];
00179 private:
00180 };
00181 #endif
00182
00183 #endif // VECTOR_INTRIN