Skip to content

Commit 09be920

Browse files
committed
get proc id using two arrays
1 parent e1be0a5 commit 09be920

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
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.1"
4+
version = "0.1.0"
55

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

src/ParallelUtilities.jl

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,34 @@ function get_processor_id_from_split_array(iter,val::Tuple,num_procs)
106106
return 0
107107
end
108108

109-
function get_processor_range_from_split_array(arr₁::AbstractVector,arr₂::AbstractVector,
110-
iter_section,num_procs::Integer)
109+
get_processor_id_from_split_array(arr₁::AbstractVector,arr₂::AbstractVector,
110+
val::Tuple{Any,Any},num_procs::Integer) =
111+
get_processor_id_from_split_array(Iterators.product(arr₁,arr₂),
112+
val,num_procs)
113+
114+
function get_processor_range_from_split_array(iter,iter_section,num_procs::Integer)
111115

112116
if isempty(iter_section)
113117
return 0:-1 # empty range
114118
end
115119

116-
tasks_arr = collect(iter_section)
117-
proc_id_start = get_processor_id_from_split_array(arr₁,arr₂,first(tasks_arr),num_procs)
118-
proc_id_end = get_processor_id_from_split_array(arr₁,arr₂,last(tasks_arr),num_procs)
119-
return proc_id_start:proc_id_end
120-
end
120+
first_task = first(iter_section)
121+
proc_id_start = get_processor_id_from_split_array(iter,first_task,num_procs)
121122

122-
function get_processor_range_from_split_array(iter,iter_section,num_procs::Integer)
123-
124-
if isempty(iter_section)
125-
return 0:-1 # empty range
123+
last_task = first_task
124+
for t in iter_section
125+
last_task = t
126126
end
127127

128-
tasks_arr = collect(iter_section)
129-
proc_id_start = get_processor_id_from_split_array(iter,first(tasks_arr),num_procs)
130-
proc_id_end = get_processor_id_from_split_array(iter,last(tasks_arr),num_procs)
128+
proc_id_end = get_processor_id_from_split_array(iter,last_task,num_procs)
131129
return proc_id_start:proc_id_end
132130
end
133131

132+
get_processor_range_from_split_array(arr₁::AbstractVector,arr₂::AbstractVector,
133+
iter_section,num_procs::Integer) =
134+
get_processor_range_from_split_array(Iterators.product(arr₁,arr₂),
135+
iter_section,num_procs)
136+
134137
function get_index_in_split_array(iter_section,val::Tuple)
135138
if isnothing(iter_section)
136139
return nothing

0 commit comments

Comments
 (0)