Source

Branch

1/ @Waffl3x

Use OpenMP :^)
Target region, map the memory, use parallel for with a reduction clause, yell at my compiler vendor if it fails to vectorize.
Or just use Fortran (also with OpenMP).

Answer changes if you need non-overflowing semantics. I am honestly not sure how I would do it efficiently in a scenario that effectively needs a bigint.

I imagine you chunk it in such a way that lets you use native width ints for the largest proportion of the calculation possible

2/ @AgileJebrim

@Waffl3x

OpenMP is for CPUs and isn’t really designed for the realtime workflows we require. ISPC would be better and actually has hard guarantees about vectorization.

Our earlier tech was built on top of ISPC. Our next gen tech is in a custom shader language built for GPU-native apps.

3/ @AgileJebrim

@Waffl3x

The goal should be to avoid BIGINT and have the input values be defined as smaller bitwidths instead.

4/ @Waffl3x

@AgileJebrim

Mmm I can see it, also I suppose bigint isn’t necessary anyway, 128bit is almost certainly goof enough for a sum… I hope.

5/ @AgileJebrim

@Waffl3x

https://x.com/agilejebrim/status/2058562643158352101?s=46&t=ZbNecpPBsBMrvteeaA6IcA

6/ @Waffl3x

@AgileJebrim

My mental model for this was off, it really does fit in a 32bit unsigned huh? OpenMP does this efficiently trivially I’m pretty sure, but that’s just because it’s such a simple case. So my answer really isn’t useful for the interviewer.