Mercurial > repos > public > sbplib_julia
comparison distributedTest.jl @ 151:80f7d7abe47d parallel_test
Removed unnecessary assertion
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 26 Feb 2019 11:49:56 +0100 |
parents | 4dc19757cada |
children |
comparison
equal
deleted
inserted
replaced
150:4dc19757cada | 151:80f7d7abe47d |
---|---|
4 # TODO: Currently uses integer division to calculate the local grid size. | 4 # TODO: Currently uses integer division to calculate the local grid size. |
5 # Should we make sure this is handled in some way if mod(sz./nworkers()) != 0 | 5 # Should we make sure this is handled in some way if mod(sz./nworkers()) != 0 |
6 # or keep assertions? | 6 # or keep assertions? |
7 @everywhere function create_partitioned_grid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T}, nworkers_per_dim::NTuple{Dim, Int}) where Dim where T | 7 @everywhere function create_partitioned_grid(size::NTuple{Dim, Int}, limit_lower::NTuple{Dim, T}, limit_upper::NTuple{Dim, T}, nworkers_per_dim::NTuple{Dim, Int}) where Dim where T |
8 @assert mod.(size, nworkers_per_dim) == (0,0) | 8 @assert mod.(size, nworkers_per_dim) == (0,0) |
9 @assert prod(nworkers_per_dim) == nworkers() | |
10 # Translate the current worker id to a cartesian index, based on nworkers_per_dim | 9 # Translate the current worker id to a cartesian index, based on nworkers_per_dim |
11 ci = CartesianIndices(nworkers_per_dim); | 10 ci = CartesianIndices(nworkers_per_dim); |
12 id = Tuple(ci[myid()-1]) | 11 id = Tuple(ci[myid()-1]) |
13 | 12 |
14 # Compute the size of each partitioned grid | 13 # Compute the size of each partitioned grid |
28 @time sbp.apply_tiled!(op, u, v) | 27 @time sbp.apply_tiled!(op, u, v) |
29 return nothing | 28 return nothing |
30 end | 29 end |
31 | 30 |
32 gridsize = (10000, 10000); # Global grid size | 31 gridsize = (10000, 10000); # Global grid size |
32 nworkers_per_dim = (2,2) # Currently must have mod.(gridsize,n_workers_per_dim) == 0 | |
33 v = dzeros(gridsize) # Distribured arrays | 33 v = dzeros(gridsize) # Distribured arrays |
34 u = dzeros(gridsize) # Distribured arrays | 34 u = dzeros(gridsize) # Distribured arrays |
35 | 35 |
36 @sync @distributed for p in workers() | 36 @sync @distributed for p in workers() |
37 #Should these be declared globally or locally? | 37 #Should these be declared globally or locally? |
38 limit_lower = (0., 0.) | 38 limit_lower = (0., 0.) |
39 limit_upper = (2pi, 3pi/2) | 39 limit_upper = (2pi, 3pi/2) |
40 # TODO: Fix initiation of nworkers_per_dim | |
41 nworkers_per_dim = Int.(ntuple(x->nworkers()/2,2)) | |
42 init(x,y) = sin(x) + sin(y) | 40 init(x,y) = sin(x) + sin(y) |
43 grid = create_partitioned_grid(gridsize, limit_lower , limit_upper, nworkers_per_dim) | 41 grid = create_partitioned_grid(gridsize, limit_lower , limit_upper, nworkers_per_dim) |
44 @inbounds v[:L] = sbp.Grid.evalOn(grid, init) | 42 @inbounds v[:L] = sbp.Grid.evalOn(grid, init) |
45 op = sbp.readOperator("d2_4th.txt","h_4th.txt") | 43 op = sbp.readOperator("d2_4th.txt","h_4th.txt") |
46 Δ = sbp.Laplace(grid, 1.0, op) | 44 Δ = sbp.Laplace(grid, 1.0, op) |