From fa8eceee62f77b19e842093eabc426cbd6b0d411 Mon Sep 17 00:00:00 2001 From: viniciusjusten Date: Wed, 8 May 2024 13:26:12 -0300 Subject: [PATCH 1/2] remove controller arg from send_termination_message --- src/controller.jl | 12 ++++-------- src/pmap.jl | 2 +- test/test_1.jl | 2 +- test/test_2.jl | 2 +- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/controller.jl b/src/controller.jl index 596771f..81f676a 100644 --- a/src/controller.jl +++ b/src/controller.jl @@ -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) diff --git a/src/pmap.jl b/src/pmap.jl index 8048841..e101f34 100644 --- a/src/pmap.jl +++ b/src/pmap.jl @@ -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 diff --git a/test/test_1.jl b/test/test_1.jl index 7f97e1e..a26d8c9 100644 --- a/test/test_1.jl +++ b/test/test_1.jl @@ -66,7 +66,7 @@ function job_queue(data) end end - JQM.send_termination_message(controller) + JQM.send_termination_message() return new_data end diff --git a/test/test_2.jl b/test/test_2.jl index 3f6c977..1db388d 100644 --- a/test/test_2.jl +++ b/test/test_2.jl @@ -78,7 +78,7 @@ function divisors(data) end end - JQM.send_termination_message(controller) + JQM.send_termination_message() return new_data end From ce842d0f7badc385d593ab077ac376c7e5c1df96 Mon Sep 17 00:00:00 2001 From: viniciusjusten Date: Wed, 8 May 2024 13:32:22 -0300 Subject: [PATCH 2/2] run formatter --- src/pmap.jl | 2 +- test/test_pmap_serial.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pmap.jl b/src/pmap.jl index e101f34..7e285b3 100644 --- a/src/pmap.jl +++ b/src/pmap.jl @@ -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 \ No newline at end of file +end diff --git a/test/test_pmap_serial.jl b/test/test_pmap_serial.jl index a1565f3..2c501f7 100644 --- a/test/test_pmap_serial.jl +++ b/test/test_pmap_serial.jl @@ -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() \ No newline at end of file +JQM.mpi_finalize()