Usage Guidelines: Function Calls and
Function calls are a commonly used programming construct. Follow these simple guidelines when using SDLT containers:
- If an SDLT Primitive is passed to a function by value, by pointer, or by reference, be sure to inline them
- Any Non-inlined functions should be SIMD enabled (for example, marke them with #pragma omp declare simd).
If a loop variable is passed to a non-inlined function, the current C++ Application Binary Interface (ABI) requires the memory layout match object's original which could cause additional data transformations or inhibit vectorization. For that reason, the SDLT approach works best when all the methods or functions called are inlined or use
#pragma omp declare simd. Marking a function "inline" explicitly or implicitly is only a hint. Compilers have several limits and heuristics that could cause a function to not be inlined. To avoid this issue, we recommend utilizing the
#pragma forceinline recursivewhich instructs the compiler to ignore its limits and heuristics: causing all functions in the following code block that could be inlined to actually be inlined together with any functions called, and functions they call, and so on. Please also note that this can cause the loop body and/or the function body to become too big to optimize. Under such circumstances, carefully examine and restructure the function call boundaries and consider applying non-inlined, SIMD-enabled function calls.
1-Dimensional Containers Overview
What if that
std::vector<typename>could store data SIMD-friendly format internally while exposing an AOS view to the programmer?
The 1-dimensional containers in SDLT aim to achieve that goal. They can abstract the in-memory data layout of an array of objects to:
1. AOS (Array of Structures)
2. SOA (Structure of Arrays) which is SIMD friendly
As the memory layout is abstracted and may not match the original structure’s layout, containers cannot provide memory references to the underlying data. Only import or export of the object to and from a particular element in the container. In use, an algorithm might require some minor code changes to follow import/export paradigm, however algorithm itself should read/flow the same.
The 1D containers in SDLT are dynamically resizable with an interface similar to
std::vector<T>. To avoid accidental misuse of copying containers into C++11 lambda functions we chose to delete the container’s copy constructor and instead provide explicit “clone” method instead.
Containers provide SDLT concepts of an accessor and const_accessor for use with SIMD loops, interfaces for
std::vectorcompatibility are intended for ease of integration, not high performance.
std::vector, the containers own the array data and its scope controls the life of that data.
n-Dimensional Containers Overview
Multi-dimensional containers generalize ideas from 1-di