Timeline for Mirrors number at borders of interval, untill it lays in the interval
Current License: CC BY-SA 4.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 22, 2019 at 16:34 | comment | added | Quuxplusone |
You might also consider special-casing when period is a power of 2, which means that x % period is x & mask for some integer mask . (Except that of course period is never a power of 2 with your current code! I still suspect that that -1 is a bug.) For the quite real benefits of branching around an expensive division, see also Chandler Carruth's keynote from CppCon 2015, "Tuning C++."
|
|
Mar 22, 2019 at 9:29 | comment | added | user186243 | thanks for the good advice. Dividing is not cheap on gpu, therefor I added an check, that the index is not in the interval to avoid it when possible. | |
Mar 22, 2019 at 6:37 | vote | accept | CommunityBot | ||
Mar 22, 2019 at 4:01 | history | answered | Quuxplusone | CC BY-SA 4.0 |