子句共享数据变成全局变量
This commit is contained in:
parent
8b2e1f38ec
commit
47d72f3b23
@ -6,7 +6,12 @@
|
||||
#include "../distributed/comm_tag.h"
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
void share_clauses_to_next_node(std::vector<std::pair<MPI_Request, int*>> &send_data_struct, const vec<clause_store *> &cls) {
|
||||
const int BUF_SIZE = 1024 * 1024;
|
||||
std::vector<std::pair<MPI_Request, int*>> send_data_struct;
|
||||
MPI_Request receive_request;
|
||||
int buf[BUF_SIZE];
|
||||
|
||||
void share_clauses_to_next_node(const vec<clause_store *> &cls) {
|
||||
|
||||
// 清理 send_data_struct,把发送完毕的发送数据结构清理掉
|
||||
for(int i=0; i<send_data_struct.size(); i++) {
|
||||
@ -64,9 +69,9 @@ void share_clauses_to_next_node(std::vector<std::pair<MPI_Request, int*>> &send_
|
||||
LOGGER->info("send clauses: %v", send_length);
|
||||
}
|
||||
|
||||
const int BUF_SIZE = 1024 * 1024;
|
||||
|
||||
bool receive_clauses_from_last_node(MPI_Request &receive_request, int *buf, vec<clause_store*> &clauses) {
|
||||
|
||||
bool receive_clauses_from_last_node(vec<clause_store*> &clauses) {
|
||||
clauses.clear();
|
||||
|
||||
int flag;
|
||||
@ -115,18 +120,12 @@ void * share_worker(void *arg) {
|
||||
auto clk_st = std::chrono::high_resolution_clock::now();
|
||||
double share_time = 0;
|
||||
|
||||
std::vector<std::pair<MPI_Request, int*>> send_data_struct;
|
||||
// int num_procs, rank;
|
||||
// MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
|
||||
// MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
|
||||
MPI_Request receive_request;
|
||||
|
||||
int buf[BUF_SIZE];
|
||||
|
||||
int num_procs, rank;
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
||||
|
||||
int from = (rank - 2 + num_procs - 1) % (num_procs - 1) + 1;
|
||||
MPI_Irecv(buf, BUF_SIZE, MPI_INT, from, SHARE_CLAUSES_TAG, MPI_COMM_WORLD, &receive_request);
|
||||
// int from = (rank - 2 + num_procs - 1) % (num_procs - 1) + 1;
|
||||
// MPI_Irecv(buf, BUF_SIZE, MPI_INT, from, SHARE_CLAUSES_TAG, MPI_COMM_WORLD, &receive_request);
|
||||
|
||||
while (true) {
|
||||
++nums;
|
||||
@ -139,31 +138,31 @@ void * share_worker(void *arg) {
|
||||
for (int i = 0; i < sq->producers.size(); i++) {
|
||||
sq->cls.clear();
|
||||
sq->producers[i]->export_clauses_to(sq->cls);
|
||||
printf("c size %d\n", sq->cls.size());
|
||||
|
||||
//printf("c size %d\n", sq->cls.size());
|
||||
|
||||
int number = sq->cls.size();
|
||||
|
||||
LOGGER->info("thread-%v: get %v exported clauses", i, number);
|
||||
|
||||
// //分享当前节点产生的子句
|
||||
// if(sq->cls.size() > 0) share_clauses_to_next_node(sq->cls);
|
||||
|
||||
//分享当前节点产生的子句
|
||||
//if(sq->cls.size() > 0) share_clauses_to_next_node(send_data_struct, sq->cls);
|
||||
|
||||
|
||||
// 导入外部网络传输的子句
|
||||
// // 导入外部网络传输的子句
|
||||
// vec<clause_store*> clauses;
|
||||
// if(receive_clauses_from_last_node(receive_request, buf, clauses)) {
|
||||
// // for (int j = 0; j < sq->consumers.size(); j++) {
|
||||
// // for (int k = 0; k < clauses.size(); k++)
|
||||
// // clauses[k]->increase_refs(1);
|
||||
// // sq->consumers[j]->import_clauses_from(clauses);
|
||||
// // }
|
||||
// if(receive_clauses_from_last_node(clauses)) {
|
||||
// for (int j = 0; j < sq->consumers.size(); j++) {
|
||||
// for (int k = 0; k < clauses.size(); k++)
|
||||
// clauses[k]->increase_refs(1);
|
||||
// sq->consumers[j]->import_clauses_from(clauses);
|
||||
// }
|
||||
|
||||
// // // 传递外部网络传输的子句给下个节点
|
||||
// // share_clauses_to_next_node(send_data_struct, clauses);
|
||||
// // 传递外部网络传输的子句给下个节点
|
||||
// share_clauses_to_next_node(clauses);
|
||||
|
||||
// // for (int k = 0; k < clauses.size(); k++) {
|
||||
// // clauses[k]->free_clause();
|
||||
// // }
|
||||
// for (int k = 0; k < clauses.size(); k++) {
|
||||
// clauses[k]->free_clause();
|
||||
// }
|
||||
// }
|
||||
|
||||
// 导入当前节点产生的子句
|
||||
@ -172,15 +171,15 @@ void * share_worker(void *arg) {
|
||||
sq->producers[i]->broaden_export_limit();
|
||||
}
|
||||
else if (percent > 98) {
|
||||
//sq->producers[i]->restrict_export_limit();
|
||||
sq->producers[i]->restrict_export_limit();
|
||||
}
|
||||
|
||||
// for (int j = 0; j < sq->consumers.size(); j++) {
|
||||
// if (sq->producers[i]->id == sq->consumers[j]->id) continue;
|
||||
// for (int k = 0; k < sq->cls.size(); k++)
|
||||
// sq->cls[k]->increase_refs(1);
|
||||
// sq->consumers[j]->import_clauses_from(sq->cls);
|
||||
// }
|
||||
for (int j = 0; j < sq->consumers.size(); j++) {
|
||||
if (sq->producers[i]->id == sq->consumers[j]->id) continue;
|
||||
for (int k = 0; k < sq->cls.size(); k++)
|
||||
sq->cls[k]->increase_refs(1);
|
||||
sq->consumers[j]->import_clauses_from(sq->cls);
|
||||
}
|
||||
for (int k = 0; k < sq->cls.size(); k++) {
|
||||
sq->cls[k]->free_clause();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user