QuentinOchem b12938f1d7 Merge pull request #73 from AdaCore/workaround_gprlib
added workaround  to current gprlib issues
2022-09-16 09:49:47 +02:00
2022-09-12 15:12:37 -04:00
2022-06-24 14:27:19 -04:00
2022-08-25 15:00:53 +02:00
2020-09-17 22:10:49 -04:00
2022-05-04 17:17:38 +02:00
2021-03-23 20:52:37 +11:00
2022-08-31 10:14:37 +02:00

GNAT for CUDA

GNAT for CUDA® is a toolsuite that allows to compile Ada and SPARK code directly for NVIDIA GPUs.

Documentation

For a thorough discussion about GNAT for CUDA please consult the official documentation. A html version can be built like so:

cd doc
make hmtl

Status

Beta

Quickstart

End user - archive distribution

Note: During beta phase this package is available on request/invitation only.

Prerequisites

  • GNAT toolchain - AdaCore client portal
  • CUDA libraries - eg. apt-get
  • GNAT aarch64-linux cross compiler toolchain - AdaCore client portal (optional)

Developper - git repository clone

Note: During beta phase this repo can only be built by AdaCore engineers with anod acces.

Prerequisites

  • GNAT toolchain - anod
  • CUDA libraries - eg. apt-get
  • GNAT aarch64-linux cross compiler toolchain - anod (optional)
  • GNAT sources - anod (set root Makefile $GNAT_SRC to it)
  • bb-runtimes - anod (set root Makefile $BB_SRC to it)
  • CUDA_env - anod (set to system environment variables)

Setup GNAT for CUDA

chmod +x setup.sh
./setup.sh
  • End user only:
source ./env.sh 

Build cuda-gcc (optional)

make

Compilation of vectorAdd example program

Note: By default we are building for x86_64, Turing family GPU sm_75

cd examples/0_Simple/vectorAdd
make

Cross-compilation of vectorAdd example program

Note: To illustrate concrete cross-compilation steps, the following instructions are contextualized for cross-compiling from a x86_64-linux desktop (host) to a aarch64-linux Jetson Nano (cuda_host) Maxwell family GPU sm_53 running an Ubuntu 18.04 derivative as officialy published by NVIDIA. The cuda_host is located at LAN IP address 192.168.x.y running as user alice:

$ which aarch64-linux-gnu-gcc
[somewhere_on_your_disk]/aarch64-linux-linux64/gnat/install/bin/aarch64-linux-gnu-gcc

$ echo $ENV_PREFIX
[somewhere_on_your_disk]/aarch64-linux-linux64/system-libs/src/aarch64-linux-system
  • As we will use the CUDA libraries found on the cuda_host, install sshfs. On host:
sudo apt install sshfs
  • Create folders. On host:
    /usr/lib/aarch64-linux-gnu/
    /usr/local/cuda/targets/aarch64-linux/lib
    /usr/local/cuda/targets/aarch64-linux/lib/stubs
sudo mkdir -p /usr/lib/aarch64-linux-gnu/
sudo mkdir -p /usr/local/cuda/targets/aarch64-linux/lib/stubs
  • Mount cuda_host aarch64 system libs to newly created host directory using sshfs. On host:
sudo sshfs -o nonempty,allow_other,default_permissions alice@192.168.x.y:/usr/lib/aarch64-linux-gnu/ /usr/lib/aarch64-linux-gnu/
  • Mount cuda_host aarch64 CUDA libs to newly created host directory using sshfs. On host:
sudo sshfs -o nonempty,allow_other,default_permissions alice@192.168.x.y:/usr/local/cuda/targets/aarch64-linux/lib /usr/local/cuda/targets/aarch64-linux/lib
  • Edit examples/Makefile.include to:
GPU_ARCH=sm_53
CUDA_HOST=aarch64-linux
  • Build example program. On host:
source ./env.sh
cd examples/0_Simple/vectorAdd
make
  • Copy executable to cuda_host. On host:
scp main alice@192.168.x.y:~
  • Move to cuda_host. On host:
ssh alice@192.168.x.y:~
./main
Description
No description provided
Readme 12 MiB
Languages
Ada 88.2%
Python 5.9%
Shell 4.1%
Makefile 0.9%
Perl 0.9%