Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Futhark + Pyopencl-based GPU-bound entropy calculation #488

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

Ivanov1ch
Copy link
Contributor

@Ivanov1ch Ivanov1ch commented Aug 7, 2024

One sentence summary of this PR (This should go in the CHANGELOG!)
Adds an ofrak_gpu module containing GPU-bound entropy calculation, and updates the DataSummaryAnalyzer to try using ofrak_gpu's implementation before the C/Python implementations in ofrak_core.
Link to Related Issue(s)
N/A
Please describe the changes in your request.

  • Adds an ofrak_gpu module containing Futhark source code to compute the entropy of given data.
    • Also adds the Futhark-generated pyopencl library that is compiled from this source code
    • Modifies DataSummaryAnalyzer to try using ofrak_gpu's pyopencl library, then try the C implementation, then finally fall back on the Python implementation
  • Adds tests to check entropy_gpu's correctness on certain edge cases and against ofrak_core's C/Python implementations
  • Adds tests to ofrak_core/test_ofrak/components/test_entropy_component.py to test DataSummaryAnalyzer's behavior, asserting that DataSummaryAnalyzer will use ofrak_gpu's entropy calculation, if installed, before attempting to use C/Python. This was written using mocks in a way that ensures the test will run, pass, and correctly assess DataSummaryAnalyzer, whether or not ofrak_gpu is present in the testing environment.

Anyone you think should look at this, specifically?
@whyitfor

** Potential TODOs:**

  • This has only been tested on my x86_64 device that does not have a GPU, so only CPU-based OpenCL runtimes have been tested. Would be smart to test this on ARM, real GPUs, etc.
  • Can add benchmarking code

rbs-jacob and others added 15 commits April 9, 2024 11:07
…periments in injecting code into the generated entropy.py pyopencl library to allow progress tracking
…s. no_gpu still needs work.

Set up ofrak_gpu to be a proper module. It now has a makefile, requerements, setup.py, etc. The dockerstub automatically installs the latest release of futhark and is used to create entropy.py from entropy.fut at build time. Unfortunately, this will probably get rejected, which sucks because making that Dockerstub was a pain.

Had to split up the entropy tests into two separate files, one that runs the tests using a fixture to always trick the system into thinking ofrak_gpu is installed, to test the DataSummaryAnalyzer's behavior when ofrak_gpu is present, and one that uses a fixture to always trick the system into thinking ofrak_gpu has not been installed, to ensure DataSummaryAnalyzer's current behavior remains unaffected. These fixtures were incredibly annoying and confusing to get working consistently. As of this commit, no_gpu is still in need of more research. However, these efforts will allow us to fully test DataSummaryAnalyzer's behavior consistently, regardless of whether or not the ofrak_gpu module has been installed on the testing environment, which is very important for reliability (and unforuntately very difficult to do).
It is generated at build-time from entropy.fut, thanks to the Dockerstub and Makefile. It's hugely messy for VCS tracking
…talled now work

Have since realized that we now have a numpy problem. Will have to figure out how to mock this in test_entropy_component_gpu
… with and without ofrak_gpu, while testing the fallback behavior of DataSummaryAnalyzer correctly
…thing :( test_enteopy_component method works
…stalled using patching and MagicMock to stop breaking the pjson tests.

Still need to redo the tests that act like ofrak_gpu is NOT installed
…frak_gpu on ARM, finish writing tests for ofrak_gpu
@alchzh
Copy link
Contributor

alchzh commented Aug 8, 2024

Tests fail with zero / null bytes on Apple Silicon M3 Mac and pocl/pyopencl installed from conda-forge.
pytest_out.log
Tried to run with oclgrind, build failed with segmentation fault

@whyitfor whyitfor self-requested a review August 16, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants