/[escript]/branches/diaplayground/poisson.py
ViewVC logotype

Annotation of /branches/diaplayground/poisson.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5065 - (hide annotations)
Fri Jun 20 05:49:52 2014 UTC (4 years, 11 months ago) by caltinay
File MIME type: text/x-python
File size: 1614 byte(s)
Proof-of-concept 2:
matrix assembly on CPU as before, solving via cusp-based dia matrix on CPU
or GPU according to options.
CPU->GPU copy time is in the order of 1-2% of solver time,
solver speed-up is nice.
Unfortunately, no MPI support in cusp so this is just to confirm that
it makes sense to pursue further with custom solvers using thrust.

1 caltinay 4944 from esys.escript import *
2 caltinay 4946 from esys.escript.linearPDEs import LinearPDE,SolverOptions
3     from esys.ripley import Rectangle, Brick
4 caltinay 4944 from time import time
5    
6 caltinay 5065 BLOCKSIZE=1
7 caltinay 4946
8 caltinay 5065 dom = Rectangle(l0=1.,l1=1.,n0=599, n1=599)
9     #dom = Brick(l0=1.,l1=1.,n0=51, n1=51, n2=17)
10 caltinay 4946 x = dom.getX()
11 caltinay 4944 gammaD = whereZero(x[0])+whereZero(x[1])
12 caltinay 4946
13 caltinay 5065 def solve(target):
14     pde = LinearPDE(dom, numEquations=BLOCKSIZE, numSolutions=BLOCKSIZE)
15     A = pde.createCoefficient("A")
16     q = pde.createCoefficient("q")
17     Y_reduced = pde.createCoefficient("Y_reduced")
18 caltinay 4946
19 caltinay 5065 if BLOCKSIZE == 1:
20     A = kronecker(dom)
21     q = gammaD
22     Y_reduced = 1.
23     else:
24     for i in range(BLOCKSIZE):
25     A[i,:,i,:] = kronecker(dom)
26     q[i] = gammaD
27     Y_reduced[i] = 1.
28 caltinay 4946
29 caltinay 5065 pde.setValue(A=A, Y_reduced=Y_reduced, q=q)
30     pde.getSolverOptions().setSolverMethod(SolverOptions.PRES20)
31     pde.getSolverOptions().setSolverMethod(SolverOptions.BICGSTAB)
32     pde.getSolverOptions().setSolverMethod(SolverOptions.PCG)
33     pde.getSolverOptions().setSolverTarget(target)
34     pde.getSolverOptions().setPreconditioner(SolverOptions.NO_PRECONDITIONER)
35     pde.getSolverOptions().setVerbosityOn()
36     #pde.setDebugOn()
37     #rhs=pde.getRightHandSide()
38     #saveDataCSV('/tmp/rhs.csv',rhs=rhs)
39     #pde.getSystem()[0].saveMM('/tmp/poissonripley.mtx')
40     t0=time()
41     print("pde.getSolution()")
42     x = pde.getSolution()
43     t1=time()
44     print("Solver Time: %s"%(t1-t0))
45     print("Solution: %s..%s"%(inf(x),sup(x)))
46     print(x)
47 caltinay 4944
48 caltinay 5065
49     for target in SolverOptions.TARGET_CPU,SolverOptions.TARGET_GPU:
50     solve(target)
51     print("-------")
52    

  ViewVC Help
Powered by ViewVC 1.1.26