@@ -333,35 +333,33 @@ int run_sparse_pcg_example(const sycl::device &dev)
333
333
const intType nnz = ia_h[n]; // assumes zero indexing
334
334
335
335
// create arrays for help
336
- intType *ia_d = sycl::malloc_device<intType>(n+1 , q);
337
- intType *ja_d = sycl::malloc_device<intType>(nnz, q);
338
- dataType *a_d = sycl::malloc_device<dataType>(nnz, q);
339
- dataType *x_d = sycl::malloc_device<dataType>(n, q);
340
- dataType *b_d = sycl::malloc_device<dataType>(n, q);
341
- dataType *r_d = sycl::malloc_device<dataType>(n, q); // r = b - A*x
342
- dataType *z_d = sycl::malloc_device<dataType>(n, q); // z = M^{-1} * r
343
- dataType *p_d = sycl::malloc_device<dataType>(n, q); // p = ?? z
344
- dataType *t_d = sycl::malloc_device<dataType>(n, q); // helper array
345
- dataType *d_d = sycl::malloc_device<dataType>(n, q); // diag(A)
346
- dataType *invd_d = sycl::malloc_device<dataType>(n, q); // inv(diag(A))
336
+ intType *ia_d = sycl::malloc_device<intType>(n+1 , q); // matrix rowptr
337
+ intType *ja_d = sycl::malloc_device<intType>(nnz, q); // matrix columns
338
+ dataType *a_d = sycl::malloc_device<dataType>(nnz, q); // matrix values
339
+ dataType *x_d = sycl::malloc_device<dataType>(n, q); // solution
340
+ dataType *b_d = sycl::malloc_device<dataType>(n, q); // right hand side
341
+ dataType *r_d = sycl::malloc_device<dataType>(n, q); // residual
342
+ dataType *z_d = sycl::malloc_device<dataType>(n, q); // preconditioned residualr
343
+ dataType *p_d = sycl::malloc_device<dataType>(n, q); // search direction
344
+ dataType *t_d = sycl::malloc_device<dataType>(n, q); // helper array
345
+ dataType *d_d = sycl::malloc_device<dataType>(n, q); // matrix diagonals
346
+ dataType *invd_d = sycl::malloc_device<dataType>(n, q); // matrix reciprocal of diagonals
347
347
348
348
const intType width = 8 ; // width * sizeof(dataType) >= cacheline size (64 Bytes)
349
- dataType *temp_d = sycl::malloc_device<dataType>(4 *width, q);
350
- dataType *temp_h = sycl::malloc_host<dataType>(4 *width, q);
349
+ dataType *temp_d = sycl::malloc_device<dataType>(3 *width, q);
350
+ dataType *temp_h = sycl::malloc_host<dataType>(3 *width, q);
351
351
352
352
if ( !ia_d || !ja_d || !a_d || !x_d || !b_d || !z_d || !p_d || !t_d || !d_d || !invd_d || !temp_d || !temp_h) {
353
353
throw std::runtime_error (" Failed to allocate device side USM memory" );
354
354
}
355
355
356
356
// device side aliases scattered by width elements each
357
357
dataType *normr_h = temp_h;
358
- dataType *normr_d = temp_d;
359
358
dataType *rtz_h = temp_h+1 *width;
359
+ dataType *pAp_h = temp_h+2 *width;
360
+ dataType *normr_d = temp_d;
360
361
dataType *rtz_d = temp_d+1 *width;
361
- // dataType *oldrtz_h = temp_h+2*width;
362
- // dataType *oldrtz_d = temp_d+2*width;
363
- dataType *pAp_h = temp_h+3 *width;
364
- dataType *pAp_d = temp_d+3 *width;
362
+ dataType *pAp_d = temp_d+2 *width;
365
363
366
364
// copy data from host to device arrays
367
365
q.copy (ia_h, ia_d, n+1 ).wait ();
@@ -372,6 +370,7 @@ int run_sparse_pcg_example(const sycl::device &dev)
372
370
373
371
extract_diagonal<dataType, intType>(q,n, ia_d, ja_d, a_d, d_d, invd_d, {}).wait ();
374
372
373
+ // make the matrix diagonally dominant
375
374
modify_diagonal<dataType, intType>(q, dataType (52.0 ), n, ia_d, ja_d, a_d, d_d, invd_d, {}).wait ();
376
375
377
376
// create and initialize handle for a Sparse Matrix in CSR format
0 commit comments