From 573dbd8387c9c26543919078ef7fc6252bf5c90a Mon Sep 17 00:00:00 2001 From: Yohann Uguen Date: Tue, 28 Feb 2023 02:11:19 -0800 Subject: [PATCH 1/2] device to shared in IPA mode Signed-off-by: Yohann Uguen --- .../decompress/src/gzip/gzip_decompressor.hpp | 27 ++++++++++++++++++- .../ReferenceDesigns/decompress/src/main.cpp | 25 +++++------------ .../src/snappy/snappy_decompressor.hpp | 20 +++++++++++++- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/gzip/gzip_decompressor.hpp b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/gzip/gzip_decompressor.hpp index 97d601e65e..6071f19035 100644 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/gzip/gzip_decompressor.hpp +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/gzip/gzip_decompressor.hpp @@ -157,6 +157,7 @@ class GzipDecompressor : public DecompressorBase { bool passed = true; try { +#if defined (IS_BSP) // allocate memory on the device if ((in = sycl::malloc_device(in_count, q)) == nullptr) { std::cerr << "ERROR: could not allocate space for 'in'\n"; @@ -179,6 +180,30 @@ class GzipDecompressor : public DecompressorBase { std::cerr << "ERROR: could not allocate space for 'count'\n"; std::terminate(); } +#else + // allocate shared memory + if ((in = sycl::malloc_shared(in_count, q)) == nullptr) { + std::cerr << "ERROR: could not allocate space for 'in'\n"; + std::terminate(); + } + if ((out = sycl::malloc_shared(out_count_padded, q)) == + nullptr) { + std::cerr << "ERROR: could not allocate space for 'out'\n"; + std::terminate(); + } + if ((hdr_data = sycl::malloc_shared(1, q)) == nullptr) { + std::cerr << "ERROR: could not allocate space for 'hdr_data'\n"; + std::terminate(); + } + if ((crc = sycl::malloc_shared(1, q)) == nullptr) { + std::cerr << "ERROR: could not allocate space for 'crc'\n"; + std::terminate(); + } + if ((count = sycl::malloc_shared(1, q)) == nullptr) { + std::cerr << "ERROR: could not allocate space for 'count'\n"; + std::terminate(); + } +#endif // copy the input data to the device memory and wait for the copy to // finish @@ -297,4 +322,4 @@ class GzipDecompressor : public DecompressorBase { } }; -#endif /* __GZIP_DECOMPRESSOR_HPP__ */ \ No newline at end of file +#endif /* __GZIP_DECOMPRESSOR_HPP__ */ diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp index 73ae756d15..d2c9df3562 100644 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/main.cpp @@ -18,6 +18,8 @@ #include "common/common.hpp" #include "exception_handler.hpp" +using namespace sycl; + // ensure only one of GZIP and SNAPPY is defined #if defined(GZIP) and defined(SNAPPY) static_assert(false, "Only one of GZIP and SNAPPY can be defined!"); @@ -67,8 +69,6 @@ bool RunSnappyTest(sycl::queue& q, SnappyDecompressorT decompressor, std::string decompressor_name = "SNAPPY"; #endif -using namespace sycl; - // Prints the usage for the executable command line args void PrintUsage(std::string exe_name) { std::cerr << "USAGE: \n" @@ -240,23 +240,6 @@ bool RunGzipTest(sycl::queue& q, GzipDecompressorT decompressor, 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"; auto in_bytes = ReadInputFile(alice_in_file); @@ -270,6 +253,10 @@ bool RunSnappyTest(sycl::queue& q, SnappyDecompressorT decompressor, PrintTestResults("Alice In Wonderland Test", alice_test_pass); std::cout << std::endl; +#ifdef FPGA_SIMULATOR + return alice_test_pass; +#else + 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); diff --git a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/snappy/snappy_decompressor.hpp b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/snappy/snappy_decompressor.hpp index 444e5720ca..4479f4b7e1 100644 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/snappy/snappy_decompressor.hpp +++ b/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/src/snappy/snappy_decompressor.hpp @@ -150,6 +150,7 @@ class SnappyDecompressor : public DecompressorBase { unsigned* preamble_count; try { +#if defined (IS_BSP) // allocate memory on the device for the input and output if ((in = sycl::malloc_device(in_count_padded, q)) == nullptr) { @@ -165,6 +166,23 @@ class SnappyDecompressor : public DecompressorBase { std::cerr << "ERROR: could not allocate space for 'preamble_count'\n"; std::terminate(); } +#else + // allocate shared memory + if ((in = sycl::malloc_shared(in_count_padded, q)) == + nullptr) { + std::cerr << "ERROR: could not allocate space for 'in'\n"; + std::terminate(); + } + if ((out = sycl::malloc_shared(out_count_padded, q)) == + nullptr) { + std::cerr << "ERROR: could not allocate space for 'out'\n"; + std::terminate(); + } + if ((preamble_count = sycl::malloc_shared(1, q)) == nullptr) { + std::cerr << "ERROR: could not allocate space for 'preamble_count'\n"; + std::terminate(); + } +#endif // copy the input data to the device memory and wait for the copy to // finish @@ -260,4 +278,4 @@ class SnappyDecompressor : public DecompressorBase { } }; -#endif /* __SNAPPY_DECOMPRESSOR_HPP__ */ \ No newline at end of file +#endif /* __SNAPPY_DECOMPRESSOR_HPP__ */ From a593f009a9eaa88ada141fa3403c4720145e8e0f Mon Sep 17 00:00:00 2001 From: Yohann Uguen Date: Wed, 1 Mar 2023 00:10:58 -0800 Subject: [PATCH 2/2] remove unused files Signed-off-by: Yohann Uguen --- .../data/snappy/alice29_small.ref.txt | 23 ------------------ .../data/snappy/alice29_small.txt.sz | Bin 409 -> 0 bytes 2 files changed, 23 deletions(-) delete mode 100644 DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.ref.txt delete mode 100644 DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.txt.sz 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 deleted file mode 100644 index cdb4303a19..0000000000 --- a/DirectProgramming/C++SYCL_FPGA/ReferenceDesigns/decompress/data/snappy/alice29_small.ref.txt +++ /dev/null @@ -1,23 +0,0 @@ - - - - - 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 deleted file mode 100644 index 4374d4cec71da029554f2cb7756651d31648a0b2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 409 zcmWNLK}+LM6ovDog|?W5`zf4VWvn6&3}YD>LX)A97$vqN<3fCCUXy3byYk+xL2%*H zpWwo+Yv(7-8ICG=*51gq6t98BgleV;WFnX z8d-&d2c;hTv^GrLkKK}JJzRF*e^@0eFEK{BWoQoVb2jlJROzvL@qv w->1g7^L(_8^c~l|{jznQxPt7~`{PkK;D)w!!-xIeU8}`jhjDuobbgKg0~cL+EC2ui