Actual source code: ex239.c
1: static char help[] = "Test device/host memory allocation in MatDenseSeqCUDA()\n\n";
3: /* Contributed by: Victor Eijkhout <eijkhout@tacc.utexas.edu> */
5: #include <petscmat.h>
6: int main(int argc, char **argv)
7: {
8: PetscInt global_size = 100;
9: Mat cuda_matrix;
10: Vec input, output;
11: MPI_Comm comm = PETSC_COMM_SELF;
12: PetscReal nrm = 1;
15: PetscInitialize(&argc, &argv, NULL, help);
16: MatCreateDenseCUDA(comm, global_size, global_size, global_size, global_size, NULL, &cuda_matrix);
18: VecCreateSeqCUDA(comm, global_size, &input);
19: VecDuplicate(input, &output);
20: VecSet(input, 1.);
21: VecSet(output, 2.);
22: MatMult(cuda_matrix, input, output);
23: VecNorm(output, NORM_2, &nrm);
25: VecDestroy(&input);
26: VecDestroy(&output);
27: MatDestroy(&cuda_matrix);
28: PetscFinalize();
29: return 0;
30: }
32: /*TEST
33: build:
34: requires: cuda
36: test:
37: nsize: 1
39: TEST*/