From 55c0a70d527642783e351ab68efd2b34f4286f60 Mon Sep 17 00:00:00 2001 From: Ilya Grebnov Date: Wed, 15 Feb 2023 20:41:22 -0800 Subject: [PATCH] bsc 3.3.1 --- CHANGES | 3 +++ VERSION | 2 +- bsc.cpp | 50 +++++++++++++++++++++++++++++++++---------------- libbsc/libbsc.h | 4 ++-- 4 files changed, 40 insertions(+), 19 deletions(-) diff --git a/CHANGES b/CHANGES index 1f9563f..1331eb9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +Changes in 3.3.1 (February, 15 2023) +- Added ability to specify block size in bytes as oppose to megabytes. + Changes in 3.3.0 (February, 10 2023) - Improved GPU acceleration performance of forward ST algorithm. - Implemented GPU acceleration of forward Burrows–Wheeler transform. diff --git a/VERSION b/VERSION index 0fa4ae4..712bd5a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.3.0 \ No newline at end of file +3.3.1 \ No newline at end of file diff --git a/bsc.cpp b/bsc.cpp index 2c698d7..ff39d60 100644 --- a/bsc.cpp +++ b/bsc.cpp @@ -140,8 +140,10 @@ void Compression(char * argv[]) exit(1); } - BSC_FILEOFFSET fileSize = BSC_FTELL(fInput); - if (fileSize < 0) + BSC_FILEOFFSET inFileSize = BSC_FTELL(fInput); + BSC_FILEOFFSET outFileSize = 0; + + if (inFileSize < 0) { fprintf(stderr, "IO error on file: %s!\n", argv[2]); exit(1); @@ -153,9 +155,9 @@ void Compression(char * argv[]) exit(1); } - if (paramBlockSize > fileSize) + if (paramBlockSize > inFileSize) { - paramBlockSize = (int)fileSize; + paramBlockSize = (int)inFileSize; } if (fwrite(bscFileSign, sizeof(bscFileSign), 1, fOutput) != 1) @@ -164,13 +166,17 @@ void Compression(char * argv[]) exit(1); } - int nBlocks = paramBlockSize > 0 ? (int)((fileSize + paramBlockSize - 1) / paramBlockSize) : 0; + outFileSize += (int)(sizeof(bscFileSign)); + + int nBlocks = paramBlockSize > 0 ? (int)((inFileSize + paramBlockSize - 1) / paramBlockSize) : 0; if (fwrite(&nBlocks, sizeof(nBlocks), 1, fOutput) != 1) { fprintf(stderr, "IO error on file: %s!\n", argv[3]); exit(1); } + outFileSize += (int)(sizeof(nBlocks)); + double startTime = BSC_CLOCK(); #ifdef LIBBSC_OPENMP @@ -213,13 +219,13 @@ void Compression(char * argv[]) #pragma omp critical(input) #endif { - if ((feof(fInput) == 0) && (BSC_FTELL(fInput) != fileSize)) + if ((feof(fInput) == 0) && (BSC_FTELL(fInput) != inFileSize)) { #ifdef LIBBSC_OPENMP #pragma omp master #endif { - double progress = (100.0 * (double)BSC_FTELL(fInput)) / fileSize; + double progress = (100.0 * (double)BSC_FTELL(fInput)) / inFileSize; fprintf(stdout, "\rCompressing %.55s(%02d%%)", argv[2], (int)progress); fflush(stdout); } @@ -400,11 +406,15 @@ void Compression(char * argv[]) exit(1); } + outFileSize += (int)(sizeof(BSC_BLOCK_HEADER)); + if ((int)fwrite(buffer, 1, blockSize, fOutput) != blockSize) { fprintf(stderr, "\nIO error on file: %s!\n", argv[3]); exit(1); } + + outFileSize += (int)(blockSize); } } @@ -412,7 +422,9 @@ void Compression(char * argv[]) bsc_free(buffer); } - fprintf(stdout, "\r%.55s compressed %.0f into %.0f in %.3f seconds.\n", argv[2], (double)fileSize, (double)BSC_FTELL(fOutput), BSC_CLOCK() - startTime); + startTime = BSC_CLOCK() - startTime; + + fprintf(stdout, "\r%.55s encoded %.0f => %.0f in %.3fs (%.2f MB/s)\n", argv[2], (double)inFileSize, (double)outFileSize, startTime, ((double)inFileSize) / 1000000.0 / startTime); fclose(fInput); fclose(fOutput); } @@ -439,8 +451,10 @@ void Decompression(char * argv[]) exit(1); } - BSC_FILEOFFSET fileSize = BSC_FTELL(fInput); - if (fileSize < 0) + BSC_FILEOFFSET inFileSize = BSC_FTELL(fInput); + BSC_FILEOFFSET outFileSize = 0; + + if (inFileSize < 0) { fprintf(stderr, "IO error on file: %s!\n", argv[2]); exit(1); @@ -503,13 +517,13 @@ void Decompression(char * argv[]) #pragma omp critical(input) #endif { - if ((feof(fInput) == 0) && (BSC_FTELL(fInput) != fileSize)) + if ((feof(fInput) == 0) && (BSC_FTELL(fInput) != inFileSize)) { #ifdef LIBBSC_OPENMP #pragma omp master #endif { - double progress = (100.0 * (double)BSC_FTELL(fInput)) / fileSize; + double progress = (100.0 * (double)BSC_FTELL(fInput)) / inFileSize; fprintf(stdout, "\rDecompressing %.55s(%02d%%)", argv[2], (int)progress); fflush(stdout); } @@ -647,6 +661,8 @@ void Decompression(char * argv[]) fprintf(stderr, "\nIO error on file: %s!\n", argv[3]); exit(1); } + + outFileSize += (int)(dataSize); } } @@ -659,7 +675,9 @@ void Decompression(char * argv[]) exit(1); } - fprintf(stdout, "\r%.55s decompressed %.0f into %.0f in %.3f seconds.\n", argv[2], (double)fileSize, (double)BSC_FTELL(fOutput), BSC_CLOCK() - startTime); + startTime = BSC_CLOCK() - startTime; + + fprintf(stdout, "\r%.55s decoded %.0f => %.0f in %.3fs (%.2f MB/s)\n", argv[2], (double)inFileSize, (double)outFileSize, startTime, ((double)outFileSize) / 1000000.0 / startTime); fclose(fInput); fclose(fOutput); } @@ -739,8 +757,8 @@ void ProcessSwitch(char * s) case 'b': { char * strNum = s; while ((*s >= '0') && (*s <= '9')) s++; - paramBlockSize = atoi(strNum) * 1024 * 1024; - if ((paramBlockSize < 1024 * 1024) || (paramBlockSize > 2047 * 1024 * 1024)) ShowUsage(); + paramBlockSize = atoi(strNum); if (paramBlockSize < 100000) paramBlockSize *= 1024 * 1024; + if ((paramBlockSize < 100000) || (paramBlockSize > 2047 * 1024 * 1024)) ShowUsage(); break; } @@ -851,7 +869,7 @@ void ProcessCommandline(int argc, char * argv[]) int main(int argc, char * argv[]) { - fprintf(stdout, "This is bsc, Block Sorting Compressor. Version 3.3.0. 10 February 2023.\n"); + fprintf(stdout, "This is bsc, Block Sorting Compressor. Version 3.3.1. 15 February 2023.\n"); fprintf(stdout, "Copyright (c) 2009-2023 Ilya Grebnov .\n\n"); #if defined(_OPENMP) && defined(__INTEL_COMPILER) diff --git a/libbsc/libbsc.h b/libbsc/libbsc.h index 29da2a9..38e294f 100644 --- a/libbsc/libbsc.h +++ b/libbsc/libbsc.h @@ -35,8 +35,8 @@ See also the bsc and libbsc web site: #define LIBBSC_VERSION_MAJOR 3 #define LIBBSC_VERSION_MINOR 3 -#define LIBBSC_VERSION_PATCH 0 -#define LIBBSC_VERSION_STRING "3.3.0" +#define LIBBSC_VERSION_PATCH 1 +#define LIBBSC_VERSION_STRING "3.3.1" #define LIBBSC_NO_ERROR 0 #define LIBBSC_BAD_PARAMETER -1