Difference between revisions of "Toolchain"

From NaplesPU Documentation
Jump to: navigation, search
(Extensions)
Line 1: Line 1:
The nu+ toolchain is a collection of tools required to compile a nu+ ''executable'' application. It is based on the [https://llvm.org LLVM] project leveraging on a custom version of the [[Frontend | Clang Frontend]] and on a ''from-scratch'' implementation of the [[Backend | Backend]]. The toolchain comes with a modified version of [https://lld.llvm.org LLD], an ''elf2hex'' tool to generate nu+ compatible memory images and lastly a custom version of the ''objdump'' tool for debug purposes. A custom implementation of the ''libc'' libraries is provided.
+
The NaplesPU toolchain is a collection of tools required to compile a NaplesPU ''executable'' application. It is based on the [https://llvm.org LLVM] project leveraging on a custom version of the [[Frontend | Clang Frontend]] and on a ''from-scratch'' implementation of the [[Backend | Backend]]. The toolchain comes with a modified version of [https://lld.llvm.org LLD], an ''elf2hex'' tool to generate NaplesPU compatible memory images and lastly a custom version of the ''objdump'' tool for debuggingc purposes. A custom implementation of the ''libc'' libraries is provided.
  
 
The toolchain supports the compilation of ''C''-based and ''OpenCL C'' kernels.   
 
The toolchain supports the compilation of ''C''-based and ''OpenCL C'' kernels.   
  
 
== Building Toolchain on Ubuntu Linux environment ==
 
== Building Toolchain on Ubuntu Linux environment ==
This section shows how to build the nu+ toolchain in an Ubuntu Linux environment. The following steps are still valid in any other Unix-based system despite of package manager related differences.
+
This section shows how to build the NaplesPU toolchain in an Ubuntu Linux environment. The following steps are still valid in any other Unix-based system despite package manager related differences.
  
 
=== Required Software ===
 
=== Required Software ===
The nu+ toolchain installation relies on the following dependencies:
+
The NaplesPU toolchain installation relies on the following dependencies:
 
* Git
 
* Git
 
* GCC
 
* GCC
Line 31: Line 31:
 
<code> $ git clone https://gitlab.com/catecio/NuPlusLLVM.git <clone_directory> </code>
 
<code> $ git clone https://gitlab.com/catecio/NuPlusLLVM.git <clone_directory> </code>
  
The repository contains a helper script, ''setup.sh'' to make easier the installation process. To build a new implementation of the nu+ toolchain just type:   
+
The repository contains a helper script, ''setup.sh'' to make easier the installation process. To build a new implementation of the NaplesPU toolchain just type:   
  
 
<code> $  ./setup.sh -n </code>
 
<code> $  ./setup.sh -n </code>
  
This command starts the compilation process, installing the toolchain in ''Release Mode'' in <code>/usr/local/llvm-nuplus</code>.  
+
This command starts the compilation process, installing the toolchain in ''Release Mode'' in <code>/usr/local/llvm-npu</code>.  
 
If a debug version is required, add the <code> -d </code> flag to ''setup.sh''. You can also choose the number of threads for the compilation process, by using the <code> -t=<number_of_threads> </code> parameter.
 
If a debug version is required, add the <code> -d </code> flag to ''setup.sh''. You can also choose the number of threads for the compilation process, by using the <code> -t=<number_of_threads> </code> parameter.
  
Line 44: Line 44:
 
Now, you can use the toolchain to build your own application.
 
Now, you can use the toolchain to build your own application.
  
== The nu+ LLVM Structure ==
+
== The NaplesPU LLVM Structure ==
The nu+ toolchain relies on the LLVM project, version 7.0,  providing a custom implementation of its libraries in order to make possible the generation of nu+ kernels.  
+
The NaplesPU toolchain relies on the LLVM project, version 7.0,  providing a custom implementation of its libraries in order to make possible the generation of NaplesPU kernels.  
  
[http://clang.llvm.org Clang] is the compiler frontend for nu+, extended to handle the token-recognition of custom intrinsic functions.  
+
[http://clang.llvm.org Clang] is the compiler frontend for NaplesPU, extended to handle the token-recognition of custom intrinsic functions.  
  
[http://llvm.org/ LLVM] core libraries are used to implement a custom backend for nu+, to manage the code lowering on the target-device.
+
[http://llvm.org/ LLVM] core libraries are used to implement a custom backend for NaplesPU, to manage the code lowering on the target device.
  
[http://lld.llvm.org LLD] is adapted to match nu+ architecture requirements for linking.
+
[http://lld.llvm.org LLD] is adapted to match NaplesPU architecture requirements for linking.
  
 
[http://llvm.org/docs/CommandGuide/llvm-objdump.html objdump] is provided to disassemble and analyze the generated code.
 
[http://llvm.org/docs/CommandGuide/llvm-objdump.html objdump] is provided to disassemble and analyze the generated code.
Line 59: Line 59:
  
 
Check the following links for detailed informations on how the toolchain is implemented.
 
Check the following links for detailed informations on how the toolchain is implemented.
*  [[nu+ Clang Documentation | ''nu+'' Clang Documentation]]
+
*  [[nu+ Clang Documentation | ''NaplesPU '' Clang Documentation]]
*  [[nu+ LLVM Documentation | ''nu+'' LLVM Documentation]]
+
*  [[nu+ LLVM Documentation | ''NaplesPU '' LLVM Documentation]]
*  [[nu+ LLD Linker| ''nu+'' LLD Linker Documentation]]
+
*  [[nu+ LLD Linker| ''NaplesPU '' LLD Linker Documentation]]
*  [[nu+ Tools | ''nu+'' Tools]]
+
*  [[nu+ Tools | ''NaplesPU '' Tools]]
*  [[nu+ Libraries | ''nu+'' Libraries]]
+
*  [[nu+ Libraries | ''NaplesPU '' Libraries]]
  
 
== Extensions ==
 
== Extensions ==
  
* [[Extending nu+ for 64-bit support]]
+
* [[Extending NaplesPU for 64-bit support]]
* [[Extending nu+ for OpenCL support]]
+
* [[Extending NaplesPU for OpenCL support]]

Revision as of 15:40, 19 June 2019

The NaplesPU toolchain is a collection of tools required to compile a NaplesPU executable application. It is based on the LLVM project leveraging on a custom version of the Clang Frontend and on a from-scratch implementation of the Backend. The toolchain comes with a modified version of LLD, an elf2hex tool to generate NaplesPU compatible memory images and lastly a custom version of the objdump tool for debuggingc purposes. A custom implementation of the libc libraries is provided.

The toolchain supports the compilation of C-based and OpenCL C kernels.

Building Toolchain on Ubuntu Linux environment

This section shows how to build the NaplesPU toolchain in an Ubuntu Linux environment. The following steps are still valid in any other Unix-based system despite package manager related differences.

Required Software

The NaplesPU toolchain installation relies on the following dependencies:

  • Git
  • GCC
  • CMake
  • Python 2.7
  • libxml
  • Zlib
  • Bison
  • Flex
  • Libedit
  • Swig
  • ncurses libraries
  • Ninja

The following terminal command may be used to install all required software:

$ sudo apt install libxml2-dev git cmake gcc g++ python bison flex zlib1g-dev swig python-dev libedit-dev libncurses5-dev ninja-build

Building Process

First, you have to obtain the source code from the official repository by typing the following command:

$ git clone https://gitlab.com/catecio/NuPlusLLVM.git <clone_directory>

The repository contains a helper script, setup.sh to make easier the installation process. To build a new implementation of the NaplesPU toolchain just type:

$ ./setup.sh -n

This command starts the compilation process, installing the toolchain in Release Mode in /usr/local/llvm-npu. If a debug version is required, add the -d flag to setup.sh. You can also choose the number of threads for the compilation process, by using the -t=<number_of_threads> parameter.

At the end of the compilation process, libraries are required to be linked to the installation folder:

$ ./setup.sh -l

Now, you can use the toolchain to build your own application.

The NaplesPU LLVM Structure

The NaplesPU toolchain relies on the LLVM project, version 7.0, providing a custom implementation of its libraries in order to make possible the generation of NaplesPU kernels.

Clang is the compiler frontend for NaplesPU, extended to handle the token-recognition of custom intrinsic functions.

LLVM core libraries are used to implement a custom backend for NaplesPU, to manage the code lowering on the target device.

LLD is adapted to match NaplesPU architecture requirements for linking.

objdump is provided to disassemble and analyze the generated code.

elf2hex is a tool required for memory image generation.


Check the following links for detailed informations on how the toolchain is implemented.

Extensions