The Argon library provides several vectorized views for processing data using SIMD operations. These views work with contiguous ranges and provide iterator-based access to the vectorized data.
Vectorized read (vectorize::load)
The load view presents a read-only view of a contiguous set of data (i.e. a std::ranges::input_range). Load is lazy, and occurs only on dereference (and on every dereference, as it is not memoized).
#include <argon/vectorize/load.hpp>
#include <array>
int main() {
std::array<int32_t, 512> data;
data.fill(5);
}
}
A view that loads data from a contiguous range into SIMD vectors.
Definition load.hpp:36
Vectorized write (vectorize::store)
The store presents a write-only view of a contiguous set of data (i.e. a std::ranges::output_range). StoreTo is lazy, and occurs only on incrementing or decrementing the iterator.
#include <argon/vectorize/store.hpp>
#include <array>
int main() {
std::array<int32_t, 512> data;
data.fill(0);
vec = {1, 2, 3, 4};
}
}
Vectorized In-place Read/Write (vectorize::load_store)
The load_store view allows you to process data in-place using SIMD operations. Internally, a vector is stored in the iterator that is loaded on creation, and then stored on increment, before the next element is loaded. Dereferencing accesses the internal stored vector, and will not Load again without a manual .reload() call.
Note: If you do not need both read and write on the same range, use either vectorize::load or vectorize::store instead, as vectorize::load_store incurs the read latency and writeback penalty of them combined.
#include <argon/vectorize.hpp>
#include <array>
int main() {
std::array<int32_t, 512> data;
data.fill(5);
vec = vec + 1;
}
}
A SIMD vectorized view of a range of data.
Definition load_store.hpp:26
Interleaved Data Access
For working with interleaved data (like RGB values), Argon provides specialized views:
Loading Interleaved Data
#include <argon/vectorize/load.hpp>
#include <array>
int main() {
std::array<int32_t, 512> data;
}
}
Definition load_interleaved.hpp:15
Storing Interleaved Data
#include <argon/vectorize/store.hpp>
#include <array>
int main() {
std::array<int32_t, 512> data;
even = {0, 2, 4, 6};
odd = {1, 3, 5, 7};
}
}
Definition store_interleaved.hpp:15
Key Features
- All views work with contiguous ranges (arrays, vectors, spans)
- Automatic alignment and size handling
- Efficient SIMD operations through Argon's SIMD wrappers
- Iterator-based interface compatible with C++ ranges
- Support for different data types (int32_t, float, etc.)
Notes
- The number of elements processed in each iteration depends on the SIMD vector size for the target architecture
- Data size should ideally be aligned to the SIMD vector size
- Non-aligned sizes are handled automatically (remaining elements are not processed)
- Interleaved operations support strides of 2, 3, or 4
Error Handling
The views handle common errors gracefully:
- Non-contiguous ranges: Will not compile
- Invalid strides: Static assertions prevent invalid stride values
- Misaligned sizes: Automatically handled by processing only aligned portions