Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove controller arg from send_termination_message #8

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/controller.jl
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,15 @@ function send_jobs_to_any_available_workers(controller::Controller)
end

"""
send_termination_message(controller::Controller)
send_termination_message()

Send a termination message to all workers.
"""
function send_termination_message(controller::Controller)
if !is_controller_process()
error("Only the controller process can send termination messages.")
end
function send_termination_message()
requests = Vector{JobRequest}()
for worker in 1:controller.n_workers
for worker in 1:num_workers()
request =
MPI.isend(Job(controller.last_job_id, TerminationMessage()), _mpi_comm(); dest = worker, tag = worker + 32)
controller.worker_status[worker] = WORKER_AVAILABLE
MPI.isend(Job(0, TerminationMessage()), _mpi_comm(); dest = worker, tag = worker + 32)
push!(requests, JobRequest(worker, request))
end
return _wait_all(requests)
Expand Down
4 changes: 2 additions & 2 deletions src/pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function pmap(f::Function, jobs::Vector, data_defined_in_process = nothing)
end
end
end
send_termination_message(controller)
send_termination_message()
mpi_barrier()
return result
else
Expand All @@ -72,4 +72,4 @@ function pmap(f::Function, jobs::Vector, data_defined_in_process = nothing)
return result
end
return error("Should never get here")
end
end
2 changes: 1 addition & 1 deletion test/test_1.jl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function job_queue(data)
end
end

JQM.send_termination_message(controller)
JQM.send_termination_message()

return new_data
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function divisors(data)
end
end

JQM.send_termination_message(controller)
JQM.send_termination_message()

return new_data
end
Expand Down
2 changes: 1 addition & 1 deletion test/test_pmap_serial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ divisors_answer = JQM.pmap(get_divisors, collect(1:10))
[[1], [1, 2], [1, 3], [1, 2, 4], [1, 5], [1, 2, 3, 6], [1, 7], [1, 2, 4, 8], [1, 3, 9], [1, 2, 5, 10]]
end

JQM.mpi_finalize()
JQM.mpi_finalize()
Loading