Update blosc2 tests#388
Conversation
0550b8b to
679fa60
Compare
|
Running tests with
|
|
Updates:
|
|
@alemirone there is still some issue with |
|
Hi Thomas, I reproduced the issue. The problem was specific to the OpenHTJ2K backend. The failing case was a stack written as one Blosc2 chunk with several 2D blocks, for example: shape = (10, 128, 128) In this situation Blosc2 can call the codec several times in parallel, once per 2D block. OpenHTJ2K itself has internal multithreading, but its C++ API does not seem to be safe when several encoder/decoder instances are called concurrently from outside. This produced the failure and the crash at process shutdown. I fixed it in blosc2_htj2k by serializing only the calls to the OpenHTJ2K backend. This keeps the internal multithreading of OpenHTJ2K, but avoids concurrent external calls from Blosc2 to multiple OpenHTJ2K instances. Kakadu does not show this problem. I tested the same case with the Kakadu backend and Blosc2 multithreading enabled: blosc2.set_nthreads(1, 2, 4, 8) All cases passed. So the summary is: OpenHTJ2K: internal backend multithreading is kept, but external concurrent Blosc2 calls are serialized. I prepared this as blosc2_htj2k 0.4.2. |
|
One more clarification: we should not confuse Blosc2 external threading with the internal threading/tuning of each backend. Blosc2 threading controls how many Blosc2 blocks can be processed in parallel: blosc2.set_nthreads(n) Backend threading is a separate layer. For now, these backend-specific settings are mostly controlled through environment variables. For Kakadu: BLOSC2_HTJ2K_KAKADU_THREADS=N This controls Kakadu's internal kdu_thread_env. Values 0 or 1 mean no Kakadu thread environment; values >1 enable Kakadu internal threading. In practice, N is the intended total Kakadu thread count, including the calling thread. Other Kakadu tuning variables currently supported are: BLOSC2_HTJ2K_KAKADU_PRECISE=0/1 For OpenHTJ2K: there is currently no public environment variable exposed by our wrapper for the internal thread count. The wrapper currently calls OpenHTJ2K with num_threads=0: openhtj2k_encoder(..., num_threads=0) In OpenHTJ2K, 0 means the default/all available internal threads. So the current situation is: Blosc2 external threads: Kakadu internal threads: OpenHTJ2K internal threads: If you think it would be useful, we can expose these backend thread controls through the Python API as well, for example through configure() or a backend-specific settings function. For the moment they remain backend-specific environment variables. |
|
Tests pass with blosc2_htj2k 0.4.2, thanks for the fix |
closes #377