mrc-ide / odin.dust

Compile odin to dust
https://mrc-ide.github.io/odin.dust
Other
3 stars 1 forks source link

Use unsigned integers in for loops #47

Closed johnlees closed 3 years ago

johnlees commented 3 years ago

We now use size_t <-> int casts to avoid compiler warnings

I wasn't sure what assembly actually results from these casts and looked it up:

The CUDA guide advises us to use unsigned integers for loops (as apparently the overflow is better defined and easier/quicker to deal with). So maybe we should just use uints?

Originally posted by @johnlees in https://github.com/mrc-ide/sircovid/issues/179#issuecomment-752068907

richfitz commented 3 years ago

CUDA suggests signed integers (https://docs.nvidia.com/cuda/cuda-c-best-practices-guide/index.html#loop-counters-signed-vs-unsigned) so I think we should leave as is