I have a general question about two implementations of an algorithm with CUDA. The algorithm has the task of summing the columns of a matrix. Firstly, I use one thread per block and the same number of blocks as columns. The kernel uses a for loop to add an entire column with one thread. In the second implementation, I use two threads per block and the same number of blocks as columns. In the kernel for loop, each thread will add half of a column. This returns a 2xN matrix, which then is passed through the same kernel to collapse a second time. Both implementations give the correct answer, but the first consistently gives 0 error compared to MATLAB sum() function and the second gives errors in the order of 1e-5. Can anyone tell me why that is?
Mrcloc
1
IEEE floating point math is not transitive. Summing the same numbers in a different order will produce different results.
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| I got the wrong result from matrix summation | 0 | 4371 | June 1, 2011 | |
| Different results using diffrent memory types | 22 | 4677 | April 14, 2010 | |
| different results (cuda\fortran) | 3 | 915 | July 9, 2013 | |
| I got the wrong result from matrix summation | 2 | 582 | June 1, 2011 | |
| matrix column sums | 0 | 2110 | November 25, 2008 | |
| Why these two scripts give different results? | 5 | 1881 | June 19, 2012 | |
| Debugging inside my kernel I'm sure its something small. | 12 | 10560 | June 19, 2008 | |
| Problem with kernel output | 5 | 1262 | February 18, 2016 | |
| Why these two scripts give different results? | 0 | 1149 | June 18, 2012 | |
| floating point precision on CUDA | 11 | 15238 | June 8, 2010 |