-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cu
31 lines (21 loc) · 875 Bytes
/
main.cu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "shared.cuh"
int main(int argc, char **argv) {
Mat A;
PetscViewer viewer;
PetscInt N = 49000;
PetscMPIInt rank;
PetscFunctionBeginUser;
PetscCall(PetscInitialize(&argc, &argv, NULL, NULL));
PetscCall(PetscOptionsGetInt(NULL, NULL, "-N", &N, NULL));
PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
PetscInt loc_size = (rank == 0) ? N : 0;
PetscCall(MatCreateDenseCUDA(PETSC_COMM_WORLD,loc_size,loc_size,PETSC_DETERMINE,PETSC_DETERMINE,NULL,&A));
PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD, "A.dat", FILE_MODE_WRITE, &viewer));
PetscCall(PetscViewerPushFormat(viewer, PETSC_VIEWER_NATIVE));
PetscCall(MatView(A, viewer));
PetscCall(PetscViewerPopFormat(viewer));
PetscCall(PetscViewerDestroy(&viewer));
PetscCall(MatDestroy(&A));
PetscCall(PetscFinalize());
return 0;
}