doe300 / VC4C

Compiler for the VC4CL OpenCL implementation
MIT License
117 stars 37 forks source link

RPI 3A+ VC4C Build error #165

Closed jDietschi closed 1 year ago

jDietschi commented 1 year ago

When building the VC4C Library (running make) it fails while trying to Link CXX shared library libVC4CC.so with the same error as #157

[  4%] Built target GetGitCommit
[  4%] Performing update step for 'cpplog-project'
From https://github.com/doe300/cpplog
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
[  4%] Performing configure step for 'cpplog-project'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build/cpplog/src/cpplog-project-build
[  4%] Performing build step for 'cpplog-project'
[ 50%] Built target cpplog-static
[100%] Built target cpplog
[  4%] Built target cpplog-project-build
[  4%] Linking CXX shared library libVC4CC.so
collect2: fatal error: ld terminated with signal 9 [Killed]
compilation terminated.
make[2]: *** [src/CMakeFiles/VC4CC.dir/build.make:1555: src/libVC4CC.so.0.4.9999] Error 1
make[2]: *** Deleting file 'src/libVC4CC.so.0.4.9999'
make[1]: *** [CMakeFiles/Makefile2:353: src/CMakeFiles/VC4CC.dir/all] Error 2
make: *** [Makefile:163: all] Error 2

The output in VC4C/build/CMakeFiles/CMakeError.log is the same as in issue

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_c2e1a/fast && /usr/bin/make -f CMakeFiles/cmTC_c2e1a.dir/build.make CMakeFiles/cmTC_c2e1a.dir/build
make[1]: Entering directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_c2e1a.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD   -o CMakeFiles/cmTC_c2e1a.dir/src.c.o   -c /home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_c2e1a
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_c2e1a.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD    -rdynamic CMakeFiles/cmTC_c2e1a.dir/src.c.o  -o cmTC_c2e1a
/usr/bin/ld: CMakeFiles/cmTC_c2e1a.dir/src.c.o: in function `main':
src.c:(.text+0x40): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x4c): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x5c): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_c2e1a.dir/build.make:87: cmTC_c2e1a] Error 1
make[1]: Leaving directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_c2e1a/fast] Error 2

Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/make cmTC_9fcf5/fast && /usr/bin/make -f CMakeFiles/cmTC_9fcf5.dir/build.make CMakeFiles/cmTC_9fcf5.dir/build
make[1]: Entering directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_9fcf5.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create   -o CMakeFiles/cmTC_9fcf5.dir/CheckFunctionExists.c.o   -c /usr/share/cmake-3.16/Modules/CheckFunctionExists.c
Linking C executable cmTC_9fcf5
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_9fcf5.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create    -rdynamic CMakeFiles/cmTC_9fcf5.dir/CheckFunctionExists.c.o  -o cmTC_9fcf5  -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
make[1]: *** [CMakeFiles/cmTC_9fcf5.dir/build.make:87: cmTC_9fcf5] Error 1
make[1]: Leaving directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
make: *** [Makefile:121: cmTC_9fcf5/fast] Error 2

Using this install routine:

(The kernel downgrade was included due to the following entry: #https://github.com/Idein/rpi-vcsm/issues/2 Even if it is concerning another project, the output remains the same without the downgrade Using cmake -DMULTI_THREADED=OFF .. as seen in other (older) issues)

# get a fresh start
sudo apt-get -y update
sudo apt-get -y upgrade

# Kernel downgrade
echo Kernel downgrade
sudo rpi-update -y 43022f5adbbf5d6e05ea0e022a3090c2c9feff7c

reboot system

# swap file 4G
echo creatint 4G Swapfile
sudo swapoff -a
sudo fallocate -l 4G /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile

# install

# get third party software
sudo apt-get -y install tmux build-essential cmake git ocl-icd-opencl-dev ocl-icd-dev opencl-headers clinfo libraspberrypi-dev libpthread-stubs0-dev clang-6.0 libllvm6.0 llvm-6.0-dev clang clang-format clang-tidy

sudo reboot -f

echo Download OpenCL Repos
cd ~
mkdir opencl
cd ~/opencl
git clone https://github.com/doe300/VC4CLStdLib.git
git clone https://github.com/doe300/VC4CL.git
git clone https://github.com/doe300/VC4C.git

echo installing VC4CLStdLib
cd ~/opencl/VC4CLStdLib
mkdir build
cd build
cmake -DMULTI_THREADED=OFF ..
make
sudo make install
sudo ldconfig

echo installing VC4C
cd ~/opencl/VC4C
mkdir build
cd build
cmake -DMULTI_THREADED=OFF ..
make
sudo make install
sudo ldconfig

echo installing VC4CL
cd ~/opencl/VC4CL
mkdir build
cd build
cmake -DMULTI_THREADED=OFF ..
make
sudo make install
sudo ldconfig

uname -a

Linux raspi01 5.4.83-v7+ #1379 SMP Mon Dec 14 13:08:57 GMT 2020 armv7l GNU/Linux

clang version:

clang version 7.0.1-8+rpi3+deb10u2 (tags/RELEASE_701/final)
Target: armv6k-unknown-linux-gnueabihf
Thread model: posix
InstalledDir: /usr/bin

gcc version:

gcc (Raspbian 8.3.0-6+rpi1) 8.3.0

/proc/cpuinfo

processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 2
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

processor       : 3
model name      : ARMv7 Processor rev 4 (v7l)
BogoMIPS        : 38.40
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xd03
CPU revision    : 4

Hardware        : BCM2835
Revision        : 9020e0
Serial          : 00000000c049d860
Model           : Raspberry Pi 3 Model A Plus Rev 1.0

Is this project supported (buildable) on Raspberry Pi 3A+ and if so, how can I install it?

Thanks for this great Projekt and thanks in advance!

doe300 commented 1 year ago

collect2: fatal error: ld terminated with signal 9 [Killed]

The linker command seems to have been killed externally. Did you maybe run out of memory?

jDietschi commented 1 year ago

I don't think so I just ran another attempt without the kernel downgrade and got the same Error And is this really compatible for Raspberry Pi 3A+?

VC4CLStdLib and VC4CL build without any erros.

VC4C CMakeError.log

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake cmTC_33e6d/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_33e6d.dir/build.make CMakeFiles/cmTC_33e6d.dir/build
gmake[1]: Entering directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_33e6d.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD -o CMakeFiles/cmTC_33e6d.dir/src.c.o -c /home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_33e6d
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_33e6d.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD -rdynamic CMakeFiles/cmTC_33e6d.dir/src.c.o -o cmTC_33e6d
/usr/bin/ld: CMakeFiles/cmTC_33e6d.dir/src.c.o: in function `main':
src.c:(.text+0x40): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x4c): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x58): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x68): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_33e6d.dir/build.make:106: cmTC_33e6d] Error 1
gmake[1]: Leaving directory '/home/admin/opencl/VC4C/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_33e6d/fast] Error 2

my swapfile is 4Gigabyte

admin@raspi01:~/opencl/VC4C/build/CMakeFiles $ free -h
                      total        used        free      shared  buff/cache   available
Mem:           426Mi        37Mi       148Mi       0.0Ki       240Mi       337Mi
Swap:          4.0Gi        18Mi       4.0Gi

What else could I do to avoid running out of memory?

I just ran the whole procedure again, this is my console output:

admin@raspi01:~ $ ls -l
total 4
drwxr-xr-x 5 admin admin 4096 Jun 19 06:21 opencl
admin@raspi01:~ $ cd opencl/
admin@raspi01:~/opencl $ cd VC4CLStdLib/
admin@raspi01:~/opencl/VC4CLStdLib $ cd build/
admin@raspi01:~/opencl/VC4CLStdLib/build $ cmake ..
-- build deb package...
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4CLStdLib/build
admin@raspi01:~/opencl/VC4CLStdLib/build $ make
[100%] Built target VC4CLStdLib
admin@raspi01:~/opencl/VC4CLStdLib/build $ sudo install make
install: missing destination file operand after 'make'
Try 'install --help' for more information.
admin@raspi01:~/opencl/VC4CLStdLib/build $ sudo make install
[100%] Built target VC4CLStdLib
Install the project...
-- Install configuration: ""
-- Up-to-date: /usr/local/include/vc4cl-stdlib
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_geometric.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_intrinsics.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_synchronization.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_float_float.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_conversions.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_clcxx_mangling.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_common.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_work_items.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/VC4CLStdLib.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/defines.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_async.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/opencl-c.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_config.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_extensions.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_printf.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_spir_mangling.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_atomics.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_vector.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_images.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_math.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_integer.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_relational.h
-- Up-to-date: /usr/local/include/vc4cl-stdlib/_overloads.h
admin@raspi01:~/opencl/VC4CLStdLib/build $ sudo ldconfig
admin@raspi01:~/opencl/VC4CLStdLib/build $ cd ..
admin@raspi01:~/opencl/VC4CLStdLib $ cd ..
admin@raspi01:~/opencl $ cd VC4C
admin@raspi01:~/opencl/VC4C $ cd build/
admin@raspi01:~/opencl/VC4C/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/admin/opencl/VC4C/../VC4CLStdLib/include/
-- Using CMake 3.14+ FetchContent to include dependencies...
-- CLang compiler found: /usr/bin/clang
-- LLVM-dis found: /usr/bin/llvm-dis-6.0
-- LLVM-as found: /usr/bin/llvm-as-6.0
-- LLVM-link found: /usr/bin/llvm-link-6.0
-- Compiling LLVM library front-end with LLVM in version 11.0.1 located in '/usr/lib/llvm-11/lib'
-- found clang-format: /usr/bin/clang-format
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build
admin@raspi01:~/opencl/VC4C/build $ make
[  1%] Performing update step for 'cpplog-project'
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
From https://github.com/doe300/cpplog
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
[  1%] No patch step for 'cpplog-project'
[  1%] Performing configure step for 'cpplog-project'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build/cpplog/src/cpplog-project-build
[  2%] Performing build step for 'cpplog-project'
[ 50%] Built target cpplog-static
[100%] Built target cpplog
[  3%] Built target cpplog-project-build
[ 48%] Built target VC4CC
[ 48%] Built target GetGitCommit
Scanning dependencies of target VC4C
[ 48%] Building CXX object src/CMakeFiles/VC4C.dir/main.cpp.o
[ 48%] Linking CXX executable vc4c
[ 48%] Built target VC4C
[ 50%] Built target qpu_emulator
[ 88%] Built target TestData
[ 89%] Performing update step for 'cpptest-lite-project'
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
From https://github.com/doe300/cpptest-lite
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
[ 89%] No patch step for 'cpptest-lite-project'
[ 89%] Performing configure step for 'cpptest-lite-project'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build/cpptest-lite/src/cpptest-lite-project-build
[ 90%] Performing build step for 'cpptest-lite-project'
[100%] Built target cpptest-lite
[ 91%] Built target cpptest-lite-project-build
[ 92%] Linking CXX executable TestVC4C
[100%] Built target TestVC4C
admin@raspi01:~/opencl/VC4C/build $ sudo make install
[  1%] Performing update step for 'cpplog-project'
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
From https://github.com/doe300/cpplog
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
[  1%] No patch step for 'cpplog-project'
[  1%] Performing configure step for 'cpplog-project'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build/cpplog/src/cpplog-project-build
[  2%] Performing build step for 'cpplog-project'
[ 50%] Built target cpplog-static
[100%] Built target cpplog
[  3%] Built target cpplog-project-build
[ 48%] Built target VC4CC
[ 48%] Built target GetGitCommit
Scanning dependencies of target VC4C
[ 48%] Building CXX object src/CMakeFiles/VC4C.dir/main.cpp.o
[ 48%] Linking CXX executable vc4c
[ 48%] Built target VC4C
[ 50%] Built target qpu_emulator
[ 88%] Built target TestData
[ 89%] Performing update step for 'cpptest-lite-project'
hint: Pulling without specifying how to reconcile divergent branches is
hint: discouraged. You can squelch this message by running one of the following
hint: commands sometime before your next pull:
hint:
hint:   git config pull.rebase false  # merge (the default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
From https://github.com/doe300/cpptest-lite
 * branch            HEAD       -> FETCH_HEAD
Already up to date.
[ 89%] No patch step for 'cpptest-lite-project'
[ 89%] Performing configure step for 'cpptest-lite-project'
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4C/build/cpptest-lite/src/cpptest-lite-project-build
[ 90%] Performing build step for 'cpptest-lite-project'
[100%] Built target cpptest-lite
[ 91%] Built target cpptest-lite-project-build
[100%] Built target TestVC4C
Install the project...
-- Install configuration: "Debug"
-- Up-to-date: /usr/local/lib/cmake/mpark_variant/mpark_variant-targets.cmake
-- Up-to-date: /usr/local/include/mpark
-- Up-to-date: /usr/local/include/mpark/config.hpp
-- Up-to-date: /usr/local/include/mpark/lib.hpp
-- Up-to-date: /usr/local/include/mpark/in_place.hpp
-- Up-to-date: /usr/local/include/mpark/variant.hpp
-- Up-to-date: /usr/local/lib/cmake/mpark_variant/mpark_variant-config.cmake
-- Up-to-date: /usr/local/lib/cmake/mpark_variant/mpark_variant-config-version.cmake
-- Up-to-date: /usr/local/lib/libVC4CC.so.0.4.9999
-- Up-to-date: /usr/local/lib/libVC4CC.so.1.2
-- Up-to-date: /usr/local/lib/libVC4CC.so
-- Installing: /usr/local/bin/vc4c
-- Set runtime path of "/usr/local/bin/vc4c" to "/usr/local/lib"
-- Up-to-date: /usr/local/share/vc4cc/VC4CC-targets.cmake
-- Installing: /usr/local/share/vc4cc/VC4CC-targets-debug.cmake
-- Up-to-date: /usr/local/include/vc4cc
-- Up-to-date: /usr/local/include/vc4cc/Precompiler.h
-- Up-to-date: /usr/local/include/vc4cc/CompilationError.h
-- Up-to-date: /usr/local/include/vc4cc/Compiler.h
-- Up-to-date: /usr/local/include/vc4cc/tools.h
-- Up-to-date: /usr/local/include/vc4cc/VC4C.h
-- Up-to-date: /usr/local/include/vc4cc/config.h
-- Up-to-date: /usr/local/lib/libvc4c_testdata.a
-- Up-to-date: /usr/local/share/vc4cc/TestData-target.cmake
-- Installing: /usr/local/share/vc4cc/TestData-target-debug.cmake
-- Up-to-date: /usr/local/include/vc4cc/TestData.h
admin@raspi01:~/opencl/VC4C/build $ sudo ldconfig
admin@raspi01:~/opencl/VC4C/build $ cd CMakeFiles/
admin@raspi01:~/opencl/VC4C/build/CMakeFiles $ nano CMakeError.log
admin@raspi01:~/opencl/VC4C/build/CMakeFiles $ cd ..
admin@raspi01:~/opencl/VC4C/build $ cd ..
admin@raspi01:~/opencl/VC4C $ cd ..
admin@raspi01:~/opencl $ cd build
-bash: cd: build: No such file or directory
admin@raspi01:~/opencl $ cd VC4CL
admin@raspi01:~/opencl/VC4CL $ cd build/
admin@raspi01:~/opencl/VC4CL/build $ cmake ..
-- Found headers for OpenCL up to version 2.2 located in /usr/include
-- VC4C library found: /home/admin/opencl/VC4C/build/src/libVC4CC.so
-- VC4C compiler header found at: /home/admin/opencl/VC4C/include/VC4C.h
-- VC4C test data library found: /home/admin/opencl/VC4C/build/test/libvc4c_testdata.a
-- VC4C test data header found: /home/admin/opencl/VC4C/build/test/TestData.h
-- vcsm library found at: /usr/lib/arm-linux-gnueabihf/libvcsm.so
-- found clang-format: /usr/bin/clang-format
-- Configuring done
-- Generating done
-- Build files have been written to: /home/admin/opencl/VC4CL/build
admin@raspi01:~/opencl/VC4CL/build $ make
[  0%] Built target GetGitCommit
Scanning dependencies of target VC4CL
[  2%] Building CXX object src/CMakeFiles/VC4CL.dir/common.cpp.o
[  5%] Linking CXX shared library libVC4CL.so
[ 82%] Built target VC4CL
[ 85%] Linking CXX executable vc4cl_dump_analyzer
[ 88%] Built target vc4cl_dump_analyzer
[ 91%] Linking CXX executable v3d_profile
[ 94%] Built target v3d_profile
[ 97%] Linking CXX executable v3d_info
[100%] Built target v3d_info
admin@raspi01:~/opencl/VC4CL/build $ sudo make install
[  0%] Built target GetGitCommit
Scanning dependencies of target VC4CL
[  2%] Building CXX object src/CMakeFiles/VC4CL.dir/common.cpp.o
[  5%] Linking CXX shared library libVC4CL.so
[ 82%] Built target VC4CL
[ 85%] Linking CXX executable vc4cl_dump_analyzer
[ 88%] Built target vc4cl_dump_analyzer
[ 91%] Linking CXX executable v3d_profile
[ 94%] Built target v3d_profile
[ 97%] Linking CXX executable v3d_info
[100%] Built target v3d_info
Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/local/lib/libVC4CL.so.0.4.9999
-- Up-to-date: /usr/local/lib/libVC4CL.so.1.2
-- Set runtime path of "/usr/local/lib/libVC4CL.so.0.4.9999" to "/usr/local/lib"
-- Up-to-date: /usr/local/lib/libVC4CL.so
-- Up-to-date: /usr/local/share/vc4cl/VC4CL-targets.cmake
-- Installing: /usr/local/share/vc4cl/VC4CL-targets-debug.cmake
-- Installing: /usr/local/bin/v3d_info
-- Set runtime path of "/usr/local/bin/v3d_info" to "/usr/local/lib"
-- Installing: /usr/local/bin/v3d_profile
-- Set runtime path of "/usr/local/bin/v3d_profile" to "/usr/local/lib"
-- Installing: /usr/local/bin/vc4cl_dump_analyzer
-- Set runtime path of "/usr/local/bin/vc4cl_dump_analyzer" to "/usr/local/lib"
doe300 commented 1 year ago

From the last log you posted, it looks like it worked, didn't it?

jDietschi commented 1 year ago

It looks like the building worked correctly. All the output was successfull. running clinfo still gives me the output platforms

Number of platforms                               0`
doe300 commented 1 year ago

To be able to use VC4CL globally, you'll need to configure it with the CMake switch BUILD_ICD=ON, rebuild and reinstall. Then it should be listed (although it requires root rights). Alternatively of course you could LD_PRELOAD the library before any OpenCL-client process invocation.

jDietschi commented 1 year ago

Thanks, I'll try that right away!

Currently running the commands

mkdir build
cd build
cmake --BUILD_ICD=ON --DMULTI_THREADED=OFF  ..
make
sudo make install
sudo ldconfig

for each directory (VC4CLStdLib, VC4C, VC4CL).

Unfortunately I still get the "Number of platforms: 0" output on clinfo.

the CMakeError.log in VC4C/build/CMakeFiles contains again this output

Performing C SOURCE FILE Test CMAKE_HAVE_LIBC_PTHREAD failed with the following output:
Change Dir: /root/opencl/VC4C/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake cmTC_832f8/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_832f8.dir/build.make CMakeFiles/cmTC_832f8.dir/build
gmake[1]: Entering directory '/root/opencl/VC4C/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_832f8.dir/src.c.o
/usr/bin/cc   -DCMAKE_HAVE_LIBC_PTHREAD -o CMakeFiles/cmTC_832f8.dir/src.c.o -c /root/opencl/VC4C/build/CMakeFiles/CMakeTmp/src.c
Linking C executable cmTC_832f8
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_832f8.dir/link.txt --verbose=1
/usr/bin/cc  -DCMAKE_HAVE_LIBC_PTHREAD -rdynamic CMakeFiles/cmTC_832f8.dir/src.c.o -o cmTC_832f8
/usr/bin/ld: CMakeFiles/cmTC_832f8.dir/src.c.o: in function `main':
src.c:(.text+0x40): undefined reference to `pthread_create'
/usr/bin/ld: src.c:(.text+0x4c): undefined reference to `pthread_detach'
/usr/bin/ld: src.c:(.text+0x58): undefined reference to `pthread_cancel'
/usr/bin/ld: src.c:(.text+0x68): undefined reference to `pthread_join'
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_832f8.dir/build.make:106: cmTC_832f8] Error 1
gmake[1]: Leaving directory '/root/opencl/VC4C/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_832f8/fast] Error 2

Source file was:
#include <pthread.h>

void* test_func(void* data)
{
  return data;
}

int main(void)
{
  pthread_t thread;
  pthread_create(&thread, NULL, test_func, NULL);
  pthread_detach(thread);
  pthread_cancel(thread);
  pthread_join(thread, NULL);
  pthread_atfork(NULL, NULL, NULL);
  pthread_exit(NULL);

  return 0;
}

Determining if the function pthread_create exists in the pthreads failed with the following output:
Change Dir: /root/opencl/VC4C/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/bin/gmake cmTC_12eea/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_12eea.dir/build.make CMakeFiles/cmTC_12eea.dir/build
gmake[1]: Entering directory '/root/opencl/VC4C/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_12eea.dir/CheckFunctionExists.c.o
/usr/bin/cc   -DCHECK_FUNCTION_EXISTS=pthread_create -o CMakeFiles/cmTC_12eea.dir/CheckFunctionExists.c.o -c /usr/share/cmake-3.18/Modules/CheckFunctionExists.c
Linking C executable cmTC_12eea
/usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_12eea.dir/link.txt --verbose=1
/usr/bin/cc  -DCHECK_FUNCTION_EXISTS=pthread_create -rdynamic CMakeFiles/cmTC_12eea.dir/CheckFunctionExists.c.o -o cmTC_12eea  -lpthreads
/usr/bin/ld: cannot find -lpthreads
collect2: error: ld returned 1 exit status
gmake[1]: *** [CMakeFiles/cmTC_12eea.dir/build.make:106: cmTC_12eea] Error 1
gmake[1]: Leaving directory '/root/opencl/VC4C/build/CMakeFiles/CMakeTmp'
gmake: *** [Makefile:140: cmTC_12eea/fast] Error 2
doe300 commented 1 year ago

The CMakeError.log is irrelevant. This is from an internal CMake capabilities test.

Can you run the clinfo with the OCL_ICD_ENABLE_TRACE=1 and VC4CL_DEBUG=api environment variables?

Also, does the file /etc/OpenCL/vendors/VC4CL.icd exist and what is its content? Should be the path to the VC4CL library.

jDietschi commented 1 year ago

Hi @doe300

After recompiling the whole projekt using the BUILD_ICD=ON switch it seems functional!

Thank you so much for your support. my /etc/OpenCL/vendors/VC4CL.icd file does correctly show the path to the VC4CL library: /usr/local/libVC4CL.so