From 8f7091cb64a1c1331f37347057aa5782e1fe5c6a Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Thu, 18 Feb 2021 19:18:20 -0500
Subject: [PATCH] Add some clean up in main

---
 src/main.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main.c b/src/main.c
index 627eeef..08cf764 100644
--- a/src/main.c
+++ b/src/main.c
@@ -64,6 +64,13 @@ int main(int argc, char* argv[]) {
         gettimeofday(&start_time, NULL);
     }
 
+    // Set a minimum of 4 active processes, unconditionally.
+    // One for handling "console output" and then at least 3 to function as workers.
+    // Doesn't make sense to have any fewer processes running, given the point of this program.
+    if (total_processors < 4) {
+        total_processors = 4;
+    }
+
     // Validate program args.
     validate_args(argc, argv);
 
@@ -82,7 +89,7 @@ int main(int argc, char* argv[]) {
         printf("                        = %i Minutes Active Work\n", (seconds_active_work / 60));
         printf("\n");
         printf("    %i Total System Processors\n", get_nprocs());
-        printf("    %i Processors in Use\n", total_processors);
+        printf("    %i Processors in Use (Min value of 4)\n", total_processors);
         printf("\n");
         printf("    Expected total execution time with ideal processor usage (ignoring unused processors):\n");
         expected_time_lapse = seconds_active_work / total_processors;
@@ -200,15 +207,15 @@ void run_program() {
         total_processors, seconds_per_load, total_loads, process_rank
     );
 
-    // arr_run(thread_args_ptr);
-    grr_run(thread_args_ptr);
+    arr_run(thread_args_ptr);
+    // grr_run(thread_args_ptr);
     // rp_run(thread_args_ptr);
     // nn_run(thread_args_ptr);
 
     free_thread_struct(thread_args_ptr);
 
     // Wait for all processes to synchronize.
-    // MPI_Barrier(MPI_COMM_WORLD);
+    MPI_Barrier(MPI_COMM_WORLD);
 
     if (process_rank == 0) {
         printf("\n");
-- 
GitLab