Skip to content

Commit

Permalink
bsc 3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaGrebnov committed Feb 16, 2023
1 parent 1259681 commit 55c0a70
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 19 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.3.0
3.3.1
50 changes: 34 additions & 16 deletions bsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -400,19 +406,25 @@ 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);
}

}

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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -647,6 +661,8 @@ void Decompression(char * argv[])
fprintf(stderr, "\nIO error on file: %s!\n", argv[3]);
exit(1);
}

outFileSize += (int)(dataSize);
}
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 <[email protected]>.\n\n");

#if defined(_OPENMP) && defined(__INTEL_COMPILER)
Expand Down
4 changes: 2 additions & 2 deletions libbsc/libbsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55c0a70

Please sign in to comment.