目次
文書の過去の版を表示しています。
VideoCore IV GPU で OpenCL
ビルド依存パッケージのインストール
$ sudo apt update && sudo apt upgrade
Hit:1 https://dietpi.com/apt bookworm InRelease Hit:2 https://dietpi.com/apt all InRelease Get:3 http://raspbian.raspberrypi.com/raspbian bookworm InRelease [15.0 kB] Get:4 https://archive.raspberrypi.com/debian bookworm InRelease [23.6 kB] Get:5 http://raspbian.raspberrypi.com/raspbian bookworm/main Sources [13.7 MB] Get:6 https://archive.raspberrypi.com/debian bookworm/main armhf Packages [392 kB] Get:7 https://archive.raspberrypi.com/debian bookworm/main armhf Contents (deb) [2,994 kB] Get:8 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf Packages [14.5 MB] Fetched 31.7 MB in 1min 48s (292 kB/s) Reading package lists... Done Building dependency tree... Done Reading state information... Done All packages are up to date. Reading package lists... Done Building dependency tree... Done Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install cmake git
Reading package lists... Done Building dependency tree... Done Reading state information... Done cmake is already the newest version (3.25.1-1). git is already the newest version (1:2.39.2-1.1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install opencl-headers
Reading package lists... Done Building dependency tree... Done Reading state information... Done opencl-headers is already the newest version (3.0~2023.02.06-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install ocl-icd-opencl-dev ocl-icd-dev
Reading package lists... Done Building dependency tree... Done Reading state information... Done ocl-icd-opencl-dev is already the newest version (2.3.1-1). ocl-icd-dev is already the newest version (2.3.1-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install libraspberrypi-dev
Reading package lists... Done Building dependency tree... Done Reading state information... Done libraspberrypi-dev is already the newest version (1:2+git20231018~131943+3c97f76-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install clang-14 clang-format-14 clang-tidy-14
Reading package lists... Done Building dependency tree... Done Reading state information... Done clang-14 is already the newest version (1:14.0.6-12+rpi1). clang-14 set to manually installed. clang-format-14 is already the newest version (1:14.0.6-12+rpi1). clang-format-14 set to manually installed. clang-tidy-14 is already the newest version (1:14.0.6-12+rpi1). clang-tidy-14 set to manually installed. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo apt install llvm-14 libllvm14 llvm-14-dev libllvmspirvlib-14-dev libllvmspirvlib14
Reading package lists... Done Building dependency tree... Done Reading state information... Done llvm-14 is already the newest version (1:14.0.6-12+rpi1). libllvm14 is already the newest version (1:14.0.6-12+rpi1). libllvmspirvlib-14-dev is already the newest version (14.0.0-5+rpi1). libllvmspirvlib14 is already the newest version (14.0.0-5+rpi1). The following additional packages will be installed: libz3-dev llvm-14-tools python3-pygments Suggested packages: python-pygments-doc ttf-bitstream-vera The following NEW packages will be installed: libz3-dev llvm-14-dev llvm-14-tools python3-pygments 0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded. Need to get 35.1 MB of archives. After this operation, 252 MB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://ftp.udx.icscoe.jp/Linux/raspbian/raspbian bookworm/main armhf libz3-dev armhf 4.8.12-3.1 [90.6 kB] Get:2 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf python3-pygments all 2.14.0+dfsg-1 [783 kB] Get:3 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf llvm-14-tools armhf 1:14.0.6-12+rpi1 [361 kB] Get:4 http://raspbian.raspberrypi.com/raspbian bookworm/main armhf llvm-14-dev armhf 1:14.0.6-12+rpi1 [33.9 MB] Fetched 35.1 MB in 2min 29s (236 kB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package libz3-dev:armhf. (Reading database ... 141885 files and directories currently installed.) Preparing to unpack .../libz3-dev_4.8.12-3.1_armhf.deb ... Unpacking libz3-dev:armhf (4.8.12-3.1) ... Selecting previously unselected package python3-pygments. Preparing to unpack .../python3-pygments_2.14.0+dfsg-1_all.deb ... Unpacking python3-pygments (2.14.0+dfsg-1) ... Selecting previously unselected package llvm-14-tools. Preparing to unpack .../llvm-14-tools_1%3a14.0.6-12+rpi1_armhf.deb ... Unpacking llvm-14-tools (1:14.0.6-12+rpi1) ... Selecting previously unselected package llvm-14-dev. Preparing to unpack .../llvm-14-dev_1%3a14.0.6-12+rpi1_armhf.deb ... Unpacking llvm-14-dev (1:14.0.6-12+rpi1) ... Setting up libz3-dev:armhf (4.8.12-3.1) ... Setting up python3-pygments (2.14.0+dfsg-1) ... Setting up llvm-14-tools (1:14.0.6-12+rpi1) ... Setting up llvm-14-dev (1:14.0.6-12+rpi1) ... Processing triggers for man-db (2.11.2-2) ... Processing triggers for libc-bin (2.36-9+rpt2+deb12u4) ...
$ sudo apt install clinfo
Reading package lists... Done Building dependency tree... Done Reading state information... Done clinfo is already the newest version (3.0.23.01.25-1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 14
update-alternatives: using /usr/bin/clang-14 to provide /usr/bin/clang (clang) in auto mode
$ sudo update-alternatives --config clang
There is 1 choice for the alternative clang (providing /usr/bin/clang). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/clang-14 14 auto mode 1 /usr/bin/clang-14 14 manual mode Press <enter> to keep the current choice[*], or type selection number:
$ clang --version
Raspbian clang version 14.0.6 Target: arm-unknown-linux-gnueabihf Thread model: posix InstalledDir: /usr/bin
$ sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-14 14
update-alternatives: using /usr/bin/clang-format-14 to provide /usr/bin/clang-format (clang-format) in auto mode
$ sudo update-alternatives --config clang-format
There is 1 choice for the alternative clang-format (providing /usr/bin/clang-format). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/clang-format-14 14 auto mode 1 /usr/bin/clang-format-14 14 manual mode Press <enter> to keep the current choice[*], or type selection number:
$ clang-format --version
Raspbian clang-format version 14.0.6
$ sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-14 14
update-alternatives: using /usr/bin/llvm-config-14 to provide /usr/bin/llvm-config (llvm-config) in auto mode
$ sudo update-alternatives --config llvm-config
There is 1 choice for the alternative llvm-config (providing /usr/bin/llvm-config). Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/bin/llvm-config-14 14 auto mode 1 /usr/bin/llvm-config-14 14 manual mode Press <enter> to keep the current choice[*], or type selection number:
$ llvm-config --version
14.0.6
ソースコードからビルドする...🤔
ソースコードの clone …🤔
$ mkdir opencl && cd opencl $ git clone --depth 1 https://github.com/doe300/VC4CLStdLib.git
Cloning into 'VC4CLStdLib'... remote: Enumerating objects: 38, done. remote: Counting objects: 100% (38/38), done. remote: Compressing objects: 100% (38/38), done. remote: Total 38 (delta 1), reused 14 (delta 0), pack-reused 0 Receiving objects: 100% (38/38), 151.65 KiB | 404.00 KiB/s, done. Resolving deltas: 100% (1/1), done.
$ git clone https://github.com/doe300/VC4C.git
Cloning into 'VC4C'... remote: Enumerating objects: 14476, done. remote: Counting objects: 100% (3209/3209), done. remote: Compressing objects: 100% (577/577), done. remote: Total 14476 (delta 2626), reused 3192 (delta 2616), pack-reused 11267 Receiving objects: 100% (14476/14476), 26.52 MiB | 369.00 KiB/s, done. Resolving deltas: 100% (11603/11603), done. Updating files: 100% (1607/1607), done.
$ git clone https://github.com/doe300/VC4CL.git
Cloning into 'VC4CL'... remote: Enumerating objects: 2119, done. remote: Counting objects: 100% (118/118), done. remote: Compressing objects: 100% (83/83), done. remote: Total 2119 (delta 40), reused 39 (delta 35), pack-reused 2001 Receiving objects: 100% (2119/2119), 1.05 MiB | 254.00 KiB/s, done. Resolving deltas: 100% (1657/1657), done.
VC4CLStdLib のビルド & インストール
$ cd VC4CLStdLib $ mkdir build && cd build $ cmake ..
-- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- build deb package... -- Configuring done -- Generating done -- Build files have been written to: /home/dietpi/opencl/VC4CLStdLib/build
$ make
[100%] Linking C static library libVC4CLStdLib.a [100%] Built target VC4CLStdLib
$ sudo make install && sudo ldconfig
[100%] Built target VC4CLStdLib Install the project... -- Install configuration: "" -- Installing: /usr/local/include/vc4cl-stdlib -- Installing: /usr/local/include/vc4cl-stdlib/_atomics.h -- Installing: /usr/local/include/vc4cl-stdlib/opencl-c.h -- Installing: /usr/local/include/vc4cl-stdlib/_integer.h -- Installing: /usr/local/include/vc4cl-stdlib/defines.h -- Installing: /usr/local/include/vc4cl-stdlib/_printf.h -- Installing: /usr/local/include/vc4cl-stdlib/_spir_mangling.h -- Installing: /usr/local/include/vc4cl-stdlib/_config.h -- Installing: /usr/local/include/vc4cl-stdlib/_relational.h -- Installing: /usr/local/include/vc4cl-stdlib/_common.h -- Installing: /usr/local/include/vc4cl-stdlib/_work_items.h -- Installing: /usr/local/include/vc4cl-stdlib/_extensions.h -- Installing: /usr/local/include/vc4cl-stdlib/_geometric.h -- Installing: /usr/local/include/vc4cl-stdlib/_images.h -- Installing: /usr/local/include/vc4cl-stdlib/_overloads.h -- Installing: /usr/local/include/vc4cl-stdlib/_math.h -- Installing: /usr/local/include/vc4cl-stdlib/_vector.h -- Installing: /usr/local/include/vc4cl-stdlib/_intrinsics.h -- Installing: /usr/local/include/vc4cl-stdlib/_synchronization.h -- Installing: /usr/local/include/vc4cl-stdlib/_conversions.h -- Installing: /usr/local/include/vc4cl-stdlib/_clcxx_mangling.h -- Installing: /usr/local/include/vc4cl-stdlib/_float_float.h -- Installing: /usr/local/include/vc4cl-stdlib/_async.h -- Installing: /usr/local/include/vc4cl-stdlib/VC4CLStdLib.h
VC4C のビルド & インストール
$ cd ../../VC4C $ mkdir build && cd build $ cmake ..
CMake Deprecation Warning at CMakeLists.txt:4 (cmake_policy): The OLD behavior for policy CMP0026 will be removed from a future version of CMake. The cmake-policies(7) manual explains that the OLD behaviors of all policies are deprecated and that a policy should be set to OLD only under specific short-term circumstances. Projects should be ported to the NEW behavior and not rely on setting a policy to OLD. -- VC4CL standard library headers found: /home/dietpi/opencl/VC4C/../VC4CLStdLib/include/ -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Using CMake 3.14+ FetchContent to include dependencies... -- CLang compiler found: /usr/bin/clang -- LLVM-dis found: /usr/bin/llvm-dis-14 -- LLVM-as found: /usr/bin/llvm-as-14 -- LLVM-link found: /usr/bin/llvm-link-14 -- Performing Test HAVE_FFI_CALL -- Performing Test HAVE_FFI_CALL - Success -- Found FFI: /usr/lib/arm-linux-gnueabihf/libffi.so -- Performing Test Terminfo_LINKABLE -- Performing Test Terminfo_LINKABLE - Success -- Found Terminfo: /usr/lib/arm-linux-gnueabihf/libtinfo.so -- Found ZLIB: /usr/lib/arm-linux-gnueabihf/libz.so (found version "1.2.13") -- Found LibXml2: /usr/lib/arm-linux-gnueabihf/libxml2.so (found version "2.9.14") -- Compiling LLVM library front-end with LLVM in version 14.0.6 located in '/usr/lib/llvm-14/lib' -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- found clang-format: /usr/bin/clang-format -- Configuring done -- Generating done -- Build files have been written to: /home/dietpi/opencl/VC4C/build
$ make
VC4CL のビルド & インストール
$ cd ../../VC4CL $ mkdir build && cd build $ cmake ..
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.1") -- The C compiler identification is GNU 12.2.0 -- The CXX compiler identification is GNU 12.2.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for CL_VERSION_3_0 -- Looking for CL_VERSION_3_0 - found -- Found OpenCL: /usr/lib/arm-linux-gnueabihf/libOpenCL.so (found version "3.0") -- Found headers for OpenCL up to version 3.0 located in /usr/include -- No VC4C compiler library found! -- VC4C compiler header found at: /home/dietpi/opencl/VC4C/include/VC4C.h -- Looking for wsyncup in /usr/lib/arm-linux-gnueabihf/libcurses.so -- Looking for wsyncup in /usr/lib/arm-linux-gnueabihf/libcurses.so - found -- Looking for cbreak in /usr/lib/arm-linux-gnueabihf/libncurses.so -- Looking for cbreak in /usr/lib/arm-linux-gnueabihf/libncurses.so - found -- Looking for nodelay in /usr/lib/arm-linux-gnueabihf/libncurses.so -- Looking for nodelay in /usr/lib/arm-linux-gnueabihf/libncurses.so - found -- Found Curses: /usr/lib/arm-linux-gnueabihf/libncurses.so -- vcsm library not found -- found clang-format: /usr/bin/clang-format -- Configuring done CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: VC4CC_LIBRARY linked by target "VC4CL" in directory /home/dietpi/opencl/VC4CL/src -- Generating done CMake Generate step failed. Build files cannot be regenerated correctly.
$ make