From 6ca51a1ccd15436e93f58ac3bf3f30458515c7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claudio=20Andr=C3=A9?= Date: Sat, 26 Oct 2024 13:59:30 -0300 Subject: [PATCH] flatpak: add support for OpenCL (HPC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is possible to use GPU acceleration via OpenCL within flatpak: - https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/issues/1535 - https://github.com/flathub/com.openwall.John/pull/13#issuecomment-2341867599 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é --- .github/actions/spelling/expect.txt | 7 ++++ .github/workflows/flatpak-bundle.yml | 4 +- deploy/flatpak/build.sh | 2 +- deploy/flatpak/com.openwall.John.json | 59 ++++++++++++++++++++++++++- requirements.hash | 2 +- scripts/run_tests.sh | 6 ++- 6 files changed, 74 insertions(+), 6 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 8d31cbdc..d943848a 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -14,6 +14,11 @@ appveyor asan ASLR ath +autodelete +autodownload +autogen +autoprune +autoreconf avx awor aws @@ -67,6 +72,7 @@ dmg dnf dns Dockerfiles +dri drwx drwxr drwxrwxr @@ -106,6 +112,7 @@ ifndef img IMO intrinsics +ipc jscpd JTR jtrcrackers diff --git a/.github/workflows/flatpak-bundle.yml b/.github/workflows/flatpak-bundle.yml index a10a9b65..0f29a3db 100644 --- a/.github/workflows/flatpak-bundle.yml +++ b/.github/workflows/flatpak-bundle.yml @@ -109,8 +109,8 @@ 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 + wget https://raw.githubusercontent.com/openwall/john-packages/release/scripts/run_tests.sh source run_tests.sh shell: bash diff --git a/deploy/flatpak/build.sh b/deploy/flatpak/build.sh index 28a4efec..037393e7 100755 --- a/deploy/flatpak/build.sh +++ b/deploy/flatpak/build.sh @@ -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" diff --git a/deploy/flatpak/com.openwall.John.json b/deploy/flatpak/com.openwall.John.json index 4fb85e95..3bd9f8d2 100644 --- a/deploy/flatpak/com.openwall.John.json +++ b/deploy/flatpak/com.openwall.John.json @@ -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"], + "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, + "autodelete": true, + "download-if": "active-gl-driver", + "enable-if": "active-gl-driver", + "autoprune-unless": "active-gl-driver" + } + }, "cleanup": ["/include", "*.la", "*.a"], "modules": [ + { + "name": "clinfo", + "no-autogen": true, + "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", + "commands": ["autoreconf -fiv"] + } + ] + }, + { + "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": [ diff --git a/requirements.hash b/requirements.hash index a84c49bd..ec6810db 100644 --- a/requirements.hash +++ b/requirements.hash @@ -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 diff --git a/scripts/run_tests.sh b/scripts/run_tests.sh index 3854834b..baeeb211 100755 --- a/scripts/run_tests.sh +++ b/scripts/run_tests.sh @@ -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