1515 * ************************************************************************ */
1616
1717 /* ! \file
18- * \brief Simple demonstration code for how to calculate a SpM-dV (Sparse matrix
19- * times dense Vector) multiply
18+ * \brief Simple demonstration code for how to calculate a SpMM addition
2019 */
2120
2221#include < iostream>
3231#include " clSPARSE-error.h"
3332
3433/* *
35- * \brief Sample Sparse Matrix dense Vector multiplication (SPMV C++)
36- * \details [y = alpha * A*x + beta * y ]
34+ * \brief Sample Bool Sparse Matrix Matrix addition
35+ * \details [C = A + A ]
3736 *
3837 * A - [m x n] matrix in CSR format
39- * x - dense vector of n elements
40- * y - dense vector of m elements
41- * alpha, beta - scalars
42- *
43- *
44- * Program presents usage of clSPARSE library in csrmv (y = A*x) operation
45- * where A is sparse matrix in CSR format, x, y are dense vectors.
46- *
47- * clSPARSE offers two spmv algorithms for matrix stored in CSR format.
48- * First one is called vector algorithm, the second one is called adaptve.
49- * Adaptive version is usually faster but for given matrix additional
50- * structure (rowBlocks) needs to be calculated first.
51- *
52- * To calculate rowBlock structure you have to execute clsparseCsrMetaSize
53- * for given matrix stored in CSR format. It is enough to calculate the
54- * structure once, it is related to its nnz pattern.
55- *
56- * After the matrix is read from disk with the function
57- * clsparse<S,D>CsrMatrixfromFile
58- * the rowBlock structure can be calculated using clsparseCsrMetaCompute
59- *
60- * If rowBlocks are calculated the clsparseCsrMatrix.rowBlocks field is not null.
6138 *
6239 * Program is executing by completing following steps:
6340 * 1. Setup OpenCL environment
6441 * 2. Setup GPU buffers
6542 * 3. Init clSPARSE library
66- * 4. Execute algorithm cldenseSaxpy
43+ * 4. Execute algorithm clsparseBoolScsrElemAdd
6744 * 5. Shutdown clSPARSE library & OpenCL
6845 *
6946 * usage:
7047 *
71- * sample-spmv path/to/matrix/in/mtx/format.mtx
48+ * bool-add-sample path/to/matrix/in/mtx/format.mtx
7249 *
7350 */
7451
@@ -221,8 +198,7 @@ int main (int argc, char* argv[])
221198
222199
223200 clsparseBoolCsrMatrix C;
224- /* *Step 4. Call the add algorithm */
225- // status = clsparseBoolScsrSpGemm(&A, &B, &C, createResult.control );
201+ /* *Step 4. Call the addition algorithm */
226202 status = clsparseBoolScsrElemAdd (&A, &B, &C, createResult.control );
227203
228204 std::vector<int > csrRowPtrC_h ((C.num_rows + 1 ), 0 );
@@ -235,11 +211,6 @@ int main (int argc, char* argv[])
235211 0 ,
236212 0 ,
237213 0 );
238- // for (auto i = csrRowPtrC_h.begin(); i != csrRowPtrC_h.end(); ++i)
239- // {
240- // std::cout << *i << ' ';
241- // }
242- // std::cout << std::endl;
243214
244215 std::vector<int > csrColIndC_h (C.num_nonzeros , 0 );
245216 run_status = clEnqueueReadBuffer (queue (),
@@ -251,12 +222,6 @@ int main (int argc, char* argv[])
251222 0 ,
252223 0 ,
253224 0 );
254- // for (auto i = csrColIndC_h.begin(); i != csrColIndC_h.end(); ++i)
255- // {
256- // std::cout << *i << ' ';
257- // }
258- // std::cout << std::endl;
259-
260225
261226 // CPU ADDITION
262227
@@ -297,24 +262,11 @@ int main (int argc, char* argv[])
297262 dst.clear ();
298263 }
299264
300- // for (auto i = row_ptr_C.begin(); i != row_ptr_C.end(); ++i)
301- // {
302- // std::cout << *i << ' ';
303- // }
304- // std::cout << std::endl;
305-
306- // for (auto i = cols_C.begin(); i != cols_C.end(); ++i)
307- // {
308- // std::cout << *i << ' ';
309- // }
310- // std::cout << std::endl;
311-
312265 // VERIFY RESULTS
313266
314267 assert (csrRowPtrC_h == row_ptr_C);
315268 assert (csrColIndC_h == cols_C);
316269
317-
318270 if (status != clsparseSuccess)
319271 {
320272 std::cout << " Problem with execution SpMV algorithm."
0 commit comments