Skip to content

Commit adf766f

Browse files
committed
workersactive, nworkersactive and evenlyscatterproduct accept an Iterators.ProductIterator, added coverage badge
1 parent 2e186f5 commit adf766f

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "ParallelUtilities"
22
uuid = "fad6cfc8-4f83-11e9-06cc-151124046ad0"
33
authors = ["Jishnu Bhattacharya <[email protected]>"]
4-
version = "0.1.0"
4+
version = "0.1.1"
55

66
[deps]
77
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# ParallelUtilities.jl
22

33
[![Build Status](https://travis-ci.com/jishnub/ParallelUtilities.jl.svg?branch=master)](https://travis-ci.com/jishnub/ParallelUtilities.jl)
4+
[![Coverage Status](https://coveralls.io/repos/github/jishnub/ParallelUtilities.jl/badge.svg?branch=master)](https://coveralls.io/github/jishnub/ParallelUtilities.jl?branch=master)
45

56
Parallel mapreduce and other helpful functions for HPC, meant primarily for embarassingly parallel operations that often require one to split up a list of tasks into subsections that can be processed on individual cores.
67

src/ParallelUtilities.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,9 @@ function evenlyscatterproduct(iterators::Tuple,
400400
ProductSplit(iterators,np,procid)
401401
end
402402

403+
evenlyscatterproduct(itp::Iterators.ProductIterator,args...) =
404+
evenlyscatterproduct(itp.iterators,args...)
405+
403406
function whichproc(iterators::Tuple,val::Tuple,np::Int)
404407

405408
_infullrange(val,iterators) || return nothing
@@ -504,9 +507,11 @@ end
504507
nt <= nw ? nt : nw
505508
end
506509
@inline nworkersactive(ps::ProductSplit) = nworkersactive(ps.iterators)
510+
@inline nworkersactive(itp::Iterators.ProductIterator) = nworkersactive(itp.iterators)
507511
@inline nworkersactive(args...) = nworkersactive(args)
508512
@inline workersactive(iterators::Tuple) = workers()[1:nworkersactive(iterators)]
509513
@inline workersactive(ps::ProductSplit) = workersactive(ps.iterators)
514+
@inline workersactive(itp::Iterators.ProductIterator) = workersactive(itp.iterators)
510515
@inline workersactive(args...) = workersactive(args)
511516

512517
function gethostnames(procs_used = workers())

test/runtests.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ end
181181
@test evenlyscatterproduct(n,np,proc_id) == ProductSplit((1:n,),np,proc_id)
182182
for iters in [(1:10,),(1:10,4:6),(1:10,4:6,1:4),(1:2:10,4:1:6)]
183183
@test evenlyscatterproduct(iters,np,proc_id) == ProductSplit(iters,np,proc_id)
184+
itp = Iterators.product(iters...)
185+
@test evenlyscatterproduct(itp,np,proc_id) == ProductSplit(iters,np,proc_id)
184186
end
185187
end
186188

@@ -281,6 +283,11 @@ end
281283

282284
ps = ProductSplit((1:10,),nworkers(),1)
283285
@test nworkersactive(ps) == min(10,nworkers())
286+
287+
iters = (1:1,1:2)
288+
itp = Iterators.product(iters...)
289+
@test nworkersactive(itp) == nworkersactive(iters)
290+
@test workersactive(itp) == workersactive(iters)
284291
end
285292

286293
@testset "hostnames" begin

0 commit comments

Comments
 (0)