修改源码文件夹结构

This commit is contained in:
YuhangQ 2023-04-19 08:58:59 +00:00
parent 0cb9e15c01
commit 1d2fbbb614
17 changed files with 19 additions and 148 deletions

3
run.sh
View File

@ -17,6 +17,9 @@
# 04157f716c1e9606c6a530657bf8f957-Kakuro-easy-125-ext.xml.hg_4.cnf
#每次都有BUG
# 3d2a6e5c2f8f58dee79fd50444009625-cfi-rigid-z2-0088-03-or_2_shuffle_all.cnf
# 这个存在问题
DIR=/pub/data/chenzh/data/sat2022

View File

@ -2,7 +2,7 @@
#define _clause_hpp_INCLUDED
#include <boost/thread.hpp>
#include <boost/thread/thread.hpp>
#include "../utils/vec.hpp"
#include "utils/vec.hpp"
using std::shared_ptr;

View File

@ -1,6 +1,5 @@
#pragma once
const int TERMINATE_TAG = 0;
const int SOLVED_REPORT_TAG = 1;
const int MODEL_REPORT_TAG = 2;

View File

@ -1,9 +0,0 @@
#include "../utils/vec.hpp"
#include "../workers/clause.hpp"
class ClausePack {
};

View File

@ -1,98 +0,0 @@
#include "heartbeat.h"
HeartBeat::HeartBeat(int num_procs) {
this->num_procs = num_procs;
this->online = new int[num_procs];
for(int i=0; i<num_procs; i++) {
this->online[i] = 1;
}
this->last_send_time = new time_t[num_procs];
for(int i=0; i<num_procs; i++) {
this->last_send_time[i] = 0;
}
this->requests = new MPI_Request[num_procs];
this->send_requests = new MPI_Request[num_procs];
for(int i=1; i<num_procs; i++) {
MPI_Irecv(&last_send_time[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD, &requests[i]);
int buf[2];
buf[0] = next_online(i);
buf[1] = last_online(i);
MPI_Isend(buf, 2, MPI_INT, i, 0, MPI_COMM_WORLD, &send_requests[i]);
}
auto t = time(NULL);
}
HeartBeat::~HeartBeat() {
delete []this->online;
delete []this->last_send_time;
delete []this->requests;
}
void HeartBeat::update() {
for(int i=1; i<num_procs; i++) {
int flag;
while(MPI_Test(&requests[i], &flag, MPI_STATUS_IGNORE) == MPI_SUCCESS && flag == 1) {
printf("[leader] receive headbeat from: %d - time: %d\n", i, time(0) - last_send_time[i]);
MPI_Irecv(&last_send_time[i], 1, MPI_INT, i, 0, MPI_COMM_WORLD, &requests[i]);
}
}
time_t now = time(NULL);
for(int i=1; i<num_procs; i++) {
if(now - last_send_time[i] > 5) {
if(online[i]) printf("[leader] ERROR: worker %d offline\n", i);
online[i] = 0;
} else {
if(!online[i]) printf("[leader] RECONNECT: worker %d online\n", i);
online[i] = 1;
}
}
for(int i=1; i<num_procs; i++) {
int flag;
if(MPI_Test(&requests[i], &flag, MPI_STATUS_IGNORE) == MPI_SUCCESS && flag == 1) {
int buf[2];
buf[0] = next_online(i);
buf[1] = last_online(i);
MPI_Isend(buf, 2, MPI_INT, i, 0, MPI_COMM_WORLD, &send_requests[i]);
}
}
}
void HeartBeat::waiting_all() {
MPI_Waitall(num_procs-1, requests+1, MPI_STATUS_IGNORE);
for(int i=1; i<num_procs; i++) {
int flag;
if(MPI_Test(&requests[i], &flag, MPI_STATUS_IGNORE) == MPI_SUCCESS && flag == 1) {
int buf[2];
buf[0] = next_online(i);
buf[1] = last_online(i);
printf("buf: %d %d\n", buf[0], buf[1]);
MPI_Isend(buf, 2, MPI_INT, i, 0, MPI_COMM_WORLD, &send_requests[i]);
}
}
}
int HeartBeat::is_online(int p) {
return online[p];
}
int HeartBeat::next_online(int p) {
do {
p = (p + 1) % (num_procs - 1);
} while(!is_online(p));
return p + 1;
}
int HeartBeat::last_online(int p) {
do {
p = (p - 1 + num_procs - 1) % (num_procs - 1);
} while(!is_online(p));
return p + 1;
}

View File

@ -1,18 +0,0 @@
#include <mpi.h>
class HeartBeat {
public:
HeartBeat(int num_procs);
~HeartBeat();
int is_online(int p);
int next_online(int p);
int last_online(int p);
void update();
void waiting_all();
private:
int num_procs;
int *online;
time_t *last_send_time;
MPI_Request* requests;
MPI_Request* send_requests;
};

View File

@ -1,5 +0,0 @@
#pragma once
#include <mpi.h>
#include "comm_tag.h"

View File

@ -6,10 +6,9 @@
#include <mpi.h>
#include "comm_tag.h"
#include "../light.hpp"
#include "../utils/cmdline.h"
#include "../paras.hpp"
#include "heartbeat.h"
#include "light.hpp"
#include "utils/cmdline.h"
#include "paras.hpp"
void leader_main(light* S, int num_procs, int rank) {

View File

@ -8,10 +8,10 @@
#include "utils/cmdline.h"
#include "paras.hpp"
#include "distributed/leader.hpp"
#include "distributed/worker.hpp"
#include "leader.hpp"
#include "worker.hpp"
#include "workers/clause.hpp"
#include "clause.hpp"
int main(int argc, char **argv) {

View File

@ -1,10 +1,10 @@
#include "light.hpp"
#include "workers/basesolver.hpp"
#include "solver_api/basesolver.hpp"
#include "sharer.hpp"
#include "unordered_map"
#include "workers/clause.hpp"
#include "clause.hpp"
#include <unistd.h>
#include "distributed/comm_tag.h"
#include "comm_tag.h"
#include <boost/thread/thread.hpp>
int nums = 0;

View File

@ -3,7 +3,7 @@
#include "paras.hpp"
#include <boost/thread.hpp>
#include "utils/vec.hpp"
#include "./workers/clause.hpp"
#include "clause.hpp"
class basesolver;
class sharer {

View File

@ -1,5 +1,5 @@
#include "light.hpp"
#include "workers/basekissat.hpp"
#include "solver_api/basekissat.hpp"
#include "sharer.hpp"
#include "paras.hpp"
#include <unistd.h>

View File

@ -3,7 +3,7 @@
#include "../light.hpp"
#include "../utils/vec.hpp"
#include "clause.hpp"
#include "../clause.hpp"
#include <fstream>
#include <iostream>
#include <boost/thread.hpp>

View File

@ -4,9 +4,9 @@
#include <ctime>
#include <mpi.h>
#include "../light.hpp"
#include "../utils/cmdline.h"
#include "../paras.hpp"
#include "light.hpp"
#include "utils/cmdline.h"
#include "paras.hpp"
#include "comm_tag.h"
void worker_main(light* S, int num_procs, int rank) {