void load(Archive& ar, const unsigned Integer) { load_sparse_matrix(ar, reduce_A_); load_vector(ar, W_); ar & R_; ar & G_; ar & C_; ar & ins_; ar & iter_; ar & time_; }
int main(int argc, char *argv[]) { int nrep = 1, BS = 0; //parseArgs(argc,argv); double cusp_time; int ok = -1; double init_time = omp_get_wtime(); //init_load(argc,argv, &_numRows, &_numCols, &_numValues, _numericalValues, _rowOffsets,_colIndexValues, _vector, _output_vector,&check_res,&just_analyse); if (argc < 2) { exit(EXIT_FAILURE); } char const *mmfile = argv[1]; printf("Matrix File %s\n", mmfile); int m, n, nz; int *i_idx, *j_idx; double *a; check_res = 1; just_analyse = 0; if (argc == 3) if (argv[2][0] == 'a') { printf("Analyzing matrix...\n"); just_analyse = 1; } else check_res = 0; //read_mm_matrix (mmfile, &m, &n, &nz, &i_idx, &j_idx, &a); //enum sparse_matrix_file_format_t informat; struct sparse_matrix_t *A = load_sparse_matrix(MATRIX_MARKET, argv[1]); if (valid_sparse_matrix(A)) printf("\n### Sparse matrix is valid ###\n\n"); else printf("\n### Invalid sparse matrix! ###\n\n"); struct csr_matrix_t *B = NULL; B = coo_to_csr(A->repr); init_time = omp_get_wtime() - init_time; _numericalValues = (double *) B->values; if (just_analyse) { check_matrix(B->m, B->n, B->nnz, _numericalValues, B->colidx, B->rowptr); return 0; } _vector = malloc(sizeof(double) * B->m); _output_vector = malloc(sizeof(double) * B->m); for (int i = 0; i < B->m; ++i) _vector[i] = i; double ss_time; _numRows = (uint) B->m; _numValues = (uint) B->nnz; _rowOffsets = (uint) B->rowptr; _colIndexValues = (uint) B->colidx; int tmp; double db_time = omp_get_wtime(); #pragma omp target device(acc) #pragma omp task inout([_numValues]_numericalValues, [_numValues]_colIndexValues, [_numRows]_rowOffsets, [_numRows]_vector , [_numRows]_output_vector ) #pragma omp teams num_teams(1) thread_limit(1) { } #pragma omp taskwait noflush db_time = omp_get_wtime() - db_time; ss_time = omp_get_wtime(); SpMV_CSR(_numRows, _numValues, _numericalValues, _colIndexValues, _rowOffsets, _vector, _output_vector); #pragma omp taskwait noflush ss_time = omp_get_wtime() - ss_time; #pragma omp taskwait FILE *fp; fp = fopen("result.txt", "w+"); for (int i = 0; i < B->m; ++i) fprintf(fp, "%.2lf\n", _output_vector[i]); fclose(fp); // if(check_res!=0) // { // ok = check_result(_output_vector,_vector); // cusp_time = get_cusp_time(); // } unsigned long nops = (unsigned long) 2 * (B->m + B->nnz); prtspeed(_numRows, BS, ss_time, init_time, db_time, 0, 0, ok, nops); return 0; }