forked from ErianArcher/RandomStringAssembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommunicator.h
113 lines (80 loc) · 2.95 KB
/
communicator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//
// Created by erianliang on 19-7-19.
//
#ifndef RANDOMSTRINGASSEMBLY_COMMUNICATOR_H
#define RANDOMSTRINGASSEMBLY_COMMUNICATOR_H
#include "entity/idset.h"
#include "entity/read.h"
#include "entity/k_minus_mer.h"
#include "entity/k_mer.h"
#include <mpi.h>
#if SIZE_MAX == UCHAR_MAX
#define my_MPI_SIZE_T MPI_UNSIGNED_CHAR
#elif SIZE_MAX == USHRT_MAX
#define my_MPI_SIZE_T MPI_UNSIGNED_SHORT
#elif SIZE_MAX == UINT_MAX
#define my_MPI_SIZE_T MPI_UNSIGNED
#elif SIZE_MAX == ULONG_MAX
#define my_MPI_SIZE_T MPI_UNSIGNED_LONG
#elif SIZE_MAX == ULLONG_MAX
#define my_MPI_SIZE_T MPI_UNSIGNED_LONG_LONG
#else
#define my_MPI_SIZE_T MPI_UNSIGNED_LONG
//#error "what is happening here?"
#endif
#define DONOTHIN_OP 0
#define EXIT_OP 1
#define READ_STORE_OP 11
#define EDGE_STORE_OP 21
#define EDGE_QUERY_OP 22
#define EDGE_FULL_QUERY_OP 23
#define VERTEX_STORE_OP 31
#define VERTEX_QUERY_OP 32
#define PREFIX_READ_OP 1
#define PREFIX_EDGE_OP 2
#define PREFIX_VERTEX_OP 3
// QUERY STATUS
#define FAILED_QUERY 0
#define SUCCESSFUL_QUERY 1
#define TANGLE_QUERY 31
#define SINK_QUERY 32
#define TAG(source, sink) (source) * 1000 + (sink)
#define QUERY_PACK_SIZE 12
// 只能容纳100个host
#define QUERY_TAG(querySource, querySink) (querySource) * 10000 + (querySink) * 100
struct threeLists {
int sourceRank;
VertexList *vertexList;
EdgeList *edgeList;
SetOfID *tangleList;
};
typedef struct threeLists RecvArg;
struct item {
int tarRank;
char *pack;
int packSize;
item();
virtual ~item();
};
typedef struct item Item;
void mainThreadTellRunning();
void mainThreadTellFinished(int thisRank, int world_size);
void requestRankToDoTest(int currank, int tarrank, const char *content);
void requestRankToStoreRead(int currank, int tarrank, const char *filename, size_t pos);
void requestOtherRanksToStoreEdge(int currank, int world_size,
const char *value, EdgeId edgeId, ReadId readId, KMERPOS_t kmerpos);
void requestOtherRanksToStoreVertex(int currank, int world_size,
VertexId vertexId, EdgeId edgeId, VertexMode_t vertexMode);
int processRecvRead(const char *filename, size_t pos);
int processRecvEdge(EdgeList *edgeList, char *value, ReadId readId, KMERPOS_t kmerpos);
// TODO: 记得tangle 判断
int processRecvVertex(VertexList *vertexList, SetOfID *tangleList, VertexId vertexId, EdgeId edgeId, VertexMode_t vertexMode);
void *senderRunner(void *arg);
void *testReceiverRunner(void *arg);
void *receiverRunner(void *recvArg);
void sendSuperContigToRankHead(int headrank, int currank, string &superContig);
string reduceSuperContigFromOthers(int currank, int world_size, string &superContig);
int queryEdgeById(string *pEdgeStr, int currank, int tarrank, EdgeId edgeId);
int queryOutEdgeOfVertexById(EdgeId *pEdgeId, int currank, int tarrank, VertexId vertexId);
int queryFullEdgeById(string *pString, int currank, int tarrank, EdgeId edgeId);
#endif //RANDOMSTRINGASSEMBLY_COMMUNICATOR_H