Developer Guide and Reference


Example 2

Example 2 demonstrates use of nested primitives and the use of an accessor inside a SIMD loop to generate efficient code.
#include <stdio.h> #include <sdlt/sdlt.h> #define N 1024 typedef struct XYZs { float x; float y; float z; } XYZTy; SDLT_PRIMITIVE(XYZTy, x, y, z) typedef struct RGBs { float r; float g; float b; XYZTy w; } RGBTy; SDLT_PRIMITIVE(RGBs, r, g, b, w) void main() { sdlt::soa1d_container<RGBTy> aContainer(N); auto a = aContainer.access(); #pragma omp simd for (int k = 0; k<N; k++) { RGBTy c; c.r = k*1.5f; c.g = k*2.5f; c.b = k*3.5f; c.w.x = k*4.5f; c.w.y = k*5.5f; c.w.z = k*6.5f; a[k] = c; } const RGBTy c = a[10]; printf("k = %d, a[k].r = %f, a[k].g = %f, a[k].b = %f \n", 10, c.r, c.g, c.b); printf("k = %d, a[k].w.x = %f, a[k].w.y = %f, a[k].w.z = %f \n", 10, c.w.x, c.w.y, c.w.z);

Product and Performance Information


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