diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/README.md b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/README.md index 6a6365ad39..371de334cc 100755 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/README.md +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/README.md @@ -195,7 +195,7 @@ Snappy is compression format that aims for high throughput compression and decom Unlike many compression encodings, like DEFLATE, Snappy encoding is byte oriented. The Snappy format does not use entropy encoding, such as Huffman or range encoding. -Snappy encoding is like LZ77 encoding, which replaces portions of the byte stream with {length, distance} pairs. For more information on the Snappy format, see the [Snappy](https://en.wikipedia.org/wiki/Snappy_(compression)) Wikipedia article and the [Google Snappy](https://github.com/google/snappy) GitHub repository. +Snappy encoding is like LZ77 encoding, which replaces portions of the byte stream with {length, distance} pairs. For more information on the Snappy format, see the [Snappy](https://en.wikipedia.org/wiki/Snappy_(compression)) Wikipedia article and the [Google Snappy](https://github.com/google/snappy) GitHub repository. The files being decompressed in this tutorial have been compressed using [python-snappy](https://github.com/andrix/python-snappy) which is a python library for the snappy compression library from Google. The basic Snappy format is a *preamble* followed by the *compressed data stream*. diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/gzip/small.gz b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/gzip/small.gz new file mode 100644 index 0000000000..ca57c75193 Binary files /dev/null and b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/gzip/small.gz differ diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.ref.txt b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.ref.txt new file mode 100644 index 0000000000..cdb4303a19 --- /dev/null +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.ref.txt @@ -0,0 +1,23 @@ + + + + + ALICE'S ADVENTURES IN WONDERLAND + + Lewis Carroll + + THE MILLENNIUM FULCRUM EDITION 2.9 + + + + + CHAPTER I + + Down the Rabbit-Hole + + + Alice was beginning to get very tired of sitting by her sister +on the bank, and of having nothing to do: once or twice she had +peeped into the book her sister was reading, but it had no +pictures or conversations in it, `and what is the use of a book,' +thought Alice `without pictures or conversation?' \ No newline at end of file diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.txt.sz b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.txt.sz new file mode 100644 index 0000000000..4374d4cec7 Binary files /dev/null and b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.txt.sz differ diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp index f4dca99219..37ac4b136f 100644 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp @@ -184,13 +184,26 @@ void PrintTestResults(std::string test_name, bool passed) { #if defined(GZIP) bool RunGzipTest(sycl::queue& q, GzipDecompressorT decompressor, const std::string test_dir) { + + +#ifdef FPGA_SIMULATOR + // the name of the file for the simulator is fixed + std::string small_filename = test_dir + "/small.gz"; + + std::cout << ">>>>> Small File Test <<<<<" << std::endl; + bool small_test_pass = decompressor.DecompressFile( + q, small_filename, "", 1, false, false); + PrintTestResults("Small File Test", small_test_pass); + std::cout << std::endl; + + return small_test_pass; +#else // the name of the files for the default test are fixed std::string uncompressed_filename = test_dir + "/uncompressed.gz"; std::string static_compress_filename = test_dir + "/static_compressed.gz"; std::string dynamic_compress_filename = test_dir + "/dynamic_compressed.gz"; std::string tp_test_filename = test_dir + "/tp_test.gz"; -#ifndef FPGA_SIMULATOR std::cout << ">>>>> Uncompressed File Test <<<<<" << std::endl; bool uncompressed_test_pass = decompressor.DecompressFile( q, uncompressed_filename, "", 1, false, false); @@ -202,12 +215,6 @@ bool RunGzipTest(sycl::queue& q, GzipDecompressorT decompressor, q, static_compress_filename, "", 1, false, false); PrintTestResults("Statically Compressed File Test", static_test_pass); std::cout << std::endl; -#else - std::cout << "Only running the Dynamically Compressed File Test when using " - "the simulator flow to reduce execution time." << std::endl; - bool uncompressed_test_pass = true; - bool static_test_pass = true; -#endif std::cout << ">>>>> Dynamically Compressed File Test <<<<<" << std::endl; bool dynamic_test_pass = decompressor.DecompressFile( @@ -215,32 +222,47 @@ bool RunGzipTest(sycl::queue& q, GzipDecompressorT decompressor, PrintTestResults("Dynamically Compressed File Test", dynamic_test_pass); std::cout << std::endl; - -#ifndef FPGA_SIMULATOR std::cout << ">>>>> Throughput Test <<<<<" << std::endl; constexpr int kTPTestRuns = 5; bool tp_test_pass = decompressor.DecompressFile(q, tp_test_filename, "", kTPTestRuns, true, false); PrintTestResults("Throughput Test", tp_test_pass); std::cout << std::endl; -#else - bool tp_test_pass = true; -#endif return uncompressed_test_pass && static_test_pass && dynamic_test_pass && - tp_test_pass; + tp_test_pass; +#endif + } #endif #if defined(SNAPPY) bool RunSnappyTest(sycl::queue& q, SnappyDecompressorT decompressor, const std::string test_dir) { + + +#ifdef FPGA_SIMULATOR + std::cout << ">>>>> Small Alice In Wonderland Test <<<<<" << std::endl; + std::string alice_in_file = test_dir + "/alice29_small.txt.sz"; + auto in_bytes = ReadInputFile(alice_in_file); + auto result = decompressor.DecompressBytes(q, in_bytes, 1, false); + + std::string alice_ref_file = test_dir + "/alice29_small.ref.txt"; + auto ref_bytes = ReadInputFile(alice_ref_file); + bool alice_test_pass = + (result != std::nullopt) && (result.value() == ref_bytes); + + PrintTestResults("Small Alice In Wonderland Test", alice_test_pass); + std::cout << std::endl; + return alice_test_pass; + +#else std::cout << ">>>>> Alice In Wonderland Test <<<<<" << std::endl; - std::string alice_in_file = test_dir + "/alice29.txt.sz"; + std::string alice_in_file = test_dir + "/alice29_small.txt.sz"; auto in_bytes = ReadInputFile(alice_in_file); auto result = decompressor.DecompressBytes(q, in_bytes, 1, false); - std::string alice_ref_file = test_dir + "/alice29.ref.txt"; + std::string alice_ref_file = test_dir + "/alice29_small.ref.txt"; auto ref_bytes = ReadInputFile(alice_ref_file); bool alice_test_pass = (result != std::nullopt) && (result.value() == ref_bytes); @@ -248,7 +270,6 @@ bool RunSnappyTest(sycl::queue& q, SnappyDecompressorT decompressor, PrintTestResults("Alice In Wonderland Test", alice_test_pass); std::cout << std::endl; -#ifndef FPGA_SIMULATOR std::cout << ">>>>> Only Literal Strings Test <<<<<" << std::endl; auto test1_bytes = GenerateSnappyCompressedData(333, 3, 0, 0, 3); auto test1_ret = decompressor.DecompressBytes(q, test1_bytes, 1, false); @@ -285,8 +306,6 @@ bool RunSnappyTest(sycl::queue& q, SnappyDecompressorT decompressor, return alice_test_pass && test1_pass && test2_pass && test3_pass && test_tp_pass; -#else - return alice_test_pass; #endif }