@@ -67,18 +67,13 @@ class xCoo2Csr: public clsparseFunc
6767
6868 double bandwidth ( )
6969 {
70- // Assuming that accesses to the vector always hit in the cache after the first access
71- // There are NNZ integers in the cols[ ] array
72- // You access each integer value in row_delimiters[ ] once.
73- // There are NNZ float_types in the vals[ ] array
74- // You read num_cols floats from the vector, afterwards they cache perfectly.
75- // Finally, you write num_rows floats out to DRAM at the end of the kernel.
76- return ( sizeof ( cl_int )*( csrMtx.num_nonzeros + csrMtx.num_rows ) + sizeof ( T ) * ( csrMtx.num_nonzeros + csrMtx.num_cols + csrMtx.num_rows ) ) / time_in_ns ( );
70+ // Number of Elements converted in unit time
71+ return ( n_vals / time_in_ns ( ) );
7772 }
7873
7974 std::string bandwidth_formula ( )
8075 {
81- return " GiB /s" ;
76+ return " Gi-Elements /s" ;
8277 }
8378
8479
@@ -88,15 +83,14 @@ class xCoo2Csr: public clsparseFunc
8883
8984 cl_int status;
9085
91- int nnz1, row1, col1;
92- clsparseStatus fileError = clsparseHeaderfromFile ( &nnz1, &row1, &col1, path.c_str ( ) );
86+ clsparseStatus fileError = clsparseHeaderfromFile ( &n_vals, &n_rows, &n_cols, path.c_str ( ) );
9387 if ( fileError != clsparseSuccess )
9488 throw std::runtime_error ( " Could not read matrix market header from disk" );
9589
9690 clsparseInitCooMatrix ( &cooMatx );
97- cooMatx.num_nonzeros = nnz1 ;
98- cooMatx.num_rows = row1 ;
99- cooMatx.num_cols = col1 ;
91+ cooMatx.num_nonzeros = n_vals ;
92+ cooMatx.num_rows = n_rows ;
93+ cooMatx.num_cols = n_cols ;
10094
10195 cooMatx.values = ::clCreateBuffer ( ctx, CL_MEM_READ_ONLY ,
10296 cooMatx.num_nonzeros * sizeof (T), NULL , &status );
@@ -105,8 +99,6 @@ class xCoo2Csr: public clsparseFunc
10599 cooMatx.rowIndices = ::clCreateBuffer ( ctx, CL_MEM_READ_ONLY ,
106100 cooMatx.num_nonzeros * sizeof ( cl_int ), NULL , &status );
107101
108- // JPA: Bug fix: That will not work for double precision
109- // clsparseCooMatrixfromFile( &cooMatx, path.c_str( ), control );
110102 if (typeid (T) == typeid (float ))
111103 clsparseSCooMatrixfromFile (&cooMatx, path.c_str (), control);
112104 if (typeid (T) == typeid (double ))
@@ -116,12 +108,12 @@ class xCoo2Csr: public clsparseFunc
116108 clsparseInitCsrMatrix ( &csrMtx );
117109
118110 // JPA:: Shouldn't be CL_MEM_WRITE_ONLY since coo ---> csr???
119- csrMtx.values = ::clCreateBuffer ( ctx, CL_MEM_READ_ONLY ,
111+ csrMtx.values = ::clCreateBuffer ( ctx, CL_MEM_READ_WRITE ,
120112 cooMatx.num_nonzeros * sizeof ( T ), NULL , &status );
121113
122- csrMtx.colIndices = ::clCreateBuffer ( ctx, CL_MEM_READ_ONLY ,
114+ csrMtx.colIndices = ::clCreateBuffer ( ctx, CL_MEM_READ_WRITE ,
123115 cooMatx.num_nonzeros * sizeof ( cl_int ), NULL , &status );
124- csrMtx.rowOffsets = ::clCreateBuffer ( ctx, CL_MEM_READ_ONLY ,
116+ csrMtx.rowOffsets = ::clCreateBuffer ( ctx, CL_MEM_READ_WRITE ,
125117 ( cooMatx.num_rows + 1 ) * sizeof ( cl_int ), NULL , &status );
126118
127119 }
@@ -157,13 +149,13 @@ class xCoo2Csr: public clsparseFunc
157149 if ( gpuTimer && cpuTimer )
158150 {
159151 std::cout << " clSPARSE matrix: " << sparseFile << std::endl;
160- size_t sparseBytes = 0 ;
152+ size_t sparseElements = n_vals ;
161153 cpuTimer->pruneOutliers ( 3.0 );
162- cpuTimer->Print ( sparseBytes , " GiB /s" );
154+ cpuTimer->Print ( sparseElements , " GiElements /s" );
163155 cpuTimer->Reset ( );
164156
165157 gpuTimer->pruneOutliers ( 3.0 );
166- gpuTimer->Print ( sparseBytes , " GiB /s" );
158+ gpuTimer->Print ( sparseElements , " GiElements /s" );
167159 gpuTimer->Reset ( );
168160 }
169161
@@ -193,9 +185,9 @@ class xCoo2Csr: public clsparseFunc
193185 clsparseCooMatrix cooMatx;
194186
195187 // matrix dimension
196- int m ;
197- int n ;
198- int nnz ;
188+ int n_rows ;
189+ int n_cols ;
190+ int n_vals ;
199191
200192 // OpenCL state
201193 cl_command_queue_properties cqProp;
0 commit comments