Mercurial > repos > public > sbplib_julia
comparison distributedTest.jl @ 147:aa18b7bf4926 parallel_test
Changed to initialize u and v as distributed arrays
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Mon, 25 Feb 2019 17:21:07 +0100 |
parents | 21b188f38358 |
children | 95a3ba70bccb |
comparison
equal
deleted
inserted
replaced
146:21b188f38358 | 147:aa18b7bf4926 |
---|---|
37 # Create Laplace operator | 37 # Create Laplace operator |
38 @everywhere op = sbp.readOperator("d2_4th.txt","h_4th.txt") | 38 @everywhere op = sbp.readOperator("d2_4th.txt","h_4th.txt") |
39 Laplace_partitioned = [@spawnat p sbp.Laplace(fetch(grids_partitioned[p-1]), 1.0, op) for p in workers()] | 39 Laplace_partitioned = [@spawnat p sbp.Laplace(fetch(grids_partitioned[p-1]), 1.0, op) for p in workers()] |
40 | 40 |
41 # Create initial value grid function v and solution grid function u | 41 # Create initial value grid function v and solution grid function u |
42 # TODO: u and v could be a distributed arrays from the start. | |
43 # Then pass local parts of the distributed arrays to the functions | |
44 @everywhere init(x,y) = sin(x) + sin(y) | 42 @everywhere init(x,y) = sin(x) + sin(y) |
45 v = [@spawnat p sbp.Grid.evalOn(fetch(grids_partitioned[p-1]), init) for p in workers()] | 43 v = dzeros(gridsize) |
46 u = [@spawnat p zero(fetch(v[p-1])) for p in workers()] | 44 u = dzeros(gridsize) |
45 @async([@spawnat p v[:L] = sbp.Grid.evalOn(fetch(grids_partitioned[p-1]), init) for p in workers()]) #TODO: Correct use of async? | |
47 | 46 |
48 # # Apply Laplace | 47 # Apply Laplace |
49 fetch([@spawnat p sbp.apply_tiled!(fetch(Laplace_partitioned[p-1]),fetch(u[p-1]), fetch(v[p-1])) for p in workers()]) | 48 @async([@spawnat p sbp.apply_tiled!(fetch(Laplace_partitioned[p-1]),u[:L], v[:L]) for p in workers()]) #TODO: Correct use of async? |
50 | 49 |
51 # Construct global vector and store in distributed array | 50 @show maximum(abs.(u + v)) |
52 u = reshape(u,(2,2)) | |
53 u_global = DArray(u) | |
54 v = reshape(v,(2,2)) | |
55 v_global = DArray(v) | |
56 @show maximum(abs.(u_global + v_global)) |