-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdistributed_parallel.jl
More file actions
39 lines (30 loc) · 965 Bytes
/
distributed_parallel.jl
File metadata and controls
39 lines (30 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
"""
distributed_parallel.jl
Distributed backend example with strict qualified imports.
Run from package root:
julia --project=examples examples/distributed_parallel.jl 4
"""
using Distributed: Distributed
using StructureFunctions: StructureFunctions as SF
n_workers = length(ARGS) > 0 ? parse(Int, ARGS[1]) : 2
if Distributed.nworkers() < n_workers
Distributed.addprocs(n_workers - Distributed.nworkers())
end
Distributed.@everywhere using StructureFunctions: StructureFunctions as SF
N = 100_000
x = randn(N, 2)
u = randn(N, 2)
bins = collect(10.0:20.0:1000.0)
operator = SF.FullVectorStructureFunctionType{Float64}(order = 2)
result = @time SF.calculate_structure_function(
operator,
x,
u,
bins;
backend = SF.DistributedBackend(),
show_progress = false,
verbose = false,
)
println("Workers: $(Distributed.nworkers())")
println("Total pair counts: $(sum(result.counts))")
Distributed.rmprocs(Distributed.workers())