LLNL / zfp

Compressed numerical arrays that support high-speed random access
http://zfp.llnl.gov
BSD 3-Clause "New" or "Revised" License
754 stars 152 forks source link

Issue with running the diffusion program in the examples folder #229

Closed TOMATOFQY closed 4 months ago

TOMATOFQY commented 4 months ago

I tried running the diffusion program in the examples folder using the following command:

./diffusion -c -R

with result:

...
time=0.997427 rate=47.574 (+5.000)
time=0.998202 rate=47.562 (+5.000)
time=0.998977 rate=47.543 (+5.000)
time=0.999752 rate=47.559 (+5.000)
sum=0.998346 error=1.212716e-07

I expected this to be a lossless decompression, but the result still has errors. Is my understanding of lossless incorrect, or am I using the parameters incorrectly?

I have read the official website's description of the loseless function, but I still haven't found the correct usage method.

lindstro commented 4 months ago

The error is measured with respect to the analytical continuous solution to this partial differential equation. Because of finite precision and discretization of the PDE, there will always be a small non-zero error. You'll see that running with double precision (./diffusion with no arguments), the same error is observed.

TOMATOFQY commented 4 months ago

I think I have a terrible misunderstanding here, as I did not fully grasp the purpose of the program. Thank you for taking the time to provide a helpful response to this issue.

Additionally, I believe I have figured out the -R option for reversible mode. I noticed that in the diffusion.cpp file, only the rate field in the zfp_config variable is used to initialize zfp::array2, and not the mode. Furthermore, I found that zfp::const_array2 might be used for true lossless compression, as it does take a zfp_config as input.

Lastly, I would like to express my gratitude once again for your time and assistance with this issue. ZFP is a great tool, and it has been very helpful to me.

lindstro commented 4 months ago

No worries. Admittedly this example is not all that self explanatory when it comes to the output it produces. Its main purpose is not to evaluate rounding errors (as other errors also contribute) or performance, but rather to show how to use the zfp array API in various ways to solve this simple numerical problem, e.g., using fixed- and variable-rate arrays, using indexing vs. iterators, using single- and multi-threading, etc.

Unless you have any other questions about this example, I'd like to go ahead and close this issue.