A quick and easy way to do this is to use cublasSgemm to do a matrix multiply with a ones vector(vector whose elements are all 1.0f) of the same length as your data. You’ll probably have to write a trivial kernel to initialize your ones vector, but the call to Sgemm is fairly straightforward, just be careful to get the input dimensions correct. My guess is using cublas would be slower then the reduction example, but it would be interesting to see how much.
mattb3
12
Related topics
| Topic | Replies | Views | Activity | |
|---|---|---|---|---|
| float reduction, cpu and cuda answers differ | 4 | 3502 | April 1, 2008 | |
| Best way to face this problem | 4 | 1264 | May 16, 2010 | |
| Simple summation of an array | 5 | 3653 | November 7, 2017 | |
| Reduction Reduction Reduction................. Precision Confusion Race Condition...... HELP! | 16 | 10670 | December 8, 2009 | |
| Basic reduction with CUDA | 1 | 607 | March 22, 2018 | |
| Summing matrix elements | 3 | 7042 | July 4, 2011 | |
| 2D reduction using CUDA The use a cuda and cublas library for a 2D simple reduction | 11 | 4676 | February 7, 2012 | |
| Problem using NPP sum Having trouble using reduction sum with NPP | 0 | 1059 | August 3, 2011 | |
| Easyway to compute the sum of the array? | 4 | 8146 | February 13, 2008 | |
| total sum example | 3 | 7440 | December 2, 2015 |