From 1b3f45734a6fc575613ca7395c6581a015a399d8 Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Tue, 14 Aug 2018 09:11:13 -0700 Subject: [PATCH 1/6] Update macros.jl Changes `splitrange` to use `Integer` instead of `Int` so that mixed-width ints can be used. This fixes the following LightGraphs issue on 32-bit machines: ``` julia> g = Graph(10,20) {10, 20} undirected simple Int32 graph julia> Parallel.stress_centrality(g); julia> g = Graph{Int64}(g) {10, 20} undirected simple Int64 graph julia> Parallel.stress_centrality(g); ERROR: MethodError: no method matching splitrange(::Int64, ::Int32) Closest candidates are: splitrange(::Int32, ::Int32) at /buildworker/worker/package_linuxarmv7l/build/usr/share/julia/stdlib/v1.0/Distributed/src/macros.jl:235 ``` --- stdlib/Distributed/src/macros.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/Distributed/src/macros.jl b/stdlib/Distributed/src/macros.jl index f04ad345f10bc..93e4469971d61 100644 --- a/stdlib/Distributed/src/macros.jl +++ b/stdlib/Distributed/src/macros.jl @@ -231,7 +231,7 @@ end # Statically split range [1,N] into equal sized chunks for np processors -function splitrange(N::Int, np::Int) +function splitrange(N::Integer, np::Integer) each = div(N,np) extras = rem(N,np) nchunks = each > 0 ? np : extras From aee422aac62d2dbd79534336bd42671c1e21c3b5 Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Tue, 14 Aug 2018 10:17:01 -0700 Subject: [PATCH 2/6] Update macros.jl update per @jeffbezansons' suggestions --- stdlib/Distributed/src/macros.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/Distributed/src/macros.jl b/stdlib/Distributed/src/macros.jl index 93e4469971d61..15faadb3c31fa 100644 --- a/stdlib/Distributed/src/macros.jl +++ b/stdlib/Distributed/src/macros.jl @@ -231,7 +231,7 @@ end # Statically split range [1,N] into equal sized chunks for np processors -function splitrange(N::Integer, np::Integer) +function splitrange(N::Int, np::Int) each = div(N,np) extras = rem(N,np) nchunks = each > 0 ? np : extras @@ -251,7 +251,7 @@ end function preduce(reducer, f, R) N = length(R) - chunks = splitrange(N, nworkers()) + chunks = splitrange(Int(N), nworkers()) all_w = workers()[1:length(chunks)] w_exec = Task[] From bc103f6a828ec02996e9bebb9ca59b14d918ba0b Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Thu, 23 Aug 2018 08:05:57 -0700 Subject: [PATCH 3/6] Update distributed_exec.jl added test. --- stdlib/Distributed/test/distributed_exec.jl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 04ef09d495a2d..210f6ac6212ce 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1525,6 +1525,10 @@ end a27933 = :_not_defined_27933 @test remotecall_fetch(()->a27933, first(workers())) === a27933 +# PR #28651 +for T in [UInt8, Int8, UInt16, Int16, UInt32, Int32] + @test Distributed.splitrange(20, 4) == Distributed.splitrange(T(20), 4) +end # Run topology tests last after removing all workers, since a given # cluster at any time only supports a single topology. rmprocs(workers()) From ee54551b35bf7c8ec3cc7a4aa44ac33fca9eec9b Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Thu, 23 Aug 2018 08:28:35 -0700 Subject: [PATCH 4/6] Update distributed_exec.jl Moved to before `addprocs` since we don't need remote workers for the `splitrange` test. --- stdlib/Distributed/test/distributed_exec.jl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 210f6ac6212ce..cf58ec46ccd2e 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -15,6 +15,11 @@ include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) 1 end +# PR #28651 +for T in [UInt8, Int8, UInt16, Int16, UInt32, Int32] + @test Distributed.splitrange(20, 4) == Distributed.splitrange(T(20), 4) +end + addprocs_with_testenv(4) @test nprocs() == 5 @@ -1525,10 +1530,6 @@ end a27933 = :_not_defined_27933 @test remotecall_fetch(()->a27933, first(workers())) === a27933 -# PR #28651 -for T in [UInt8, Int8, UInt16, Int16, UInt32, Int32] - @test Distributed.splitrange(20, 4) == Distributed.splitrange(T(20), 4) -end # Run topology tests last after removing all workers, since a given # cluster at any time only supports a single topology. rmprocs(workers()) From 16fd2a4aabc3462d4bf1a2651c4f13450ff87612 Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Fri, 24 Aug 2018 08:02:53 -0700 Subject: [PATCH 5/6] Update distributed_exec.jl --- stdlib/Distributed/test/distributed_exec.jl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index cf58ec46ccd2e..7773c24bfa98c 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -15,11 +15,6 @@ include(joinpath(Sys.BINDIR, "..", "share", "julia", "test", "testenv.jl")) 1 end -# PR #28651 -for T in [UInt8, Int8, UInt16, Int16, UInt32, Int32] - @test Distributed.splitrange(20, 4) == Distributed.splitrange(T(20), 4) -end - addprocs_with_testenv(4) @test nprocs() == 5 @@ -1530,6 +1525,14 @@ end a27933 = :_not_defined_27933 @test remotecall_fetch(()->a27933, first(workers())) === a27933 +# PR #28651 +for T in (UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64) + n = @distributed (+) for i in Base.OneTo(T(10)) + i + end + @test n == 55 +end + # Run topology tests last after removing all workers, since a given # cluster at any time only supports a single topology. rmprocs(workers()) From 8e7f93958b2e34ee26f5c4c06ee844e5f7c7ee32 Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Fri, 24 Aug 2018 08:03:27 -0700 Subject: [PATCH 6/6] Update distributed_exec.jl --- stdlib/Distributed/test/distributed_exec.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/Distributed/test/distributed_exec.jl b/stdlib/Distributed/test/distributed_exec.jl index 7773c24bfa98c..d715dc0b62767 100644 --- a/stdlib/Distributed/test/distributed_exec.jl +++ b/stdlib/Distributed/test/distributed_exec.jl @@ -1527,10 +1527,10 @@ a27933 = :_not_defined_27933 # PR #28651 for T in (UInt8, Int8, UInt16, Int16, UInt32, Int32, UInt64) - n = @distributed (+) for i in Base.OneTo(T(10)) - i - end - @test n == 55 + n = @distributed (+) for i in Base.OneTo(T(10)) + i + end + @test n == 55 end # Run topology tests last after removing all workers, since a given