Skip to content

Commit

Permalink
Fix prefilter overflow instability
Browse files Browse the repository at this point in the history
  • Loading branch information
milot-mirdita committed Mar 3, 2020
1 parent e0f9718 commit 14014cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/prefiltering/CacheFriendlyOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ template<unsigned int BINSIZE> size_t CacheFriendlyOperations<BINSIZE>::mergeDia
while ( n != static_cast<size_t>(-1) )
{
const unsigned int element = binStartPos[n].id >> (MASK_0_5_BIT);
duplicateBitArray[element] = static_cast<unsigned char>(tmpElementBuffer[n].diagonal) + 1;
duplicateBitArray[element] = static_cast<unsigned char>(binStartPos[n].diagonal) + 1;
--n;
}
// combine diagonals
Expand All @@ -101,7 +101,7 @@ template<unsigned int BINSIZE> size_t CacheFriendlyOperations<BINSIZE>::mergeDia
output[doubleElementCount].diagonal = element.diagonal;
// std::cout << output[doubleElementCount].id << " " << (int)output[doubleElementCount].count << " " << (int)static_cast<unsigned char>(output[doubleElementCount].diagonal) << std::endl;
// memory overflow can not happen since input array = output array
doubleElementCount += (duplicateBitArray[hashBinElement] != static_cast<unsigned char>(tmpElementBuffer[n].diagonal)) ? 1 : 0;
doubleElementCount += (duplicateBitArray[hashBinElement] != static_cast<unsigned char>(binStartPos[n].diagonal)) ? 1 : 0;

duplicateBitArray[hashBinElement] = static_cast<unsigned char>(element.diagonal);
}
Expand Down Expand Up @@ -136,7 +136,7 @@ template<unsigned int BINSIZE> size_t CacheFriendlyOperations<BINSIZE>::mergeDup
output[doubleElementCount].diagonal = element.diagonal;
// memory overflow can not happen since input array = output array
doubleElementCount += (UNLIKELY(duplicateBitArray[hashBinElement] != 0 ) ) ? 1 : 0;
duplicateBitArray[hashBinElement] = static_cast<unsigned char>(tmpElementBuffer[n].diagonal);
duplicateBitArray[hashBinElement] = static_cast<unsigned char>(binStartPos[n].diagonal);
}
}
return doubleElementCount;
Expand All @@ -147,6 +147,7 @@ template<unsigned int BINSIZE> size_t CacheFriendlyOperations<BINSIZE>::findDupl
CounterResult * output,
size_t outputSize,
bool computeTotalScore) {
memset(duplicateBitArray, 0, duplicateBitArraySize * sizeof(unsigned char));
size_t doubleElementCount = 0;
const CounterResult * bin_ref_pointer = binDataFrame;
for (size_t bin = 0; bin < binCount; bin++) {
Expand Down

0 comments on commit 14014cd

Please sign in to comment.