Poplar and PopLibs
FieldTypeTraits.hpp
1// Copyright (c) 2018 Graphcore Ltd. All rights reserved.
2#ifndef poplar_FieldTypeTraits_hpp_
3#define poplar_FieldTypeTraits_hpp_
4
5#include <poplar/FieldTypes.hpp>
6
7namespace poplar {
8// VectorLayout traits
9template <VectorLayout L> struct VectorLayoutTraits {
10 constexpr static unsigned MinAlign = 1;
11};
12template <> struct VectorLayoutTraits<VectorLayout::SCALED_PTR32> {
13 constexpr static unsigned MinAlign = 4;
14};
15template <> struct VectorLayoutTraits<VectorLayout::SCALED_PTR64> {
16 constexpr static unsigned MinAlign = 8;
17};
18
19// VectorListLayout traits
20template <class T, VectorListLayout L> struct VectorListLayoutTraits {
21 constexpr static unsigned MinAlign = 1;
22};
23template <class T>
24struct VectorListLayoutTraits<T, VectorListLayout::SCALED_PTR32> {
25 constexpr static unsigned MinAlign = 4;
26};
27template <class T>
28struct VectorListLayoutTraits<T, VectorListLayout::SCALED_PTR64> {
29 constexpr static unsigned MinAlign = 8;
30};
31template <class T>
32struct VectorListLayoutTraits<T, VectorListLayout::DELTANELEMENTS> {
33 constexpr static unsigned MinAlign = sizeof(T);
34};
35} // namespace poplar
36
37#endif // poplar_FieldTypeTraits_hpp_
Poplar classes and functions.
Definition: ArrayRef.hpp:14
VectorListLayout
The memory layout used for a VectorList.
Definition: FieldTypes.hpp:57
@ DELTANELEMENTS
A top-level structure with a 21-bit pointer to the base of the vector data, a 16 bit count for the nu...
VectorLayout
The memory layout used for a Vector.
Definition: FieldTypes.hpp:11
@ SCALED_PTR32
Similar to ONE_PTR, but this uses a compressed 16-bit pointer containing bits 2-17 of the offset from...
@ SCALED_PTR64
Similar to ONE_PTR, but this uses a compressed 16-bit pointer containing bits 3-18 of a full pointer.