Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Unnecessary wrapping_add? #4

Open
beamspease opened this issue May 19, 2017 · 2 comments
Open

Unnecessary wrapping_add? #4

beamspease opened this issue May 19, 2017 · 2 comments

Comments

@beamspease
Copy link

I noticed that you're manually calling wrapping_* for arithmetic operations in the PTX kernels. Shouldn't overflow wrap around already?

Note that I also noticed that it appears the intrinsics use signed for these variables (for which overflow would be undefined in C, although defined as wraparound in RFC 560 for Rust) but are defined as using unsigned (defined as wraparound in both C and Rust) in the CUDA programming manual. I filed a ticket in that library about this.

https://github.com/nox/rust-rfcs/blob/master/text/0560-integer-overflow.md
japaric-archived/nvptx-builtins#1

Feel free to close the ticket if it isn't relevant - I don't typically do GPGPU programming and this was the easiest way for me to provide feedback.

@japaric
Copy link
Contributor

japaric commented May 20, 2017

I noticed that you're manually calling wrapping_* for arithmetic operations in the PTX kernels. Shouldn't overflow wrap around already?

Not in debug mode; it would panic in that mode when an overflow occurs. The wrapping_add makes sure there's no panic branch even in debug mode.

for which overflow would be undefined in C

Oh, wow. Is that UB?

I filed a ticket in that library about this.

I answered over there.

@beamspease
Copy link
Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants