Skip to content

Commit 9a8d4cb

Browse files
authored
Merge pull request #1074 from sooyoung-cha/dec
solved issue #1073
2 parents bd01c22 + 9c3cee8 commit 9a8d4cb

File tree

1 file changed

+38
-31
lines changed

1 file changed

+38
-31
lines changed

src/clustering/ClusteringAlgorithms.cpp

Lines changed: 38 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -295,41 +295,48 @@ void ClusteringAlgorithms::greedyIncrementalLowMem( unsigned int *assignedcluste
295295
}
296296

297297
// Parallel reading and parsing into buffer
298-
#pragma omp parallel for schedule(dynamic, 4)
299-
for (long i = start; i < end; i++) {
300-
unsigned int clusterKey = seqDbr->getDbKey(i);
301-
std::vector<unsigned int>& keys = buffer[i - start].second;
302-
if(needSET) {
303-
size_t start1 = sourceOffsets[clusterKey];
304-
size_t end1 = sourceOffsets[clusterKey+1];
305-
size_t len = end1 - start1;
306-
for (size_t j = 0; j < len; ++j) {
307-
unsigned int value = sourceLookupTable[clusterKey][j];
308-
if (value != UINT_MAX) {
309-
const size_t alnId = alnDbr->getId(value);
310-
char *data = alnDbr->getData(alnId, 0);
311-
while (*data != '\0') {
312-
char dbKey[255 + 1];
313-
Util::parseKey(data, dbKey);
314-
const unsigned int key = keyToSet[(unsigned int)strtoul(dbKey, NULL, 10)];
315-
keys.push_back(key);
316-
data = Util::skipLine(data);
298+
#pragma omp parallel
299+
{
300+
int thread_idx = 0;
301+
#ifdef OPENMP
302+
thread_idx = (unsigned int) omp_get_thread_num();
303+
#endif
304+
#pragma omp for schedule(dynamic, 4)
305+
for (long i = start; i < end; i++) {
306+
unsigned int clusterKey = seqDbr->getDbKey(i);
307+
std::vector<unsigned int>& keys = buffer[i - start].second;
308+
if(needSET) {
309+
size_t start1 = sourceOffsets[clusterKey];
310+
size_t end1 = sourceOffsets[clusterKey+1];
311+
size_t len = end1 - start1;
312+
for (size_t j = 0; j < len; ++j) {
313+
unsigned int value = sourceLookupTable[clusterKey][j];
314+
if (value != UINT_MAX) {
315+
const size_t alnId = alnDbr->getId(value);
316+
char *data = alnDbr->getData(alnId, thread_idx);
317+
while (*data != '\0') {
318+
char dbKey[255 + 1];
319+
Util::parseKey(data, dbKey);
320+
const unsigned int key = keyToSet[(unsigned int)strtoul(dbKey, NULL, 10)];
321+
keys.push_back(key);
322+
data = Util::skipLine(data);
323+
}
317324
}
318325
}
326+
} else {
327+
const size_t alnId = alnDbr->getId(clusterKey);
328+
char* data = alnDbr->getData(alnId, thread_idx);
329+
while (*data != '\0') {
330+
char dbKey[255 + 1];
331+
Util::parseKey(data, dbKey);
332+
const unsigned int key = (unsigned int)strtoul(dbKey, NULL, 10);
333+
keys.push_back(key);
334+
data = Util::skipLine(data);
335+
}
319336
}
320-
} else {
321-
const size_t alnId = alnDbr->getId(clusterKey);
322-
char* data = alnDbr->getData(alnId, 0);
323-
while (*data != '\0') {
324-
char dbKey[255 + 1];
325-
Util::parseKey(data, dbKey);
326-
const unsigned int key = (unsigned int)strtoul(dbKey, NULL, 10);
327-
keys.push_back(key);
328-
data = Util::skipLine(data);
329-
}
330-
}
331337

332-
buffer[i - start].first = i;
338+
buffer[i - start].first = i;
339+
}
333340
}
334341

335342
// Sequential processing of the buffer

0 commit comments

Comments
 (0)