Skip to content

Commit

Permalink
flatpak: add support for OpenCL (HPC)
Browse files Browse the repository at this point in the history
It is possible to use GPU acceleration via OpenCL within flatpak:
- https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1535
- flathub/com.openwall.John#13 (comment)

However, it's not clear what is actually needed for this to work (poor
documentation? or I'm failing to find it?).
- what is the minimum required to run `cl-info` inside a flatpak?

HPC (high performance computing) using GPU is very important to us.
NVIDIA is the target at the moment.

Our community does not have suitable hardware with CUDA installed to
use/test this PR.

=> Note: Review/Revert/Improve:
. Should I also add org.freedesktop.Platform.HIP.Nvidia?
. Is the `add-extensions:` necessary or useful? I want to enable NVIDIA support
but allow poor people (like me) to continue using flatpak, e.g., for CPU
formats.
. Test when possible:
```
+        "--socket=x11",
+        "--device=all"
```

Signed-off-by: Claudio André <dev@claudioandre.slmail.me>
  • Loading branch information
claudioandre-br committed Oct 26, 2024
1 parent 6206c67 commit 58a296c
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flatpak-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ jobs:
# Required defines
export FLATPAK='true'
export JTR_BIN='john'
export TEST=';full;extra;' # Controls how the test will happen
export TEST=';full;extra;OpenCL-info;' # Controls how the test will happen
wget https://raw.githubusercontent.com/openwall/john-packages/main/scripts/run_tests.sh
source run_tests.sh
Expand Down
2 changes: 1 addition & 1 deletion deploy/flatpak/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ TASK_RUNNING="Flatpak build"
export -p DEPLOY_PAK FLATPAK_BUILD BASE TASK_RUNNING

# Build options (system wide, disable checks, etc.)
SYSTEM_WIDE='--with-systemwide --disable-opencl'
SYSTEM_WIDE="--with-systemwide"
X86_REGULAR="--disable-native-tests $SYSTEM_WIDE"
X86_NO_OPENMP="--disable-native-tests $SYSTEM_WIDE --disable-openmp"

Expand Down
59 changes: 58 additions & 1 deletion deploy/flatpak/com.openwall.John.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,66 @@
"sdk": "org.freedesktop.Sdk",
"command": "john",
"tags": ["1.9J1+2404"],
"finish-args": ["--filesystem=home"],
"finish-args": ["--filesystem=home", "--share=ipc", "--device=dri"],

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

ipc is not a recognized word. (unrecognized-spelling)

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

dri is not a recognized word. (unrecognized-spelling)
"add-extensions": {
"org.freedesktop.Platform.GL": {
"version": "1.4",
"versions": "%{branch};%{branch-extra};1.4",
"directory": "%{lib}/GL",
"add-ld-path": "lib",
"merge-dirs": "%{gl_merge_dirs}",
"subdirectories": true,
"no-autodownload": true,

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autodownload is not a recognized word. (unrecognized-spelling)
"autodelete": true,

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autodelete is not a recognized word. (unrecognized-spelling)
"download-if": "active-gl-driver",
"enable-if": "active-gl-driver",
"autoprune-unless": "active-gl-driver"

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autoprune is not a recognized word. (unrecognized-spelling)
}
},
"cleanup": ["/include", "*.la", "*.a"],
"modules": [
{
"name": "clinfo",
"no-autogen": true,

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autogen is not a recognized word. (unrecognized-spelling)
"no-make-install": true,
"build-commands": ["install -Dm755 -t /app/bin/ clinfo"],
"sources": [
{
"type": "archive",
"url": "https://github.com/Oblomov/clinfo/archive/refs/tags/3.0.23.01.25.tar.gz",
"sha256": "6dcdada6c115873db78c7ffc62b9fc1ee7a2d08854a3bccea396df312e7331e3"
}
],
"modules": [
{
"name": "ocl-icd",
"sources": [
{
"type": "archive",
"url": "https://github.com/OCL-dev/ocl-icd/archive/refs/tags/v2.3.2.tar.gz",
"sha256": "ec47d7dcd961ea06695b067e8b7edb82e420ddce03e0081a908c62fd0b8535c5"
},
{
"type": "script",
"dest-filename": "autogen.sh",

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autogen is not a recognized word. (unrecognized-spelling)
"commands": ["autoreconf -fiv"]

Check failure

Code scanning / check-spelling

Unrecognized Spelling Error

autoreconf is not a recognized word. (unrecognized-spelling)
}
]
},
{
"name": "opencl-headers",
"buildsystem": "simple",
"build-commands": ["cp -av opencl22/CL /app/include"],
"sources": [
{
"type": "git",
"url": "https://github.com/KhronosGroup/OpenCL-Headers.git",
"commit": "e986688daf750633898dfd3994e14a9e618f2aa5"
}
]
}
]
},
{
"name": "libpcap",
"sources": [
Expand Down
2 changes: 1 addition & 1 deletion requirements.hash
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
a1788258b118178c77e6d7de16723e07b2aa9191e7414a84e756fa831d02d0aa ./clean_package.sh
b6dd937dfccbc23fd618c5b259698c1eafd5ef54e7965c778c3ae1599c12a113 ./helper.sh
a11e89f1d10be4235e247bc815e0549f06bef22fb5414acecf7d3e82cee0a70a ./package_version.sh
376ed40297353794e2c9e43c277e19743f37965ba9c4eb8260e8dff3230c1be9 ./run_tests.sh
8ef989a660f91d0c20ec08f86ba5c6c6e47649730d1f9048a30f0a5f28710dbf ./run_tests.sh
5e4629cce7b4552876dc308a659e878b1b196df60327df50f462ec899d6d28ed ./show_info.sh
11aa0fb376310c49eb5c915f5db2c066d2e8b35950e8a6b604d75104994ec04f ./Handle-self-confined-system-wide-build.patch
1f93d80dd97a5450c6e36759148d2767e29bbf987c078d5e5089b702e77aece5 ./Remove-peflags-from-the-default-target.patch
6 changes: 5 additions & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ echo "=> $JTR_BIN --list=build-info"

"$JTR_BIN" --list=build-info

if [[ "$HOST_OS" == "Darwin" || -z "${TEST##*OpenCL-full*}" ]]; then
if [[ "$HOST_OS" == "Darwin" || -z "${TEST##*OpenCL-full*}" || -z "${TEST##*OpenCL-info*}" ]]; then
echo "---------------------------- OpenCL Devices ----------------------------"
"$JTR_BIN" --list=opencl-devices

if [[ "$FLATPAK" == "true" ]]; then
flatpak run --command=clinfo com.openwall.John
fi
fi

# shellcheck disable=SC2016
Expand Down

0 comments on commit 58a296c

Please sign in to comment.