InsightSoftwareConsortium / InsightSoftwareConsortium/ITK

[Feature Request] Align::[Adaptive/Element/Vector] mode and use std::array as FixedArray

Open
#5,034 2 comments 1 reaction 0 assignees View on GitHub
type:Enhancement
Dominant language
C++
Stars
1.7k
Forks
748
Avg merge
1d 1h
Merged PRs (30d)
64

Description

### Description

Add SIMD compatible alignment support to FixedArray based types and use std::array.

```cpp
#include
#include
#include
#include
#include
#include

enum class Align
{
Adaptive = 0,
Element = 1,
Vector = 2,
}

template(VLength)>
struct alignas(((VLength == VLengthPow2) && (VAlign != Align::Element)) || (VAlign == Align::Vector) ? VLengthPow2 * sizeof(T) : sizeof(T)) FixedArray : std::array
{
};

FixedArray a = {1,2,3};
FixedArray b = {1,2,3};
FixedArray c = {1,2,3,4};
FixedArray d = {1,2,3,4};

printf("%02zu/%zu\n", alignof(a), sizeof(a));
printf("%02zu/%zu\n", alignof(b), sizeof(b));
printf("%02zu/%zu\n", alignof(c), sizeof(c));
printf("%02zu/%zu\n", alignof(d), sizeof(d));

```
### Expected Behavior

```sh
4/12
16/16
4/16
16/16
```
### Current behavior

```sh
Align::Element = alignas(sizeof(T))/(sizeof(T)*VLength);
```
### Additional Information
- [mlr](https://github.com/jopadan/mlr)
- [TrenchBroom/vm - detailed explanation of the proposed code changes](https://github.com/TrenchBroom/TrenchBroom/issues/4721)
- [vnl issue of these changes](https://github.com/vxl/vxl/issues/967)
- std::md[span/array] fixed static extents support for arithmetic vector based types adding splice/slice

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.