From 454cd962d52e219c488a8242baca7093c74719fb Mon Sep 17 00:00:00 2001
From: FKHals <5229803-FKHals@users.noreply.gitlab.com>
Date: Thu, 25 Aug 2022 15:23:28 +0200
Subject: [PATCH] Modify rank-swapper-agent to run on a docker image

---
 rank-swapper-agent/Makefile  | 2 +-
 rank-swapper-agent/client.sh | 8 +++++---
 rank-swapper-agent/hello_c.c | 2 +-
 rank-swapper-agent/locserv.c | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/rank-swapper-agent/Makefile b/rank-swapper-agent/Makefile
index 7aefe6ec5f..b5d328f888 100644
--- a/rank-swapper-agent/Makefile
+++ b/rank-swapper-agent/Makefile
@@ -1,4 +1,4 @@
-export OMPI := /<path-to-my-openmpi-installation>/openmpi-install
+export OMPI := /home/openmpi-install
 export PATH := $(PATH):$(OMPI)/bin
 export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH):$(OMPI)/bin
 # requirement: GNU make, see https://unix.stackexchange.com/questions/11530/adding-directory-to-path-through-makefile/261844#261844
diff --git a/rank-swapper-agent/client.sh b/rank-swapper-agent/client.sh
index cb1d85889e..50f1a093fc 100755
--- a/rank-swapper-agent/client.sh
+++ b/rank-swapper-agent/client.sh
@@ -1,14 +1,16 @@
 #!/bin/bash
 
-export OMPI=/<path-to-my-openmpi-installation>/openmpi-install
+export OMPI=/home/openmpi-install
 export PATH=$PATH:$OMPI/bin
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$OMPI/bin
 
 PROCESSES=1
 
 HOSTFILE="--hostfile hostfile.txt"
+# makes the usage of hardware-threads instead of just cores possible
 ENABLE_HYPERTHREADING="--bind-to hwthread"
 ALLOW_OVERLOAD="--bind-to core:overload-allowed"
 ENABLE_OVERSUBSCRIBE="--map-by :OVERSUBSCRIBE"
-# --bind-to hwthread: makes the usage of threads instead of just cores possible
-mpirun --np $PROCESSES $ALLOW_OVERLOAD $ENABLE_OVERSUBSCRIBE $HOSTFILE hello
+#FIXME run as root is necessary for running it inside docker but it should be disabled for production!
+ALLOW_RUN_AS_ROOT="--allow-run-as-root"
+mpirun --np $PROCESSES $ALLOW_OVERLOAD $ENABLE_OVERSUBSCRIBE $HOSTFILE $ALLOW_RUN_AS_ROOT hello
diff --git a/rank-swapper-agent/hello_c.c b/rank-swapper-agent/hello_c.c
index d8b3e61117..4693db3eb7 100644
--- a/rank-swapper-agent/hello_c.c
+++ b/rank-swapper-agent/hello_c.c
@@ -15,7 +15,7 @@
 
 #include "mpi.h"
 
-#define SOCKET_PATH "/home/beach/Dokumente/Uni/Informatik_BA/Bachelorarbeit_MPI/sockets_mpi_test/socket"
+#define SOCKET_PATH "/home/ompi/openmpi-rank-swapper-agent/socket"
 #define BUFFLEN 64
 
 /* Spawn Modes (dynamic job spawning):
diff --git a/rank-swapper-agent/locserv.c b/rank-swapper-agent/locserv.c
index 828ae8e667..1628c9e213 100644
--- a/rank-swapper-agent/locserv.c
+++ b/rank-swapper-agent/locserv.c
@@ -23,7 +23,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#define SOCKET_PATH "/home/beach/Dokumente/Uni/Informatik_BA/Bachelorarbeit_MPI/sockets_mpi_test/socket"
+#define SOCKET_PATH "/home/ompi/openmpi-rank-swapper-agent/socket"
 #define MAX_CONNECTIONS 10
 #define RANK_STR_LEN 8
 #define BUFFLEN  64
-- 
GitLab