changeset 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
files distributedTest.jl
diffstat 1 files changed, 6 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/distributedTest.jl	Mon Feb 25 16:36:15 2019 +0100
+++ b/distributedTest.jl	Mon Feb 25 17:21:07 2019 +0100
@@ -39,18 +39,12 @@
 Laplace_partitioned  = [@spawnat p sbp.Laplace(fetch(grids_partitioned[p-1]), 1.0, op) for p in workers()]
 
 # Create initial value grid function v and solution grid function u
-# TODO: u and v could be a distributed arrays from the start.
-# Then pass local parts of the distributed arrays to the functions
 @everywhere init(x,y) = sin(x) + sin(y)
-v = [@spawnat p sbp.Grid.evalOn(fetch(grids_partitioned[p-1]), init) for p in workers()]
-u = [@spawnat p zero(fetch(v[p-1])) for p in workers()]
+v = dzeros(gridsize)
+u = dzeros(gridsize)
+@async([@spawnat p v[:L] = sbp.Grid.evalOn(fetch(grids_partitioned[p-1]), init) for p in workers()]) #TODO: Correct use of async?
 
-# # Apply Laplace
-fetch([@spawnat p sbp.apply_tiled!(fetch(Laplace_partitioned[p-1]),fetch(u[p-1]), fetch(v[p-1])) for p in workers()])
+# Apply Laplace
+@async([@spawnat p sbp.apply_tiled!(fetch(Laplace_partitioned[p-1]),u[:L], v[:L]) for p in workers()]) #TODO: Correct use of async?
 
-# Construct global vector and store in distributed array
-u = reshape(u,(2,2))
-u_global = DArray(u)
-v = reshape(v,(2,2))
-v_global = DArray(v)
-@show maximum(abs.(u_global + v_global))
+@show maximum(abs.(u + v))