[pzstd] Fix and test 32 bit support
parent
5c9adff7f8
commit
0a5910b23b
|
@ -30,7 +30,7 @@ else
|
||||||
EXT =
|
EXT =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: default all test clean
|
.PHONY: default all test clean test32 googletest googletest32
|
||||||
|
|
||||||
default: pzstd
|
default: pzstd
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ libzstd.a: $(ZSTD_FILES)
|
||||||
$(MAKE) -C $(ZSTDDIR) libzstd
|
$(MAKE) -C $(ZSTDDIR) libzstd
|
||||||
@cp $(ZSTDDIR)/libzstd.a .
|
@cp $(ZSTDDIR)/libzstd.a .
|
||||||
|
|
||||||
|
|
||||||
Pzstd.o: Pzstd.h Pzstd.cpp ErrorHolder.h utils/*.h
|
Pzstd.o: Pzstd.h Pzstd.cpp ErrorHolder.h utils/*.h
|
||||||
$(CXX) $(FLAGS) -c Pzstd.cpp -o $@
|
$(CXX) $(FLAGS) -c Pzstd.cpp -o $@
|
||||||
|
|
||||||
|
@ -57,20 +56,55 @@ main.o: main.cpp *.h utils/*.h
|
||||||
pzstd: Pzstd.o SkippableFrame.o Options.o main.o libzstd.a
|
pzstd: Pzstd.o SkippableFrame.o Options.o main.o libzstd.a
|
||||||
$(CXX) $(FLAGS) $^ -o $@$(EXT) -lpthread
|
$(CXX) $(FLAGS) $^ -o $@$(EXT) -lpthread
|
||||||
|
|
||||||
|
libzstd32.a: $(ZSTD_FILES)
|
||||||
|
$(MAKE) -C $(ZSTDDIR) libzstd MOREFLAGS="-m32"
|
||||||
|
@cp $(ZSTDDIR)/libzstd.a libzstd32.a
|
||||||
|
|
||||||
|
Pzstd32.o: Pzstd.h Pzstd.cpp ErrorHolder.h utils/*.h
|
||||||
|
$(CXX) -m32 $(FLAGS) -c Pzstd.cpp -o $@
|
||||||
|
|
||||||
|
SkippableFrame32.o: SkippableFrame.h SkippableFrame.cpp utils/*.h
|
||||||
|
$(CXX) -m32 $(FLAGS) -c SkippableFrame.cpp -o $@
|
||||||
|
|
||||||
|
Options32.o: Options.h Options.cpp
|
||||||
|
$(CXX) -m32 $(FLAGS) -c Options.cpp -o $@
|
||||||
|
|
||||||
|
main32.o: main.cpp *.h utils/*.h
|
||||||
|
$(CXX) -m32 $(FLAGS) -c main.cpp -o $@
|
||||||
|
|
||||||
|
pzstd32: Pzstd32.o SkippableFrame32.o Options32.o main32.o libzstd32.a
|
||||||
|
$(CXX) -m32 $(FLAGS) $^ -o $@$(EXT) -lpthread
|
||||||
|
|
||||||
googletest:
|
googletest:
|
||||||
|
@$(RM) -rf googletest
|
||||||
@git clone https://github.com/google/googletest
|
@git clone https://github.com/google/googletest
|
||||||
@mkdir -p googletest/build
|
@mkdir -p googletest/build
|
||||||
@cd googletest/build && cmake .. && make
|
@cd googletest/build && cmake .. && make
|
||||||
|
|
||||||
|
googletest32:
|
||||||
|
@$(RM) -rf googletest
|
||||||
|
@git clone https://github.com/google/googletest
|
||||||
|
@mkdir -p googletest/build
|
||||||
|
@cd googletest/build && cmake .. -DCMAKE_CXX_FLAGS=-m32 && make
|
||||||
|
|
||||||
test: libzstd.a Pzstd.o Options.o SkippableFrame.o
|
test: libzstd.a Pzstd.o Options.o SkippableFrame.o
|
||||||
$(MAKE) -C utils/test clean
|
$(MAKE) -C utils/test clean
|
||||||
$(MAKE) -C utils/test test
|
$(MAKE) -C utils/test test
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
$(MAKE) -C test test
|
$(MAKE) -C test test
|
||||||
|
|
||||||
|
test32:
|
||||||
|
$(MAKE) clean
|
||||||
|
$(MAKE) pzstd MOREFLAGS="-m32"
|
||||||
|
$(MAKE) -C utils/test clean
|
||||||
|
$(MAKE) -C utils/test test MOREFLAGS="-m32"
|
||||||
|
$(MAKE) -C test clean
|
||||||
|
$(MAKE) -C test test MOREFLAGS="-m32"
|
||||||
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C $(ZSTDDIR) clean
|
$(MAKE) -C $(ZSTDDIR) clean
|
||||||
$(MAKE) -C utils/test clean
|
$(MAKE) -C utils/test clean
|
||||||
$(MAKE) -C test clean
|
$(MAKE) -C test clean
|
||||||
@$(RM) -rf libzstd.a *.o pzstd$(EXT)
|
@$(RM) -rf libzstd.a *.o pzstd$(EXT) pzstd32$(EXT)
|
||||||
@echo Cleaning completed
|
@echo Cleaning completed
|
||||||
|
|
|
@ -333,10 +333,9 @@ static size_t calculateStep(
|
||||||
size_t step = size_t{1} << (params.cParams.windowLog + 2);
|
size_t step = size_t{1} << (params.cParams.windowLog + 2);
|
||||||
// If file size is known, see if a smaller step will spread work more evenly
|
// If file size is known, see if a smaller step will spread work more evenly
|
||||||
if (size != 0) {
|
if (size != 0) {
|
||||||
const std::uintmax_t newStep = size / std::uintmax_t{numThreads};
|
const std::uintmax_t newStep = size / numThreads;
|
||||||
if (newStep != 0 &&
|
if (newStep != 0 && newStep <= std::numeric_limits<size_t>::max()) {
|
||||||
newStep <= std::uintmax_t{std::numeric_limits<size_t>::max()}) {
|
step = std::min(step, static_cast<size_t>(newStep));
|
||||||
step = std::min(step, size_t{newStep});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return step;
|
return step;
|
||||||
|
|
|
@ -40,8 +40,6 @@ TEST(Pzstd, SmallSizes) {
|
||||||
for (unsigned numThreads = 1; numThreads <= 4; numThreads *= 2) {
|
for (unsigned numThreads = 1; numThreads <= 4; numThreads *= 2) {
|
||||||
for (unsigned level = 1; level <= 8; level *= 8) {
|
for (unsigned level = 1; level <= 8; level *= 8) {
|
||||||
auto errorGuard = makeScopeGuard([&] {
|
auto errorGuard = makeScopeGuard([&] {
|
||||||
guard.dismiss();
|
|
||||||
std::fprintf(stderr, "file: %s\n", inputFile.c_str());
|
|
||||||
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
||||||
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
||||||
std::fprintf(stderr, "compression level: %u\n", level);
|
std::fprintf(stderr, "compression level: %u\n", level);
|
||||||
|
@ -79,8 +77,6 @@ TEST(Pzstd, LargeSizes) {
|
||||||
for (unsigned numThreads = 1; numThreads <= 16; numThreads *= 4) {
|
for (unsigned numThreads = 1; numThreads <= 16; numThreads *= 4) {
|
||||||
for (unsigned level = 1; level <= 4; level *= 2) {
|
for (unsigned level = 1; level <= 4; level *= 2) {
|
||||||
auto errorGuard = makeScopeGuard([&] {
|
auto errorGuard = makeScopeGuard([&] {
|
||||||
guard.dismiss();
|
|
||||||
std::fprintf(stderr, "file: %s\n", inputFile.c_str());
|
|
||||||
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
std::fprintf(stderr, "pzstd headers: %u\n", headers);
|
||||||
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
std::fprintf(stderr, "# threads: %u\n", numThreads);
|
||||||
std::fprintf(stderr, "compression level: %u\n", level);
|
std::fprintf(stderr, "compression level: %u\n", level);
|
||||||
|
@ -98,6 +94,34 @@ TEST(Pzstd, LargeSizes) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Pzstd, ExtremelyLargeSize) {
|
||||||
|
unsigned seed = std::random_device{}();
|
||||||
|
std::fprintf(stderr, "Pzstd.ExtremelyLargeSize seed: %u\n", seed);
|
||||||
|
std::mt19937 gen(seed);
|
||||||
|
|
||||||
|
std::string inputFile = std::tmpnam(nullptr);
|
||||||
|
auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); });
|
||||||
|
|
||||||
|
{
|
||||||
|
// Write 4GB + 64 MB
|
||||||
|
constexpr size_t kLength = 1 << 26;
|
||||||
|
std::unique_ptr<uint8_t[]> buf(new uint8_t[kLength]);
|
||||||
|
auto fd = std::fopen(inputFile.c_str(), "wb");
|
||||||
|
auto closeGuard = makeScopeGuard([&] { std::fclose(fd); });
|
||||||
|
for (size_t i = 0; i < (1 << 6) + 1; ++i) {
|
||||||
|
RDG_genBuffer(buf.get(), kLength, 0.5, 0.0, gen());
|
||||||
|
auto written = std::fwrite(buf.get(), 1, kLength, fd);
|
||||||
|
ASSERT_EQ(written, kLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Options options;
|
||||||
|
options.overwrite = true;
|
||||||
|
options.inputFiles = {inputFile};
|
||||||
|
options.compressionLevel = 1;
|
||||||
|
ASSERT_TRUE(roundTrip(options));
|
||||||
|
}
|
||||||
|
|
||||||
TEST(Pzstd, ExtremelyCompressible) {
|
TEST(Pzstd, ExtremelyCompressible) {
|
||||||
std::string inputFile = std::tmpnam(nullptr);
|
std::string inputFile = std::tmpnam(nullptr);
|
||||||
auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); });
|
auto guard = makeScopeGuard([&] { std::remove(inputFile.c_str()); });
|
||||||
|
|
Loading…
Reference in New Issue