Developer Guide and Reference

Contents

Example 3

Example 3 demonstrates the declaration of a Structure of Arrays (SoA) interacting with a forward dependency.
#include <stdio.h> #include <sdlt/primitive.h> #include <sdlt/soa1d_container.h> #define N 1024 typedef struct RGBs { float r; float g; float b; } RGBTy; SDLT_PRIMITIVE(RGBTy, r, g, b) void main() { // RGBTy a[N]; // AOS data layout sdlt::soa1d_container<RGBTy> aContainer(N); auto a = aContainer.access(); // SOA data layout // use SDLT access method to access struct members r, g, and b. // with unit-stride access after vectorization #pragma omp simd for (int k = 0; k<N; k++) { a[k].r() = k*1.5; a[k].g() = k*2.5; a[k].b() = k*3.5; } // Test forward-dependency on SOA memory access #pragma omp simd for (int i = 0; i<N - 1; i++) { sdlt::linear_index k(i); a[k].r() = a[k + 1].r() + k*1.5; a[k].g() = a[k + 1].g() + k*2.5; a[k].b() = a[k + 1].b() + k*3.5; } std::cout << "k =" << 10 << ", a[k].r =" << a[10].r() << ", a[k].g =" << a[10].g() << ", a[k].b =" << a[10].b() << std::endl; }

Product and Performance Information

1

Intel's compilers may or may not optimize to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include SSE2, SSE3, and SSSE3 instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors. Certain optimizations not specific to Intel microarchitecture are reserved for Intel microprocessors. Please refer to the applicable product User and Reference Guides for more information regarding the specific instruction sets covered by this notice.

Notice revision #20110804