16
16
17
17
using namespace std ;
18
18
19
- block_queue<Item *> *blockQueue = new block_queue<Item *>(1024 );
19
+ block_queue<Item *> *blockQueue = new block_queue<Item *>(1024 * 1024 );
20
20
21
21
#define MAIN_THREAD_RUNNING 1
22
22
#define MAIN_THREAD_WAITING 0
@@ -41,7 +41,7 @@ void mainThreadTellFinished(int thisRank, int world_size) {
41
41
itemStop->tarRank = i;
42
42
itemStop->pack = buf;
43
43
if (nullptr == blockQueue) cerr << " Cannot create blocking queue." << endl;
44
- blockQueue->push (itemStop);
44
+ if (! blockQueue->push (itemStop)) cerr << " Cannot push stop signal. " << endl ;
45
45
itemStop = nullptr ;
46
46
buf = nullptr ;
47
47
packSizeStop = 0 ;
@@ -95,7 +95,7 @@ void requestOtherRanksToStoreEdge(int currank, int world_size, const char *value
95
95
int packSize = 0 ;
96
96
int strLen = getK ();
97
97
int op = EDGE_STORE_OP;
98
- int tarrank = edgeId % world_size;
98
+ size_t tarrank = idBelongTo ( world_size, edgeId) ;
99
99
if (tarrank == currank) {
100
100
cerr << " Putting a edge belonging to this host to other hosts." << endl;
101
101
return ;
@@ -110,19 +110,19 @@ void requestOtherRanksToStoreEdge(int currank, int world_size, const char *value
110
110
// DEBUG
111
111
// MPI_Send(&packSize, 1, MPI_INT, tarrank, TAG(currank, tarrank), MPI_COMM_WORLD);
112
112
// MPI_Send(buf, packSize, MPI_PACKED, tarrank, TAG(currank, tarrank), MPI_COMM_WORLD);
113
- item->tarRank = tarrank;
113
+ item->tarRank = ( int ) tarrank;
114
114
item->pack = buf;
115
115
item->packSize = packSize;
116
116
if (nullptr == blockQueue) cerr << " Cannot create blocking queue." << endl;
117
- blockQueue->push (item);
117
+ if (! blockQueue->push (item)) cerr << " Cannot request new edge " << endl ;
118
118
}
119
119
120
120
void
121
121
requestOtherRanksToStoreVertex (int currank, int world_size, VertexId vertexId, EdgeId edgeId, VertexMode_t vertexMode) {
122
122
char *buf = new char [BUFFER_SIZE];
123
123
int packSize = 0 ;
124
124
int op = VERTEX_STORE_OP;
125
- int tarrank = vertexId % world_size;
125
+ size_t tarrank = idBelongTo ( world_size, vertexId) ;
126
126
if (tarrank == currank) {
127
127
cerr << " Putting a vertex belonging to this host to other hosts." << endl;
128
128
return ;
@@ -137,11 +137,11 @@ requestOtherRanksToStoreVertex(int currank, int world_size, VertexId vertexId, E
137
137
// MPI_Send(&packSize, 1, MPI_INT, tarrank, TAG(currank, tarrank), MPI_COMM_WORLD);
138
138
// MPI_Send(buf, packSize, MPI_PACKED, tarrank, TAG(currank, tarrank), MPI_COMM_WORLD);
139
139
140
- item->tarRank = tarrank;
140
+ item->tarRank = ( int ) tarrank;
141
141
item->pack = buf;
142
142
item->packSize = packSize;
143
143
if (nullptr == blockQueue) cerr << " Cannot create blocking queue." << endl;
144
- blockQueue->push (item);
144
+ if (! blockQueue->push (item)) cerr << " Cannot request new vertex " << endl ;
145
145
}
146
146
147
147
// 该方法负责char *指针的delete
@@ -160,10 +160,10 @@ int processRecvRead(const char *filename, size_t pos) {
160
160
// 该方法负责char *指针的delete
161
161
int processRecvEdge (EdgeList *edgeList, char *value, ReadId readId, KMERPOS_t kmerpos) {
162
162
string *strValue = new string (value, 0 , getK ()-1 );
163
- VertexId sourceVertex = getId (* strValue);
163
+ VertexId sourceVertex = getId (strValue-> c_str () );
164
164
delete strValue;
165
165
strValue = new string (value, 1 , getK ()-1 );
166
- VertexId sinkVertex = getId (* strValue);
166
+ VertexId sinkVertex = getId (strValue-> c_str () );
167
167
delete strValue;
168
168
int flag = addNewEdge (edgeList, value, sourceVertex, sinkVertex, readId, kmerpos);
169
169
delete[] value;
@@ -348,7 +348,9 @@ void *receiverRunner(void *args) {
348
348
int sendMsgSize = 0 ;
349
349
350
350
if (vertexList->count (vertexId) == 0 ) {
351
+ vertexList->at (vertexId);
351
352
cerr << " Cannot query the vertex #" << vertexId << endl;
353
+ cerr << thisRank << endl;
352
354
queryStatus = FAILED_QUERY;
353
355
} else {
354
356
// vertex存在时
@@ -361,13 +363,15 @@ void *receiverRunner(void *args) {
361
363
// 并行环境下不能使用tangleList->count(vertexId) != 0来判断是否为tangle
362
364
queryStatus = TANGLE_QUERY;
363
365
Vertex *thisVertex = vertexList->at (vertexId);
364
- edgeId = *thisVertex->outKMer ->begin ();
366
+ /* edgeId = *thisVertex->outKMer->begin();
365
367
// 删除vertex的一个出度
366
- removeOutEdge (vertexList, vertexId, edgeId);
368
+ removeOutEdge(vertexList, vertexId, edgeId);*/
369
+ getAndRemoveOutEdge (vertexList, vertexId, &edgeId); // 保护并行环境下的删除节点
367
370
}else {
368
- edgeId = *thisVertex->outKMer ->begin ();
371
+ /* edgeId = *thisVertex->outKMer->begin();
369
372
// 删除vertex的一个出度
370
- removeOutEdge (vertexList, vertexId, edgeId);
373
+ removeOutEdge(vertexList, vertexId, edgeId);*/
374
+ getAndRemoveOutEdge (vertexList, vertexId, &edgeId); // 保护并行环境下的删除节点
371
375
queryStatus = SUCCESSFUL_QUERY;
372
376
}
373
377
}
0 commit comments