For reference: A purely stack-based aggregation yields 114 baggs*/sec single threaded and 360 baggs/sec multi-threaded (code below).
Let's assume this is the max. performance we can gain from the CPU. Then we are still factor 10+ away from the 8 baggs/sec we get on a heap/main memory bound aggregation.
Isn't that a prove that only the main memory interaction is slowing things down? Meaning, the 65GB throughput limit on a 100GB M2 chip is more or less the factual limit that can be achieved?
#pragma omp simd reduction(+:sum) simdlen(8)
for (int l = 0; l < loops; l++) {
sum += sum_array_simd(array, 16);
}
...
double sum_array_simd(double *array, size_t size) {
float64x2_t sum_vec = vdupq_n_f64(0.0); // Initialize SIMD vector to zero
for (size_t i = 0; i < size; i += 2) {
float64x2_t vec = vld1q_f64(&array[i]);
sum_vec = vaddq_f64(sum_vec, vec);
}
double result[2];
vst1q_f64(result, sum_vec);
return result[0] + result[1];
}
*baggs = billion aggregations