UoB-HPC / BabelStream

STREAM, for lots of devices written in many programming models
Other
313 stars 109 forks source link

Always use the correct numeric type for all kernels #134

Closed tom91136 closed 8 months ago

tom91136 commented 1 year ago

There are several instances where the double constant 0.0 is used in a way that promotes everything it touches. For example: https://github.com/UoB-HPC/BabelStream/blob/1d423fc70dd573b528ee43f521401277731b443a/src/std-data/STDDataStream.cpp#L85

In this case, the value is used on a templated function where the deducted type is based on that constant, so the kernel essentially gets fixed to double precision and not T.

There are several other models that does T sum = 0.0; which is probably OK. But for consistency I think we should probably be using aggregate initialisation for everything:

std::transform_reduce(..., T{}); 
T sum{};  
tomdeakin commented 11 months ago

LGTM, apply this (with a comment in the code)