| 37 | // C = [alpha*A, beta*B] |
| 38 | |
| 39 | __global__ void stackCSRrow(const int* row_ind1,const int* row_ptr1, const int* col_ind1, const double* values1, int nnz1, |
| 40 | const int* row_ind2,const int* row_ptr2, const int* col_ind2, const double* values2, int nnz2, |
| 41 | int* row_ptr_out, int* col_ind_out, double* values_out, int num_cols1, int num_cols2, |
| 42 | double alpha, double beta){ |
| 43 | // use row_ind to get the row index of each element |
| 44 | int i = blockIdx.x * blockDim.x + threadIdx.x; |
| 45 | |
| 46 | if(i < nnz1){ |
| 47 | int start_ind1 = row_ptr1[row_ind1[i]]; |
| 48 | int start_ind2 = row_ptr2[row_ind1[i]]; |
| 49 | col_ind_out[start_ind1 + start_ind2 + (i - start_ind1)] = col_ind1[i]; |
| 50 | values_out[start_ind1 + start_ind2 + (i - start_ind1)] = alpha * values1[i]; |
| 51 | } |
| 52 | if(i < nnz2){ |
| 53 | int start_ind1 = row_ptr1[row_ind2[i]+1]; |
| 54 | int start_ind2 = row_ptr2[row_ind2[i]]; |
| 55 | col_ind_out[start_ind1 + start_ind2 + (i - start_ind2)] = col_ind2[i] + num_cols1; |
| 56 | values_out[start_ind1 + start_ind2 + (i - start_ind2)] = beta * values2[i]; |
| 57 | } |
| 58 | int num_row = row_ind1[nnz1-1] + 1; |
| 59 | if(i < num_row + 1){ |
| 60 | row_ptr_out[i] = row_ptr1[i] + row_ptr2[i]; |
| 61 | } |
| 62 | |
| 63 | } |
| 64 | |
| 65 | #endif // SPARSE_STACK_H |
nothing calls this directly
no outgoing calls
no test coverage detected