DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
test_arraydof.py
Go to the documentation of this file.
1from DNDSR import DNDS
2import pytest
3
4
5def test():
6 cp = pytest.importorskip("cupy", reason="cupy not installed (requires CUDA)")
7
8 cp.cuda.Device(0).use()
9 mpi = DNDS.MPIInfo()
10 mpi.setWorld()
11
12 arr = DNDS.ArrayDOF_1_1()
13 arr.father = DNDS.ArrayEigenMatrix_1x1_1x1_N(mpi)
14 arr.son = DNDS.ArrayEigenMatrix_1x1_1x1_N(mpi)
15 arr.father.Resize(1000000, 1, 1)
16 arr.son.Resize(0, 1, 1)
17
18 arr.TransAttach()
19
20 arr.setConstant(1.0)
21 print(arr.norm2() ** 2)
22
23 try:
24 arr.to_device("CUDA")
25 except RuntimeError as e:
26 if "Unknown" in str(e) or "cannot to_device" in str(e):
27 pytest.skip("DNDS library built without CUDA backend support")
28 raise
29 arr.setConstant(-2.0)
30 print(arr[0].tolist())
31 arr.to_host()
32 print(arr[0].tolist())
33 arr.to_device("CUDA")
34 print(arr.norm2() ** 2)
35 print(arr.componentWiseNorm1())
36 for _ in range(1000):
37 print(arr.min())
38
39
40if __name__ == "__main__":
41 test()
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Definition MPI.hpp:215