#include <LoopUnroller.h>
Public Member Functions | |
void | _add (double *d, const double *a) |
double | _dot (const double *d, const double *v) |
void | _mul (double *d, const double s) |
void | _neg (double *d, const double *a) |
void | _sub (double *d, const double *a) |
double | _sum2 (const double *d) |
void | _zero (double *d) |
Static Public Member Functions | |
static void | _add (double *d, const double *v) |
Add v to d. More... | |
static double | _dot (const double *d, const double *v) |
Dot product of d and v Same as r=0.0; for(unsigned i=0;i<n;i++) r+=d[i]*v[i]; return r; More... | |
static void | _mul (double *d, const double s) |
Multiply d by s. More... | |
static void | _neg (double *d, const double *v) |
Set d to -v. More... | |
static void | _sub (double *d, const double *v) |
Subtract v from d. More... | |
static double | _sum2 (const double *d) |
Squared modulo of d; Same as r=0.0; for(unsigned i=0;i<n;i++) r+=d[i]*d[i]; return r; More... | |
static void | _zero (double *d) |
Set to zero. More... | |
Utiliy class for loop unrolling.
Many c++ compilers do not unroll small loops such as those used in the PLMD::Vector and PLMD::Tensor classes. This class provides methods to perform basic vector operations with unrolled loops. The methods work on double* so that they can be used in principles in other places of the code, but they are designed to be used in PLMD::Vector and PLMD::Tensor .
In case in the future we see that some compiler better optimize explicit loops, it should be easy to replace the methods here with loops. Alternatively, we could provide two paths using a cpp macro (e.g. __PLUMED_UNROLL_LOOPS or so).
All the methods for class LoopUnroller<n> act on n elements. Implementation is made using template metaprogramming, that is:
Here xxx is any of the methods of the class.
|
inline |
|
static |
Add v to d.
Same as for(unsigned i=0;i<n;i++) d[i]+=v[i];
|
static |
Dot product of d and v Same as r=0.0; for(unsigned i=0;i<n;i++) r+=d[i]*v[i]; return r;
|
inline |
|
static |
Multiply d by s.
Same as for(unsigned i=0;i<n;i++) d[i]*=s;
|
inline |
|
inline |
|
static |
Set d to -v.
Same as for(unsigned i=0;i<n;i++) d[i]=-v[i];
|
inline |
|
static |
Subtract v from d.
Same as for(unsigned i=0;i<n;i++) d[i]-=v[i];
|
static |
Squared modulo of d; Same as r=0.0; for(unsigned i=0;i<n;i++) r+=d[i]*d[i]; return r;
|
inline |
|
static |
Set to zero.
Same as for(unsigned i=0;i<n;i++) d[i]=0.0;
|
inline |
Hosted by GitHub
![]() |
![]() |