Mercurial > repos > public > sbplib_julia
comparison distributedTest.jl @ 150:4dc19757cada parallel_test
Minor cleanup.
author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
---|---|
date | Tue, 26 Feb 2019 11:27:04 +0100 |
parents | 11b6646918d4 |
children | 80f7d7abe47d |
comparison
equal
deleted
inserted
replaced
149:11b6646918d4 | 150:4dc19757cada |
---|---|
10 # Translate the current worker id to a cartesian index, based on nworkers_per_dim | 10 # Translate the current worker id to a cartesian index, based on nworkers_per_dim |
11 ci = CartesianIndices(nworkers_per_dim); | 11 ci = CartesianIndices(nworkers_per_dim); |
12 id = Tuple(ci[myid()-1]) | 12 id = Tuple(ci[myid()-1]) |
13 | 13 |
14 # Compute the size of each partitioned grid | 14 # Compute the size of each partitioned grid |
15 size_partition = size./nworkers_per_dim | 15 size_partition = Int.(size./nworkers_per_dim) |
16 size_partition = map(x->Int(x),size_partition) # TODO: Cant this be done in an easier way?... | |
17 # Compute domain size for each partition | 16 # Compute domain size for each partition |
18 domain_size = limit_upper.-limit_lower | 17 domain_size = limit_upper.-limit_lower |
19 domain_partition_size = domain_size./nworkers_per_dim | 18 domain_partition_size = domain_size./nworkers_per_dim |
20 | 19 |
21 # Compute the lower and upper limit for each grid partition, then construct the grid | 20 # Compute the lower and upper limit for each grid partition, then construct the grid |
36 | 35 |
37 @sync @distributed for p in workers() | 36 @sync @distributed for p in workers() |
38 #Should these be declared globally or locally? | 37 #Should these be declared globally or locally? |
39 limit_lower = (0., 0.) | 38 limit_lower = (0., 0.) |
40 limit_upper = (2pi, 3pi/2) | 39 limit_upper = (2pi, 3pi/2) |
41 nworkers_per_dim = (Int(nworkers()/2),Int(nworkers()/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) | 42 init(x,y) = sin(x) + sin(y) |
43 grid = create_partitioned_grid(gridsize, limit_lower , limit_upper, nworkers_per_dim) | 43 grid = create_partitioned_grid(gridsize, limit_lower , limit_upper, nworkers_per_dim) |
44 @inbounds v[:L] = sbp.Grid.evalOn(grid, init) | 44 @inbounds v[:L] = sbp.Grid.evalOn(grid, init) |
45 op = sbp.readOperator("d2_4th.txt","h_4th.txt") | 45 op = sbp.readOperator("d2_4th.txt","h_4th.txt") |
46 Δ = sbp.Laplace(grid, 1.0, op) | 46 Δ = sbp.Laplace(grid, 1.0, op) |