OpenLB 1.7
Loading...
Searching...
No Matches
Classes | Functions | Variables
olb::cpu::simd Namespace Reference

Implementations of vector CPU specifics. More...

Classes

class  Cell
 Implementation of the Cell concept for vectorized collision operators. More...
 
class  Column
 Plain column for SIMD CPU targets. More...
 
class  ConcreteDynamics
 Implementation of cpu::Dynamics for concrete DYNAMICS on SIMD blocks. More...
 
class  CyclicColumn
 Virtual memory based cyclic column for usage in ColumnVector. More...
 
class  FieldPtr
 SIMD-specific pointer to a pack of rows of a D-dimensional field. More...
 
class  Mask
 
class  Mask< double >
 
class  Mask< float >
 
class  Pack
 
class  Pack< double >
 
class  Pack< float >
 

Functions

template<typename T >
Pack< T > pow (Pack< T > base, Pack< T > exp)
 
template<typename T >
Pack< T > min (Pack< T > rhs, Pack< T > lhs)
 
template<typename T >
Pack< T > max (Pack< T > rhs, Pack< T > lhs)
 
template<typename T >
Pack< T > fabs (Pack< T > x)
 
template<typename T >
void maskstore (T *target, Mask< T > mask, Pack< T > value)
 
template<>
void maskstore< double > (double *target, Mask< double > mask, Pack< double > value)
 
template<>
void maskstore< float > (float *target, Mask< float > mask, Pack< float > value)
 
template<typename T >
void store (T *target, Pack< T > value)
 
template<>
void store< double > (double *target, Pack< double > value)
 
template<>
void store< float > (float *target, Pack< float > value)
 
template<typename T >
void store (T *target, Pack< T > value, const typename Pack< T >::index_t *indices)
 
template<>
void store< double > (double *target, Pack< double > value, const Pack< double >::index_t *indices)
 
template<>
void store< float > (float *target, Pack< float > value, const Pack< float >::index_t *indices)
 
template<>
void maskstore< double > (double *target, Mask< double > mask, Pack< double > value)
 
template<>
void maskstore< float > (float *target, Mask< float > mask, Pack< float > value)
 
template<>
void store< double > (double *target, Pack< double > value)
 
template<>
void store< float > (float *target, Pack< float > value)
 
template<>
void store< double > (double *target, Pack< double > value, const Pack< double >::index_t *indices)
 
template<>
void store< float > (float *target, Pack< float > value, const Pack< float >::index_t *indices)
 
template<typename T >
std::size_t getPageAlignedCount (std::size_t count)
 
template<typename T , typename S >
Pack< T > operator+ (S lhs, Pack< T > rhs)
 
template<typename T , typename S >
Pack< T > operator+ (Pack< T > lhs, S rhs)
 
template<typename T , typename S >
Pack< T > operator- (S lhs, Pack< T > rhs)
 
template<typename T , typename S >
Pack< T > operator- (Pack< T > lhs, S rhs)
 
template<typename T , typename S >
Pack< T > operator* (Pack< T > lhs, S rhs)
 
template<typename T , typename S >
Pack< T > operator* (S lhs, Pack< T > rhs)
 
template<typename T , typename S >
Pack< T > operator/ (Pack< T > lhs, S rhs)
 
template<typename T , typename S >
Pack< T > operator/ (S lhs, Pack< T > rhs)
 
template<typename T >
Pack< T > sqrt (Pack< T > x)
 

Variables

const int PROT_RW = PROT_READ | PROT_WRITE
 

Detailed Description

Implementations of vector CPU specifics.

Function Documentation

◆ fabs()

template<typename T >
Pack< T > olb::cpu::simd::fabs ( Pack< T > x)

Definition at line 426 of file 256.h.

427{
428 return max(x, -x);
429}
Pack< T > max(Pack< T > rhs, Pack< T > lhs)
Definition 256.h:416

References max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPageAlignedCount()

template<typename T >
std::size_t olb::cpu::simd::getPageAlignedCount ( std::size_t count)

Definition at line 134 of file column.h.

135{
136 const std::size_t page_size = sysconf(_SC_PAGESIZE);
137 const std::size_t size = ((count * sizeof(T) - 1) / page_size + 1) * page_size;
138 const std::size_t volume = size / sizeof(T);
139
140 if (size % page_size != 0) {
141 throw std::invalid_argument("Buffer size must be multiple of PAGE_SIZE");
142 }
143
144 return volume;
145};

◆ maskstore()

template<typename T >
void olb::cpu::simd::maskstore ( T * target,
Mask< T > mask,
Pack< T > value )
+ Here is the caller graph for this function:

◆ maskstore< double >() [1/2]

template<>
void olb::cpu::simd::maskstore< double > ( double * target,
Mask< double > mask,
Pack< double > value )

Definition at line 435 of file 256.h.

436{
437 _mm256_maskstore_pd(target, mask, value);
438}

◆ maskstore< double >() [2/2]

template<>
void olb::cpu::simd::maskstore< double > ( double * target,
Mask< double > mask,
Pack< double > value )

Definition at line 391 of file 512.h.

392{
393 _mm512_mask_storeu_pd(target, mask, value);
394}

◆ maskstore< float >() [1/2]

template<>
void olb::cpu::simd::maskstore< float > ( float * target,
Mask< float > mask,
Pack< float > value )

Definition at line 441 of file 256.h.

442{
443 _mm256_maskstore_ps(target, mask, value);
444}

◆ maskstore< float >() [2/2]

template<>
void olb::cpu::simd::maskstore< float > ( float * target,
Mask< float > mask,
Pack< float > value )

Definition at line 397 of file 512.h.

398{
399 _mm512_mask_storeu_ps(target, mask, value);
400}

◆ max()

template<typename T >
Pack< T > olb::cpu::simd::max ( Pack< T > rhs,
Pack< T > lhs )

Definition at line 416 of file 256.h.

417{
418 if constexpr (std::is_same_v<T,double>) {
419 return _mm256_max_pd(rhs, lhs);
420 } else {
421 return _mm256_max_ps(rhs, lhs);
422 }
423}
+ Here is the caller graph for this function:

◆ min()

template<typename T >
Pack< T > olb::cpu::simd::min ( Pack< T > rhs,
Pack< T > lhs )

Definition at line 406 of file 256.h.

407{
408 if constexpr (std::is_same_v<T,double>) {
409 return _mm256_min_pd(rhs, lhs);
410 } else {
411 return _mm256_min_ps(rhs, lhs);
412 }
413}
+ Here is the caller graph for this function:

◆ operator*() [1/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator* ( Pack< T > lhs,
S rhs )

Definition at line 64 of file pack.h.

65{
66 return lhs * Pack<T>(rhs);
67}

◆ operator*() [2/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator* ( S lhs,
Pack< T > rhs )

Definition at line 70 of file pack.h.

71{
72 return Pack<T>(lhs) * rhs;
73}

◆ operator+() [1/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator+ ( Pack< T > lhs,
S rhs )

Definition at line 46 of file pack.h.

47{
48 return lhs + Pack<T>(rhs);
49}

◆ operator+() [2/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator+ ( S lhs,
Pack< T > rhs )

Definition at line 40 of file pack.h.

41{
42 return Pack<T>(lhs) + rhs;
43}

◆ operator-() [1/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator- ( Pack< T > lhs,
S rhs )

Definition at line 58 of file pack.h.

59{
60 return lhs - Pack<T>(rhs);
61}

◆ operator-() [2/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator- ( S lhs,
Pack< T > rhs )

Definition at line 52 of file pack.h.

53{
54 return Pack<T>(lhs) - rhs;
55}

◆ operator/() [1/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator/ ( Pack< T > lhs,
S rhs )

Definition at line 76 of file pack.h.

77{
78 return lhs / Pack<T>(rhs);
79}

◆ operator/() [2/2]

template<typename T , typename S >
Pack< T > olb::cpu::simd::operator/ ( S lhs,
Pack< T > rhs )

Definition at line 82 of file pack.h.

83{
84 return Pack<T>(lhs) / rhs;
85}

◆ pow()

template<typename T >
Pack< T > olb::cpu::simd::pow ( Pack< T > base,
Pack< T > exp )

Definition at line 395 of file 256.h.

396{
397 // TODO: Replace by more efficient implementation
398 Pack<T> result;
399 for (unsigned i=0; i < Pack<T>::size; ++i) {
400 result[i] = util::pow(base[i], exp[i]);
401 }
402 return result;
403}

References olb::util::pow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sqrt()

template<typename T >
Pack< T > olb::cpu::simd::sqrt ( Pack< T > x)

Definition at line 88 of file pack.h.

89{
90 return x.sqrt();
91}

◆ store() [1/2]

template<typename T >
void olb::cpu::simd::store ( T * target,
Pack< T > value )
+ Here is the caller graph for this function:

◆ store() [2/2]

template<typename T >
void olb::cpu::simd::store ( T * target,
Pack< T > value,
const typename Pack< T >::index_t * indices )

◆ store< double >() [1/4]

template<>
void olb::cpu::simd::store< double > ( double * target,
Pack< double > value )

Definition at line 451 of file 256.h.

452{
453 _mm256_storeu_pd(target, value);
454}

◆ store< double >() [2/4]

template<>
void olb::cpu::simd::store< double > ( double * target,
Pack< double > value )

Definition at line 407 of file 512.h.

408{
409 _mm512_storeu_pd(target, value);
410}

◆ store< double >() [3/4]

template<>
void olb::cpu::simd::store< double > ( double * target,
Pack< double > value,
const Pack< double >::index_t * indices )

Definition at line 467 of file 256.h.

468{
469#ifdef __AVX512F__
470 _mm256_i32scatter_pd(target, _mm_loadu_si128(reinterpret_cast<const __m128i*>(indices)), value, sizeof(double));
471#else
472 __m256d reg = value;
473 for (unsigned i=0; i < simd::Pack<double>::size; ++i) {
474 target[indices[i]] = reg[i];
475 }
476#endif
477}

◆ store< double >() [4/4]

template<>
void olb::cpu::simd::store< double > ( double * target,
Pack< double > value,
const Pack< double >::index_t * indices )

Definition at line 423 of file 512.h.

424{
425 _mm512_i32scatter_pd(target, _mm256_loadu_si256(reinterpret_cast<const __m256i*>(indices)), value, sizeof(double));
426}

◆ store< float >() [1/4]

template<>
void olb::cpu::simd::store< float > ( float * target,
Pack< float > value )

Definition at line 457 of file 256.h.

458{
459 _mm256_storeu_ps(target, value);
460}

◆ store< float >() [2/4]

template<>
void olb::cpu::simd::store< float > ( float * target,
Pack< float > value )

Definition at line 413 of file 512.h.

414{
415 _mm512_storeu_ps(target, value);
416}

◆ store< float >() [3/4]

template<>
void olb::cpu::simd::store< float > ( float * target,
Pack< float > value,
const Pack< float >::index_t * indices )

Definition at line 480 of file 256.h.

481{
482#ifdef __AVX512F__
483 _mm256_i32scatter_ps(target, _mm256_loadu_si256(reinterpret_cast<const __m256i*>(indices)), value, sizeof(float));
484#else
485 __m256 reg = value;
486 for (unsigned i=0; i < simd::Pack<float>::size; ++i) {
487 target[indices[i]] = reg[i];
488 }
489#endif
490}

◆ store< float >() [4/4]

template<>
void olb::cpu::simd::store< float > ( float * target,
Pack< float > value,
const Pack< float >::index_t * indices )

Definition at line 430 of file 512.h.

431{
432 _mm512_i32scatter_ps(target, _mm512_loadu_si512(reinterpret_cast<const __m512i*>(indices)), value, sizeof(float));
433}

Variable Documentation

◆ PROT_RW

const int olb::cpu::simd::PROT_RW = PROT_READ | PROT_WRITE

Definition at line 131 of file column.h.