Details
Diff Detail
- Repository
- rOLDT svn-test-suite
- Build Status
Buildable 29768 Build 29767: arc lint + arc unit
Event Timeline
External/CUDA/round.cu | ||
---|---|---|
16 | I'd use a name different from the standard libm function. do_round perhaps? | |
17 | __builtin_roundf() takes float as an argument, so if T is double, it's not doing what you wanted it to do. | |
24–47 | This is way too convoluted. We do have assert available on device side. __device__ void test_a(int x) { assert(__builtin_roundf(0.5f + x) == 1.0f); assert(__builtin_roundf(-0.5f + x) == -1.0f); ... } __global__ void tests(int x) { test_a(x); ... } int main() { tests<<<1,1>>>(0); ... } Note: x is a coarse way to block constant evaluation. It may not be needed if the test is run unoptimized. | |
52–53 | It would be good to add some comments why particular values were chosen. My guess is that be the smallest value with lsb of mantissa representing less than 1.0 and thus should not be affected by rounding. |
Rename round.cu to test_round.cu.
Fix the intrinsic for double.
Change the test to use assert and a variable to prevent constant folding.
Fix the test to pass in a scalar value instead of a pointer.
Remove unnecessary device memory allocation and copy.
Add a call to cudaDeviceSynchronize.
External/CUDA/test_round.cu | ||
---|---|---|
37 ↗ | (On Diff #192762) | You may want to add a check for a similarly large negative value, too. |
I'd use a name different from the standard libm function. do_round perhaps?