Skip to content

lz4: unbloc compressed stream using cython code when input data are on the cpu#4601

Open
kif wants to merge 13 commits into
silx-kit:mainfrom
kif:4598_lz4_unbloc_cpu
Open

lz4: unbloc compressed stream using cython code when input data are on the cpu#4601
kif wants to merge 13 commits into
silx-kit:mainfrom
kif:4598_lz4_unbloc_cpu

Conversation

@kif
Copy link
Copy Markdown
Member

@kif kif commented Jun 1, 2026

PR summary

AI Disclosure

  • No AI used
  • AI tool(s) ... used for ...

Close #4598

The performance variation: was 1.2ms, down to 650µs for a 4M Eiger image.

@kif kif requested review from pierrepaleo and t20100 June 1, 2026 16:11
@kif
Copy link
Copy Markdown
Member Author

kif commented Jun 1, 2026

With this patch, azimuthal integration as described in https://pyfai.readthedocs.io/en/stable/usage/tutorial/Parallelization/GPU-decompression.html goes from 1.76ms for processing an Eiger4M images to 1.09ms, on the same computer.

@kif
Copy link
Copy Markdown
Member Author

kif commented Jun 2, 2026

There is likely still a bug somewhere ... OpenCL get randomly killed.

## This is for developing:
##cython: profile=True, warn.undeclared=True, warn.unused=True, warn.unused_result=False, warn.unused_arg=True

"""This module provides :func:`_unblock_lz4` which scans a dataset for different blocks.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not putting unblock_lz4.pyx directly in silx.opencl.codec?

Regarding naming, it should be a private module _unblock_l4.pyx providing a public function unblock_lz4.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to dislike mixing python and cython code into the same directory, same for headers and c-code ... especially in the development phase where .c and .html files are likely to be generated in place and could end up polluting the repo.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the naming, it is correct that the module should be private.

return result


def _unblock_lz4(bytes src):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is more unlock_bitshuffle_lz4 rather than bare LZ4 code block

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, it looks to be specific to bitshuffle-LZ4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rewrite the lz4_unblock kernel into cython for performances

2 participants