Arthur Ratz
Published © GPL3+

Parallel Computing On Raspberry Pi 4B+ IoT Boards Made Easy

Building and running a parallel code in C++17, implemented using Khronos CL/SYCL-model specification, on Raspberry Pi IoT boards.

AdvancedProtip2 hours5,636
Parallel Computing On Raspberry Pi 4B+ IoT Boards Made Easy

Things used in this project

Hardware components

Raspberry Pi 4 Desktop Kit - 4/8 GB
×1

Software apps and online services

Raspbian
Raspberry Pi Raspbian

Story

Read more

Schematics

The Next Generation Of Raspberry Pi 4B+ IoT Boards

The image source: https://www.raspberrypi.org/

Code

LLVM/Clang-9.x.x Compilers And Aksel Alpay's hipSYCL Installation And Configuration Script

BatchFile
An automated bash-script for installing and configuring the LLVM/Clang-9.x.x Arm/Aarch64 Compilers And Aksel Alpay's hipSYCL library open-source distribution
#!/bin/sh

sudo apt update

sudo apt install -y bison flex python python3 snap snapd git wget

sudo snap install cmake --classic
sudo snap install clangd --classic

sudo apt install -y libc++-dev libc++1 libc++abi-dev libc++abi1 libpthread-stubs0-dev libpthread-workqueue-dev
sudo apt install -y clang-format clang-tidy clang-tools clang libc++-dev libc++1 libc++abi-dev libc++abi1 libclang-dev libclang1 liblldb-dev libllvm-ocaml-dev libomp-dev libomp5 lld lldb llvm-dev llvm-runtime llvm python-clang libboost-all-dev

wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -

echo "deb http://apt.llvm.org/buster/ llvm-toolchain-buster main" >> /etc/apt/sources.list.d/raspi.list
echo "deb-src http://apt.llvm.org/buster/ llvm-toolchain-buster main" >> /etc/apt/sources.list.d/raspi.list

cd ~

sudo apt update

sudo apt install -y clang-9 lldb-9 lld-9

cd /usr/bin && rm -f clang clang++

cd /usr/bin && ln -s clang-9 clang
cd /usr/bin && ln -s clang++-9 clang++

cd ~

git clone https://github.com/llvm/llvm-project llvm-project
git clone --recurse-submodules https://github.com/illuhad/hipSYCL

export LLVM_INSTALL_PREFIX=/usr
export LLVM_DIR=~/llvm-project/llvm
export CLANG_EXECUTABLE_PATH=/usr/bin/clang++
export CLANG_INCLUDE_PATH=$LLVM_INSTALL_PREFIX/include/clang/9.0.1/include

echo "export LLVM_INSTALL_PREFIX=/usr" >> /root/.bashrc
echo "export LLVM_DIR=~/llvm-project/llvm" >> /root/.bashrc
echo "export CLANG_EXECUTABLE_PATH=/usr/bin/clang++" >> /root/.bashrc
echo "export CLANG_INCLUDE_PATH=$LLVM_INSTALL_PREFIX/include/clang/9.0.1/include" >> /root/.bashrc

env LLVM_INSTALL_PREFIX=/usr
env LLVM_DIR=~/llvm-project/llvm
env CLANG_EXECUTABLE_PATH=/usr/bin/clang++
env CLANG_INCLUDE_PATH=$LLVM_INSTALL_PREFIX/include/clang/9.0.1/include

mkdir ~/hipSYCL/build && cd ~/hipSYCL/build

cmake -DCMAKE_INSTALL_PREFIX=/opt/hipSYCL ..

make -j $(nproc) && make install -j $(nproc)

cp /opt/hipSYCL/lib/libhipSYCL-rt.so /usr/lib/libhipSYCL-rt.so

export PATH=$PATH:/opt/hipSYCL/bin
export C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/hipSYCL/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/hipSYCL/include
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/hipSYCL/lib

echo "export PATH=$PATH:/opt/hipSYCL/bin" >> /root/.bashrc
echo "export C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/hipSYCL/include" >> /root/.bashrc
echo "export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/hipSYCL/include" >> /root/.bashrc
echo "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/hipSYCL/lib" >> /root/.bashrc

env PATH=$PATH:/opt/hipSYCL/bin
env C_INCLUDE_PATH=$C_INCLUDE_PATH:/opt/hipSYCL/include
env CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/opt/hipSYCL/include
env LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/hipSYCL/lib

echo "\n*** CONGRATULATIONS!!! YOU'RE ALL SET! ***\n\n"
echo "*** BUILDING MATMUL PROJECT FOR RASPI4B+ ***\n\n"

rm -rf ~/sources

mkdir ~/sources && cd ~/sources

cp ~/matmul_hipsycl.tar.gz ~/sources/matmul_hipsycl.tar.gz

tar -xvf matmul_hipsycl.tar.gz

rm -f matmul_hipsycl.tar.gz

make all

echo "\n*** RUNNING PARALLEL MATMUL (CL/HIPSYCL) EXECUTABLE ON RASPI4B+ ***\n"

./matrix_mul_rpi4 > output.txt

cat output.txt

rm -f output.txt && cd ~

echo "\n*** SUCCESS!!! ***\n\n"

matmul_hipsycl.tar.gz

C/C++
A parallel matrix multiplication code sample, in C++17, using Aksel Alpay's hipSYCL library, targeting the Raspberry Pi's Arm/Aarch64 hardware architecture.
No preview (download only).

Credits

Arthur Ratz

Arthur Ratz

1 project • 0 followers

Comments