Auryn simulator  v0.8.1-206-gb56e451
Plastic Spiking Neural Network Simulator
Public Member Functions | List of all members
auryn::AurynVectorFloat Class Reference

Default AurynVectorFloat class for performance computation. More...

#include <AurynVector.h>

Inheritance diagram for auryn::AurynVectorFloat:
Inheritance graph
[legend]
Collaboration diagram for auryn::AurynVectorFloat:
Collaboration graph
[legend]

Public Member Functions

 AurynVectorFloat (NeuronID n)
 Default constructor. More...
 
 ~AurynVectorFloat ()
 Default destructor. More...
 
virtual void resize (NeuronID new_size)
 resize data array to new_size More...
 
void scale (const float a)
 
void saxpy (const float a, AurynVectorFloat *x)
 
void clip (const float min, const float max)
 
void add (const float c)
 
void add (AurynVectorFloat *v)
 
void sum (AurynVectorFloat *a, AurynVectorFloat *b)
 
void sum (AurynVectorFloat *a, const float b)
 
void mul (const float a)
 
void mul (AurynVectorFloat *v)
 
void diff (AurynVectorFloat *a, AurynVectorFloat *b)
 
void diff (AurynVectorFloat *a, const float b)
 
void diff (const float a, AurynVectorFloat *b)
 
void follow (AurynVectorFloat *v, const float rate)
 
- Public Member Functions inherited from auryn::AurynVector< float, NeuronID >
 AurynVector (NeuronID n)
 Default constructor. More...
 
 AurynVector (AurynVector *vec)
 Copy constructor. More...
 
virtual ~AurynVector ()
 Default destructor. More...
 
void copy (AurynVector *v)
 Copies vector v. More...
 
float get (NeuronID i)
 Gets element i from vector. More...
 
float * ptr (NeuronID i=0)
 Gets pointer to element i from vector. More...
 
void set (NeuronID i, float value)
 Sets element i in vector to value. More...
 
void set_all (const float v)
 Set all elements to value v. More...
 
void set_zero ()
 Set all elements to zero. More...
 
void scale (const float a)
 Scales all vector elements by a. More...
 
void add (const float c)
 Adds constant c to each vector element. More...
 
void add (AurynVector *v)
 Adds a vector v to the vector. More...
 
void add_specific (const NeuronID i, const float c)
 Adds the value c to specific vector element i. More...
 
void mul_specific (const NeuronID i, const float c)
 Multiply to specific vector element with data index i with the constant c. More...
 
void sub (const float c)
 Subtract constant c to each vector element. More...
 
void sub (AurynVector *v)
 Elementwise subtraction. More...
 
void mul (const float a)
 Multiply all vector elements by constant. More...
 
void mul (AurynVector *v)
 Element-wise vector multiply. More...
 
void div (const float a)
 Element-wise division. More...
 
void div (AurynVector *v)
 Element-wise vector division. More...
 
void div (AurynVector *a, AurynVector *b)
 Element-wise vector division which stores the result in this. More...
 
void saxpy (const float a, AurynVector *x)
 SAXPY operation as in GSL. More...
 
void follow (AurynVector< float, NeuronID > *v, const float rate)
 Follows target vector v with rate. More...
 
void follow_scalar (const float a, const float rate)
 Like follow but with a scalar target value a. More...
 
void elementwise_max (AurynVector *v1, AurynVector *v2)
 Elementwise max operation. More...
 
void elementwise_max (AurynVector *v1)
 Elementwise max operation with another vector. More...
 
void pow (const unsigned int n)
 Takes each element to the n-th power. More...
 
void fast_exp ()
 Computes an approximation of exp(x) for each vector element. More...
 
void exp ()
 Computes exp(x) for each vector element. More...
 
void sigmoid (AurynVector *x, const float beta, const float thr)
 Computes sigmoid(beta*(x-thr)) for each vector element and stores result in this instance. More...
 
void sqrt ()
 Takes the square root of each element. More...
 
void neg ()
 Flips the sign of all elements. More...
 
void inv ()
 Computes 1./x of each element. More...
 
void sum (AurynVector *a, AurynVector *b)
 Computes the sum a+b and stores the result in this instance. More...
 
void sum (AurynVector *a, const float b)
 Computes the sum a+b and stores the result in this instance. More...
 
void diff (AurynVector *a, AurynVector *b)
 Computes the difference a-b and stores the result in this instance. More...
 
void diff (AurynVector *a, const float b)
 Computes the difference a-b and stores the result in this instance. More...
 
void diff (const float a, AurynVector *b)
 Computes the difference a-b and stores the result in this instance. More...
 
void sqr ()
 Squares each element. More...
 
void abs ()
 Takes absolute value of each element. More...
 
void rect ()
 Rectifies all elements. More...
 
void neg_rect ()
 Negatively rectifies all elements. More...
 
void clip (float min, float max)
 Clips all vector elements to the range min max. More...
 
double var ()
 Computes the variance of the vector elements on this rank. More...
 
double std ()
 Computes the standard deviation of all elements on this rank. More...
 
double mean ()
 Computes the mean of the vector elements on this rank. More...
 
double element_sum ()
 Computes the sum of the vector elements. More...
 
double l1norm ()
 Computes the l1 norm of the vector. More...
 
double l2norm ()
 Computes the l2 norm of the vector. More...
 
double max ()
 Returns the max of the vector elements. More...
 
double min ()
 Returns the min of the vector elements. More...
 
NeuronID nonzero ()
 Computes number of nonzero elements on this rank. More...
 
void zero_effective_zeros (const float epsilon=1e-3)
 Sets all values whose absolute value is smaller than epsilon to zero. More...
 
void add_random_normal (AurynState mean=0.0, AurynState sigma=1.0, unsigned int seed=8721)
 
void set_random_normal (AurynState mean=0.0, AurynState sigma=1.0, unsigned int seed=8721)
 
void set_random (unsigned int seed=0)
 Initializes vector elements with Gaussian of unit varince and a seed derived from system time if no seed or seed of 0 is given. More...
 
bool any ()
 Returns true if any element is nonzero. More...
 
bool any (float eps)
 Returns true if any element is nonzero. More...
 
void print ()
 Print vector elements to stdout for debugging. More...
 
void write_to_file (std::string filename)
 Print vector elements to a text file for debugging. More...
 

Additional Inherited Members

- Public Attributes inherited from auryn::AurynVector< float, NeuronID >
NeuronID size
 Size of the vector. More...
 
float * data
 Pointer to the array housing the data. More...
 
- Protected Member Functions inherited from auryn::AurynVector< float, NeuronID >
void check_size (NeuronID x)
 Checks if argument is larger than size and throws and exception if so. More...
 
void check_size (AurynVector *v)
 Checks if vector size matches to this instance. More...
 
void allocate (const NeuronID n)
 Implements aligned memory allocation. More...
 
void freebuf ()
 
float fast_exp256 (float x)
 Computes approximation of exp(x) via fast series approximation up to n=256. More...
 

Detailed Description

Default AurynVectorFloat class for performance computation.

This class derives from AurynVector<float,NeuronID> and overwrites some performance critical member functions defined in the template with SIMD intrinsics for higher performance.

Constructor & Destructor Documentation

◆ AurynVectorFloat()

AurynVectorFloat::AurynVectorFloat ( NeuronID  n)

Default constructor.

53 {
54 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
55  // check that size is a multiple of SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
56  // which is typically 4 for float and SSE
58  resize(n);
59  }
60 #endif /* CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY */
61 }
Default Auryn vector template.
Definition: auryn_definitions.h:327
virtual void resize(NeuronID new_size)
resize data array to new_size
Definition: AurynVector.cpp:63
int n
Definition: mkpat.py:5
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
Here is the call graph for this function:

◆ ~AurynVectorFloat()

auryn::AurynVectorFloat::~AurynVectorFloat ( )
inline

Default destructor.

807  {
808  };
Here is the call graph for this function:

Member Function Documentation

◆ add() [1/2]

void AurynVectorFloat::add ( const float  c)
181 {
182 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
183  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
184  data[0:size:1] = a + data[0:size:1];
185  #else
186  const __m128 scalar = _mm_set1_ps(a);
187  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
188  {
189  // _mm_prefetch((i + SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS), _MM_HINT_NTA);
190  __m128 chunk = sse_load( i );
191  __m128 result = _mm_add_ps(chunk, scalar);
192  sse_store( i, result );
193  }
194  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
195 #else
196  for ( NeuronID i = 0 ; i < size ; ++i ) {
197  data[i] += a;
198  }
199 #endif
200 }
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ add() [2/2]

void AurynVectorFloat::add ( AurynVectorFloat v)
204 {
205  check_size(v);
206 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
207  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
208  data[0:size:1] = data[0:size:1] + v->data[0:v->size:1];
209  #else
210  float * bd = v->data;
211  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
212  {
213  __m128 chunk_a = sse_load( i );
214  __m128 chunk_b = sse_load( bd ); bd+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
215  __m128 result = _mm_add_ps(chunk_a, chunk_b);
216  sse_store( i, result );
217  }
218  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
219 #else
220  for ( NeuronID i = 0 ; i < size ; ++i ) {
221  data[i] += v->data[i];
222  }
223 #endif
224 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ clip()

void AurynVectorFloat::clip ( const float  min,
const float  max 
)
124 {
125 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
126  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
127  for ( NeuronID i = 0 ; i < size ; ++i ) {
128  if ( data[i] < min ) {
129  data[i] = min;
130  } else
131  if ( data[i] > max )
132  data[i] = max;
133  }
134  #else
135  const __m128 lo = _mm_set1_ps(min);
136  const __m128 hi = _mm_set1_ps(max);
137  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
138  {
139  __m128 chunk = sse_load( i );
140  __m128 result = _mm_min_ps(chunk, hi);
141  result = _mm_max_ps(result, lo);
142  sse_store( i, result );
143  }
144  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
145 #else
146  for ( NeuronID i = 0 ; i < size ; ++i ) {
147  if ( data[i] < min ) {
148  data[i] = min;
149  } else
150  if ( data[i] > max )
151  data[i] = max;
152  }
153 #endif
154 }
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
double min()
Returns the min of the vector elements.
Definition: AurynVector.h:682
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
double max()
Returns the max of the vector elements.
Definition: AurynVector.h:669
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ diff() [1/3]

void AurynVectorFloat::diff ( AurynVectorFloat a,
AurynVectorFloat b 
)
263 {
264  check_size(a);
265  check_size(b);
266 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
267  float * ea = a->data;
268  float * eb = b->data;
269  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
270  {
271  const __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
272  const __m128 chunk_b = sse_load( eb ); eb+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
273  __m128 result = _mm_sub_ps(chunk_a, chunk_b);
274  sse_store( i, result );
275  }
276 #else
277  AurynVector::diff(a,b);
278 #endif
279 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
void diff(AurynVector *a, AurynVector *b)
Computes the difference a-b and stores the result in this instance.
Definition: AurynVector.h:502
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
Here is the call graph for this function:

◆ diff() [2/3]

void AurynVectorFloat::diff ( AurynVectorFloat a,
const float  b 
)
282 {
283  check_size(a);
284  sum(a,-b);
285 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
void sum(AurynVectorFloat *a, AurynVectorFloat *b)
Definition: AurynVector.cpp:226
Here is the call graph for this function:

◆ diff() [3/3]

void AurynVectorFloat::diff ( const float  a,
AurynVectorFloat b 
)
288 {
289  check_size(b);
290  sum(b,-a);
291  neg();
292 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
void sum(AurynVectorFloat *a, AurynVectorFloat *b)
Definition: AurynVector.cpp:226
void neg()
Flips the sign of all elements.
Definition: AurynVector.h:461
Here is the call graph for this function:

◆ follow()

void AurynVectorFloat::follow ( AurynVectorFloat v,
const float  rate 
)
295 {
296 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
297  for ( NeuronID i = 0 ; i < size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
298  {
299  const __m128 chunk_a = sse_load( v->data+i );
300  const __m128 chunk_b = sse_load( data+i );
301  const __m128 scalar = _mm_set1_ps(rate);
302  __m128 temp = _mm_sub_ps(chunk_a, chunk_b);
303  temp = _mm_mul_ps( scalar, temp );
304  temp = _mm_add_ps( chunk_b, temp );
305  sse_store( data+i, temp );
306  }
307 #else
308  super::follow(v,rate);
309 #endif
310 }
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
void follow(AurynVector< float, NeuronID > *v, const float rate)
Follows target vector v with rate.
Definition: AurynVector.h:372
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ mul() [1/2]

void auryn::AurynVectorFloat::mul ( const float  a)
inline
819 { scale(a); };
void scale(const float a)
Definition: AurynVector.cpp:74
Here is the call graph for this function:

◆ mul() [2/2]

void AurynVectorFloat::mul ( AurynVectorFloat v)
157 {
158  check_size(v);
159 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
160  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
161  data[0:size:1] = data[0:size:1] * v->data[0:v->size:1];
162  #else
163  float * bd = v->data;
164  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
165  {
166  __m128 chunk_a = sse_load( i );
167  __m128 chunk_b = sse_load( bd ); bd+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
168  __m128 result = _mm_mul_ps(chunk_a, chunk_b);
169  sse_store( i, result );
170  }
171  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
172 #else
173  for ( NeuronID i = 0 ; i < size ; ++i ) {
174  data[i] *= v->data[i];
175  }
176 #endif
177 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ resize()

void AurynVectorFloat::resize ( NeuronID  new_size)
virtual

resize data array to new_size

The function tries to preserve data while resizing. If a vector is downsized elements at the end are simply dropped. When the vector size is increased the new elements at the end are intialized with zeros.

Reimplemented from auryn::AurynVector< float, NeuronID >.

Reimplemented in auryn::AurynDelayVector.

64 {
65 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
67  const NeuronID div = new_size/SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; // rounds down
68  new_size = (div+1)*SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS; // is multiple of SIMD...
69  }
70 #endif /* CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY */
71  super::resize(new_size);
72 }
void div(const float a)
Element-wise division.
Definition: AurynVector.h:322
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
virtual void resize(NeuronID new_size)
resize data array to new_size
Definition: AurynVector.h:184
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ saxpy()

void AurynVectorFloat::saxpy ( const float  a,
AurynVectorFloat x 
)
97 {
98  check_size(x);
99 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
100  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
101  data[0:size:1] = a * x->data[0:x->size:1] + data[0:size:1];
102  #else
103  float * xp = x->data;
104  const __m128 alpha = _mm_set1_ps(a);
105  for ( float * i = data ; i < data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
106  {
107  __m128 chunk = sse_load( xp ); xp += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
108  __m128 result = _mm_mul_ps( alpha, chunk );
109 
110  chunk = sse_load( i );
111  result = _mm_add_ps( result, chunk );
112  sse_store( i, result );
113  }
114  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
115 #else
116  for ( NeuronID i = 0 ; i < size ; ++i ) {
117  data[i] += a * x->data[i];
118  }
119 #endif
120 }
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ scale()

void AurynVectorFloat::scale ( const float  a)
75 {
76 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
77  #ifdef CODE_ACTIVATE_CILK_INSTRUCTIONS
78  data[0:size:1] = a * data[0:size:1];
79  #else
80  const __m128 scalar = _mm_set1_ps(a);
81  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
82  {
83  __m128 chunk = sse_load( i );
84  __m128 result = _mm_mul_ps(chunk, scalar);
85  sse_store( i, result );
86  }
87  #endif /* CODE_ACTIVATE_CILK_INSTRUCTIONS */
88 #else
89  for ( NeuronID i = 0 ; i < size ; ++i ) {
90  data[i] *= a;
91  }
92 #endif /* CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY */
93 }
float * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
unsigned int NeuronID
NeuronID is an unsigned integeger type used to index neurons in Auryn.
Definition: auryn_definitions.h:151
Here is the call graph for this function:

◆ sum() [1/2]

void AurynVectorFloat::sum ( AurynVectorFloat a,
AurynVectorFloat b 
)
227 {
228  check_size(a);
229  check_size(b);
230 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
231  float * ea = a->data;
232  float * eb = b->data;
233  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
234  {
235  __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
236  __m128 chunk_b = sse_load( eb ); eb+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
237  __m128 result = _mm_add_ps(chunk_a, chunk_b);
238  sse_store( i, result );
239  }
240 #else
241  AurynVector::sum(a,b);
242 #endif
243 }
void sum(AurynVector *a, AurynVector *b)
Computes the sum a+b and stores the result in this instance.
Definition: AurynVector.h:479
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
Here is the call graph for this function:

◆ sum() [2/2]

void AurynVectorFloat::sum ( AurynVectorFloat a,
const float  b 
)
246 {
247  check_size(a);
248 #ifdef CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY
249  float * ea = a->data;
250  const __m128 scalar = _mm_set1_ps(b);
251  for ( float * i = data ; i != data+size ; i += SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS )
252  {
253  __m128 chunk_a = sse_load( ea ); ea+=SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS;
254  __m128 result = _mm_add_ps(chunk_a, scalar);
255  sse_store( i, result );
256  }
257 #else
258  AurynVector::sum(a,b);
259 #endif
260 }
void sum(AurynVector *a, AurynVector *b)
Computes the sum a+b and stores the result in this instance.
Definition: AurynVector.h:479
void check_size(NeuronID x)
Checks if argument is larger than size and throws and exception if so.
Definition: AurynVector.h:78
T * data
Pointer to the array housing the data.
Definition: AurynVector.h:154
NeuronID size
Size of the vector.
Definition: AurynVector.h:151
__m128 sse_load(float *i)
Definition: AurynVector.cpp:32
void sse_store(float *i, __m128 d)
Definition: AurynVector.cpp:41
#define SIMD_NUM_OF_PARALLEL_FLOAT_OPERATIONS
Use Intel Cilk Plus – only has an effect when CODE_USE_SIMD_INSTRUCTIONS_EXPLICITLY is enabled...
Definition: auryn_definitions.h:64
Here is the call graph for this function:

The documentation for this class was generated from the following files: