Skip to content

Commit

Permalink
Fixed overflow on park buffers with -z > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
haorldbchi committed Aug 29, 2023
1 parent a99fe73 commit 46029fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cuda/CudaPlotter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,7 @@ void AllocateParkSerializationBuffers( CudaK32PlotContext& cx, IAllocator& pinne
// Get the largest park size
const size_t maxParkSize = cx.cfg.gCfg->compressionLevel == 0 ?
CalculateParkSize( TableId::Table1 ) :
GetCompressionInfoForLevel( cx.cfg.gCfg->compressionLevel ).tableParkSize;
GetLargestCompressedParkSize();

const size_t parksPerBuffer = CDivT<size_t>( BBCU_BUCKET_ALLOC_ENTRY_COUNT, kEntriesPerPark ) + 2;
// CDiv( BBCU_BUCKET_ALLOC_ENTRY_COUNT, kCheckpoint1Interval ) + 1; // Need an extra park for left-over entries
Expand Down
16 changes: 16 additions & 0 deletions src/plotting/Compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "plotting/FSETableGenerator.h"
#include "util/Util.h"
#include <mutex>
#include <algorithm>

// Caches for C and D tables
static std::atomic<FSE_CTable*> _cTableCache[32] = {};
Expand Down Expand Up @@ -140,4 +141,19 @@ uint32 GetCompressedLPBitCount( const uint32 compressionLevel )
// lpBitSize = lpBitSize * 2 - 1;

return lpBitSize * 2 - 1;
}

size_t GetLargestCompressedParkSize()
{
return std::max( {
GetCompressionInfoForLevel( 1 ).tableParkSize,
GetCompressionInfoForLevel( 2 ).tableParkSize,
GetCompressionInfoForLevel( 3 ).tableParkSize,
GetCompressionInfoForLevel( 4 ).tableParkSize,
GetCompressionInfoForLevel( 5 ).tableParkSize,
GetCompressionInfoForLevel( 6 ).tableParkSize,
GetCompressionInfoForLevel( 7 ).tableParkSize,
GetCompressionInfoForLevel( 8 ).tableParkSize,
GetCompressionInfoForLevel( 9 ).tableParkSize }
);
}
1 change: 1 addition & 0 deletions src/plotting/Compression.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ FSE_CTable* CreateCompressionCTable( const uint32_t compressionLevel, size_t
FSE_DTable* CreateCompressionDTable( const uint32_t compressionLevel, size_t* outTableSize = nullptr );
CompressionInfo GetCompressionInfoForLevel( const uint32_t compressionLevel );
uint32_t GetCompressedLPBitCount( const uint32_t compressionLevel );
size_t GetLargestCompressedParkSize();

template<uint32_t level>
struct CompressionLevelInfo
Expand Down

0 comments on commit 46029fb

Please sign in to comment.