From 3ebc48224b60f65a45d4234068dbc0de638ed775 Mon Sep 17 00:00:00 2001
From: YuhangQ <i@yuhangq.com>
Date: Thu, 30 Mar 2023 10:50:38 +0000
Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 docker/common.dockerfile   |  7 ++++---
 docker/leader.dockerfile   |  2 ++
 docker/run_solver.sh       |  2 +-
 src/distributed/leader.hpp | 26 +++++++++++++-------------
 src/distributed/worker.hpp | 14 +++++++-------
 5 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/docker/common.dockerfile b/docker/common.dockerfile
index 42eb968..0b9242f 100644
--- a/docker/common.dockerfile
+++ b/docker/common.dockerfile
@@ -1,8 +1,9 @@
 FROM satcomp-infrastructure:common
 USER root
 #  Install required softwares
-RUN apt-get update \
-    && DEBIAN_FRONTEND=noninteractive apt install -y cmake build-essential zlib1g-dev libopenmpi-dev wget unzip build-essential zlib1g-dev cmake python3 build-essential gfortran wget curl libboost-all-dev
+RUN apt update
+RUN DEBIAN_FRONTEND=noninteractive apt install -y cmake build-essential zlib1g-dev libopenmpi-dev wget unzip python3 gfortran curl
+RUN apt install -y libboost-all-dev
 
 
 WORKDIR /
@@ -17,4 +18,4 @@ RUN ./configure
 RUN make -j 16
 
 WORKDIR /cloud-sat/
-RUN make -j 
\ No newline at end of file
+RUN make -j 16
\ No newline at end of file
diff --git a/docker/leader.dockerfile b/docker/leader.dockerfile
index 1e85d06..89a9967 100644
--- a/docker/leader.dockerfile
+++ b/docker/leader.dockerfile
@@ -4,6 +4,8 @@ USER root
 FROM satcomp-infrastructure:leader AS mallob_liaison
 WORKDIR /
 
+COPY ./files /competition/files
+
 COPY --from=builder /cloud-sat/light light
 
 COPY --chown=ecs-user ./init_leader.sh /competition/init_solver.sh
diff --git a/docker/run_solver.sh b/docker/run_solver.sh
index 76e0d23..d2b7290 100755
--- a/docker/run_solver.sh
+++ b/docker/run_solver.sh
@@ -1,3 +1,3 @@
 #!/bin/bash
 
-mpirun --host worker1,worker2,worker3 light -i ./files/class_1_easy_10_0.cnf
\ No newline at end of file
+mpirun --host worker1,worker2,worker3 /light -i ./files/class_1_easy_10_0.cnf
\ No newline at end of file
diff --git a/src/distributed/leader.hpp b/src/distributed/leader.hpp
index 28a5b85..9678e2a 100644
--- a/src/distributed/leader.hpp
+++ b/src/distributed/leader.hpp
@@ -33,21 +33,21 @@ void leader_main(light* S, int num_procs, int rank) {
     printf("[leader] reading and do simplify ...\n");
 
     // read file
-    std::stringstream ss;
-    do_simplify(S, ss);
-    const auto& str_ref = ss.str();
-    const char* cstr = str_ref.c_str();
+    // std::stringstream ss;
+    // do_simplify(S, ss);
+    // const auto& str_ref = ss.str();
+    // const char* cstr = str_ref.c_str();
 
-    printf("[leader] hand out simplified cnf ...\n");
+    // printf("[leader] hand out simplified cnf ...\n");
 
-    HeartBeat *hb = new HeartBeat(num_procs); 
+    // HeartBeat *hb = new HeartBeat(num_procs); 
 
-    printf("[leader] waiting for connection...\n");
-    hb->waiting_all();
+    // printf("[leader] waiting for connection...\n");
+    // hb->waiting_all();
 
-    for(int i=1; i<=10; i++) {
-        printf("[leader] check: %d\n", i);
-        hb->update();
-        std::this_thread::sleep_for(std::chrono::seconds(1));
-    }
+    // for(int i=1; i<=10; i++) {
+    //     printf("[leader] check: %d\n", i);
+    //     hb->update();
+    //     std::this_thread::sleep_for(std::chrono::seconds(1));
+    // }
 }
\ No newline at end of file
diff --git a/src/distributed/worker.hpp b/src/distributed/worker.hpp
index 7a79b5e..0150b06 100644
--- a/src/distributed/worker.hpp
+++ b/src/distributed/worker.hpp
@@ -12,16 +12,16 @@ void worker_main(light* S, int num_procs, int rank) {
 
     printf("[worker] i'm worker\n");
 
-    std::this_thread::sleep_for(std::chrono::seconds(1));
+    // std::this_thread::sleep_for(std::chrono::seconds(1));
 
-    time_t now = time(NULL);
-    MPI_Send(&now, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+    // time_t now = time(NULL);
+    // MPI_Send(&now, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
 
-    int buf[2];
-    MPI_Recv(buf, 2, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
-    int next = buf[0], last = buf[1];
+    // int buf[2];
+    // MPI_Recv(buf, 2, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
+    // int next = buf[0], last = buf[1];
 
-    printf("my %d next: %d last: %d\n", rank, next, last);
+    // printf("my %d next: %d last: %d\n", rank, next, last);
 
     int res = S->run();
     if (res == 10) {