Presentation for NextGenTrigger

Introductory Example for AoS

struct Point { float x, y, z; };

template <int N>
using AoS = Point[N];

template <int N>
void sum(AoS<N> p) {
  for (int i = 0; i < N; ++i) {
    p[i].z = p[i].x + p[i].y + p[i].z;
  }
}

int main() {
  AoS<2> p = {{1, 2, 3}, {1, 2, 3}};
  sum(p);
  return 0;
}

 

Introductory Example for SoA

template <int N>
struct SoA {
  int x[N], y[N], z[N];
};

template <int N>
void sum(SoA<N> p) {
  for (int i = 0; i < N; ++i) {
    p.z[i] = p.x[i] + p.y[i] + p.z[i];
  }
}

int main() {
  SoA<2> p = {{1, 1}, {2, 2}, {3, 3}};
  sum(p);
  return 0;
}