OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
DimensionPadding.hpp
Go to the documentation of this file.
1#pragma once
2
5
6template<class T>
8{
9 auto properties = SystemProperties::GetInstance();
10 int bitsPerByte = 8;
11 if (alignment == AVX512 && properties.CPUSupportsAVX512())
12 {
13 _alignment = AVX512;
14 // Sizeof gives number of bytes, alignments are given in bit
15 _lengthOfIntrinsicVector = static_cast<int>(AVX512) / (sizeof(T) * bitsPerByte);
16 _degreesOfFreedomPadded = static_cast<index_t>(_lengthOfIntrinsicVector) * static_cast<index_t>(ceilf(degreesOfFreedom / static_cast<float>(_lengthOfIntrinsicVector)));
17 _numberOfIntrinsicVectors = _degreesOfFreedomPadded / _lengthOfIntrinsicVector;
18
19 _numberOfPaddedEntries = static_cast<int>(_degreesOfFreedomPadded - degreesOfFreedom);
20 }
21 else if ((alignment == AVX2|| alignment == AVX512) && properties.CPUSupportsAVX2())
22 {
23 _alignment = AVX2;
24 // Sizeof gives number of bytes, alignments are given in bit
25 _lengthOfIntrinsicVector = static_cast<int>(AVX2) / (sizeof(T) * bitsPerByte);
26 _degreesOfFreedomPadded = static_cast<index_t>(_lengthOfIntrinsicVector) * static_cast<index_t>(ceilf(degreesOfFreedom / static_cast<float>(_lengthOfIntrinsicVector)));
27 _numberOfIntrinsicVectors = _degreesOfFreedomPadded / _lengthOfIntrinsicVector;
28
29 _numberOfPaddedEntries = static_cast<int>(_degreesOfFreedomPadded - degreesOfFreedom);
30 }
31 else //AVX or lower currently not supported (not planned to be)
32 {
33 _lengthOfIntrinsicVector = 1;
34 _degreesOfFreedomPadded = degreesOfFreedom;
35 _alignment = CacheLine64;
36 return;
37 }
38 _masks.reset(new IntrinsicMasks(_numberOfIntrinsicVectors, _lengthOfIntrinsicVector, _numberOfPaddedEntries));
39}
Alignment
Definition Allignments.h:3
@ AVX2
Definition Allignments.h:3
@ AVX512
Definition Allignments.h:3
@ CacheLine64
Definition Allignments.h:3
int64_t index_t
Definition SystemDependentDefines.h:13
DimensionPadding(Alignment alignment, index_t degreesOfFreedom)
Definition DimensionPadding.hpp:7
Definition IntrinsicMasks.h:6
static const SystemProperties & GetInstance()
Definition SystemProperties.h:28