AOCL now offers the capability to compile individual libraries and
consolidate them into a unified binary. With the Build-It-Yourself
feature, you can choose one or more AOCL libraries and merge them into a
single library by configuring the appropriate CMake options. This
unified binary is assigned a default name: libaocl.so
/ libaocl.a
for
Linux or aocl.dll
/ aocl.lib
for Windows. This approach simplifies
integration by eliminating dependencies on library linking order and
preventing API duplication, ensuring smooth and efficient incorporation
of multiple AOCL libraries.
Note
Currently, Build-It-Yourself supports selection of AOCL-BLAS, AOCL-Utils, AOCL-LAPACK, AOCL-Sparse, AOCL-LibM, AOCL-Compression, and AOCL-Cryptography libraries only.
- AOCL Build-It-Yourself
The project is structured as follows:
aocl_blis_build.cmake
: CMake script for building AOCL-BLAS.aocl_compression_build.cmake
: CMake script for building AOCL-COMPRESSION.aocl_crypto_build.cmake
: CMake script for building AOCL-CRYPTO.aocl_libflame_build.cmake
: CMake script for building AOCL-LAPACK.aocl_libm_build.cmake
: CMake script for building AOCL-LIBM.aocl_sparse_build.cmake
: CMake script for building AOCL-SPARSE.aocl_utils_build.cmake
: CMake script for building AOCL-UTILS.CMakeLists.txt
: Main CMake script for the AOCL project.CMakePresets.json
: CMake presets for different build configurations.README.md
: This README file.presets/
: Directory containing preset configurations for different platforms.
This section explains how to configure the CMake options and the procedure to build the unified AOCL binary on both Linux and Windows platforms. Note that the procedure to configure is the same for both OSs but the only difference is in the prerequisites for each OS.
The following sub-sections describe the process:
- Meeting the prerequisites
- Cloning the repository
- Configuring the build options
- Building the unified binary
The following dependencies must be met for installing AOCL on Linux:
-
Target CPU with support for FMA, AVX2 or higher
-
Git
-
Python
-
CMake
-
GCC, g++, and Gfortran
-
AOCC
-
OpenSSL for AOCL-Cryptography:
- Define the environment variable
OPENSSL_INSTALL_DIR
to point to OpenSSL installation:
$ export OPENSSL_INSTALL_DIR=/home/user/openssl
- Define the environment variable
Note
To build the AOCL-Cryptography library, the libcrypto.so
and
libssl.so
libraries are required. Set the OPENSSL_INSTALL_DIR
environment variable to the path where OpenSSL is installed. Ensure this
directory includes the include
folder and either lib
or lib64
.
Within the lib
or lib64
folder, verify that the libcrypto.so
and
libssl.so
libraries are present.
The following dependencies must be met for building AOCL on Windows:
-
Target CPU with support for FMA, AVX2 or higher
-
LLVM
-
CMake
-
Microsoft Visual Studio IDE
-
Microsoft Visual Studio tools:
- Python development
- Desktop development with C++: C++ Clang-Cl for v142 build tool(x64/x86)
-
OpenSSL for AOCL-Cryptography:
- Define the environment variable
OPENSSL_INSTALL_DIR
to point to OpenSSL installation:
$ set OPENSSL_INSTALL_DIR=C:/Program Files/OpenSSL-Win64
- Define the environment variable
Note
To build the AOCL-Cryptography library, the libcrypto.lib
and
libssl.lib
libraries are required. Set the OPENSSL_INSTALL_DIR
environment variable to the directory where OpenSSL is installed. Make
sure this directory includes the include
and lib
folders. Within the
lib
folder, ensure that the libcrypto.lib
and libssl.lib
libraries
are present.
For more information on validated versions of compiler/LLVM, CMake and
Python, and OpenSSL libraries refer to Validation Matrix
chapter in
AOCL userguide document.
To set up and use Build-It-Yourself, you must clone the repository, configure the build options, and build the unified binary.
First, clone the AOCL repository from GitHub:
$ git clone https://github.com/amd/aocl.git
$ cd aocl
There are multiple CMake options you can configure. The following sections explain the CMake options to:
- Include or exclude individual AOCL libraries (see CMake Options to Select Libraries).
- Provide the source code for the selected libraries by using one of
the following options:
- Setting the path of the AOCL libraries source code (see CMake Options to Set Library Source Path)
- Setting the GIT repository and tag or branch name (see CMake Options to Set GIT Repository and Tag/Branch)
- Static or Shared Library:
- Static Library
-DBUILD_SHARED_LIBS=OFF
- Shared Library
-DBUILD_SHARED_LIBS=ON
(default)
- Static Library
- Select Data Type (LP64 or ILP64):
- LP64
-DENABLE_ILP64=OFF
(default) - ILP64
-DENABLE_ILP64=ON
- LP64
- Enable or disable threading:
- Multithreading
-DENABLE_MULTITHREADING=ON
- Single threading
-DENABLE_MULTITHREADING=OFF
(default)
- Multithreading
- Link Desired OpenMP library using
-DOpenMP_libomp_LIBRARY=<path to OpenMP library>
when,-DENABLE_MULTITHREADING=ON
.
Here is an example of a configuration command:
Linux
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF
-DENABLE_ILP64=OFF -DENABLE_AOCL_BLAS=ON -DENABLE_AOCL_UTILS=ON
-DENABLE_AOCL_LAPACK=ON -DENABLE_MULTITHREADING=ON -DOpenMP_libomp_LIBRARY=""
-DCMAKE_INSTALL_PREFIX=$PWD/install_package
Windows
$ cmake -S . -B build -G "Visual Studio 17 2022" -DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=OFF -DENABLE_ILP64=OFF -DENABLE_AOCL_BLAS=ON
-DENABLE_AOCL_UTILS=ON -DENABLE_AOCL_LAPACK=ON -DENABLE_MULTITHREADING=ON -TClangCl
-DCMAKE_INSTALL_PREFIX=%CD%/install_package -DCMAKE_CONFIGURATION_TYPES=Release
Use the following command to build the unified binary:
$ cmake --build build --config release --target install
The AOCL project provides a set of CMake presets to simplify the configuration and build process for different platforms and compilers. Some of these presets are:
- aocl-linux-make-lp-ga-gcc-config: Linux with GNU Make and GCC
- aocl-linux-make-ilp-ga-gcc-config: Linux with GNU Make and GCC (ILP64)
- aocl-linux-make-lp-ga-aocc-config: Linux with GNU Make and AOCC
- aocl-linux-make-ilp-ga-aocc-config: Linux with GNU Make and AOCC (ILP64)
- aocl-win-msvc-lp-ga-config: Windows with Visual Studio and Clang/LLVM
- aocl-win-msvc-ilp-ga-config: Windows with Visual Studio and Clang/LLVM (ILP64)
- aocl-win-ninja-lp-ga-config: Windows with Ninja and Clang/LLVM
- aocl-win-ninja-ilp-ga-config: Windows with Ninja and Clang/LLVM (ILP64)
Details of aocl-linux-make-lp-ga-gcc-config are given here.
The aocl-linux-make-lp-ga-gcc-config
preset is a convenient and
efficient way to build AOCL on Linux platforms with GCC. It provides a
stable, production-ready configuration while allowing flexibility for
customization based on specific requirements.
-
How is the Name Derived?
- aocl: Refers to AMD Optimized Libraries.
- linux: Indicates that the preset is for Linux platforms.
- make: Specifies the use of the GNU Make build system.
- lp: Refers to the LP64 data model, which is the default for most Linux systems.
- ga: Stands for General Availability Release, indicating that this preset is stable and production-ready.
- gcc: Specifies the use of the GCC compiler.
-
Default Configuration: By default, this preset builds a shared multithreaded library. It can be customized to build static or single-threaded libraries by modifying the relevant CMake variables.
- CMAKE_BUILD_TYPE:
Release
Specifies that the build should be optimized for performance. - BUILD_SHARED_LIBS:
ON
Indicates that shared libraries are built by default. - ENABLE_ILP64:
OFF
Configures the build to use the LP64 data model. - ENABLE_MULTITHREADING:
ON
Enables multithreading support by default. - CMAKE_C_COMPILER:
gcc
Specifies GCC as the C compiler. - CMAKE_CXX_COMPILER:
g++
Specifies G++ as the C++ compiler. - CMAKE_Fortran_COMPILER:
gfortran
Specifies GFortran as the Fortran compiler.
- CMAKE_BUILD_TYPE:
-
Required Environment Variables: Before running this preset, ensure the following environment variables are set:
-
OPENSSL_INSTALL_DIR: Points to the directory where OpenSSL is installed. This is required for building the AOCL-Cryptography library. Ensure this directory contains the
include
folder and either thelib
orlib64
folder withlibcrypto.so
andlibssl.so
libraries. -
ONEAPI_ROOT / oneAPI_ROOT: Specifies the root directory of the Intel oneAPI toolkit. Use ONEAPI_ROOT for Linux and oneAPI_ROOT for Windows. This is mandatory for Windows and optional for Linux. It is required if you want to use the Intel OpenMP runtime library.
- Linux: The library is typically located at:
$env{ONEAPI_ROOT}/compiler/latest/lib/libiomp5.so
. - Windows: The library is typically located at:
$env{oneAPI_ROOT}/compiler/latest/lib/libiomp5md.lib
.
Ensure that the appropriate environment variable (
ONEAPI_ROOT
oroneAPI_ROOT
) is set to the correct path where the oneAPI toolkit is installed. - Linux: The library is typically located at:
-
-
Example Command to Use This Preset: To configure the build using this preset, run the following command:
$ cmake --preset aocl-linux-make-lp-ga-gcc-config --fresh
This command will set up the build environment with the predefined configuration for this preset.
-
Customization Options: You can customize the build by overriding the default CMake variables. For example:
- To build a static library, set
-DBUILD_SHARED_LIBS=OFF
. - To disable multithreading, set
-DENABLE_MULTITHREADING=OFF
.
For more customization options, refer to the CMake variables
configure-the-build-options
{.interpreted-text role="ref"}. - To build a static library, set
The following sections provide examples of configuration and build commands on Linux using the CMake build system.
Note
Use the [-DOpenMP_libomp_LIBRARY]{.title-ref} option to link the desired OpenMP library.
Complete the following steps to build and install a single-thread AOCL:
-
Clone the AOCL from Git repository (https://github.com/amd/aocl.git).
$ git clone https://github.com/amd/aocl.git $ cd aocl
-
Configure the library as required:
# CMake commands # GCC (Default) and LP64 $ cmake --preset aocl-linux-make-lp-ga-gcc-config -DENABLE_MULTITHREADING=OFF --fresh # GCC and ILP64 $ cmake --preset aocl-linux-make-ilp-ga-gcc-config -DENABLE_MULTITHREADING=OFF --fresh # AOCC and LP64 $ cmake --preset aocl-linux-make-lp-ga-aocc-config -DENABLE_MULTITHREADING=OFF --fresh # AOCC and ILP64 $ cmake --preset aocl-linux-make-ilp-ga-aocc-config -DENABLE_MULTITHREADING=OFF --fresh
-
Build the unified binary and install using the command:
$ cmake --build build --config release -j --target install
Complete the following steps to install a multi-thread AOCL:
-
Clone the AOCL from Git repository (https://github.com/amd/aocl.git).
$ git clone https://github.com/amd/aocl.git $ cd aocl
-
Configure the library as required:
# CMake commands # GCC (Default) and LP64 $ cmake --preset aocl-linux-make-lp-ga-gcc-config --fresh # GCC and ILP64 $ cmake --preset aocl-linux-make-ilp-ga-gcc-config --fresh # AOCC and LP64 $ cmake --preset aocl-linux-make-lp-ga-aocc-config --fresh # AOCC and ILP64 $ cmake --preset aocl-linux-make-ilp-ga-aocc-config --fresh # GCC (Default) and LP64 with Desired OpenMP library Path $ cmake --preset aocl-linux-make-lp-ga-gcc-config --fresh -DOpenMP_libomp_LIBRARY=<path to OpenMP library>
-
Build the unified binary and install using the command:
$ cmake --build build --config Release -j --target install
Configure the Project in Command Prompt
# CMake commands using Visual Studio 17 2022 Generator
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
# Clang/LLVM (Default) and LP64
$ cmake --preset aocl-win-msvc-lp-ga-config --fresh
# Clang/LLVM and ILP64
$ cmake --preset aocl-win-msvc-ilp-ga-config --fresh
# Clang/LLVM (Default) and LP64 with Desired OpenMP library Path
$ cmake --preset aocl-win-msvc-lp-ga-config --fresh -DOpenMP_libomp_LIBRARY=<path to OpenMP library>
# CMake commands using Ninja Generator
$ "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Auxiliary\\Build\\vcvarsall.bat" x64
$ set PATH="C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\Ninja";%PATH%
# Clang/LLVM (Default) and LP64
$ cmake --preset aocl-win-ninja-lp-ga-config --fresh
# Clang/LLVM and ILP64
$ cmake --preset aocl-win-ninja-ilp-ga-config --fresh
# Clang/LLVM (Default) and LP64 with Desired OpenMP library Path
$ cmake --preset aocl-win-ninja-lp-ga-config --fresh -DOpenMP_libomp_LIBRARY=<path to OpenMP library>
Build the Project in Command Prompt
$ cmake --build build --config Release --target install
The AOCL package will be installed in the install_package
directory
which is created inside the AOCL source directory.
There are two subfolders within the install_package
folder: lib
and
include
.
- The
include
folder contains the header files required for using the AOCL libraries in applications. - The
lib
folder contains the compiled binaries:- On Linux:
libaocl.so
andlibaocl.a
. - On Windows:
aocl.dll
andaocl.lib
.
- On Linux:
This section provides a detailed reference for the CMake variables used to configure the Build-It-Yourself AOCL project. These variables allow customization of the build process, including selecting libraries and specifying source paths. Use these options to tailor the unified AOCL binary to specific requirements.
The following table lists the CMake variables used to include or exclude individual AOCL libraries.
CMake Variable or Option | Usage |
---|---|
ENABLE_AOCL_UTILS | -DENABLE_AOCL_UTILS=ON (default) or -DENABLE_AOCL_UTILS=OFF to exclude from the library. |
ENABLE_AOCL_BLAS | -DENABLE_AOCL_BLAS=OFF (default) or -DENABLE_AOCL_BLAS=ON to include in the library. |
ENABLE_AOCL_LAPACK | -DENABLE_AOCL_LAPACK=OFF (default) or -DENABLE_AOCL_LAPACK=ON to include in the library. |
ENABLE_AOCL_SPARSE | -DENABLE_AOCL_SPARSE=OFF (default) or -DENABLE_AOCL_SPARSE=ON to include in the library. |
ENABLE_AOCL_CRYPTO | -DENABLE_AOCL_CRYPTO=OFF (default) or -DENABLE_AOCL_CRYPTO=ON to include in the library. |
ENABLE_AOCL_LIBM | -DENABLE_AOCL_LIBM=OFF (default) or -DENABLE_AOCL_LIBM=ON to include in the library. |
ENABLE_AOCL_COMPRESSION | -DENABLE_AOCL_COMPRESSION=OFF (default) or -DENABLE_AOCL_COMPRESSION=ON to include in the library. |
The following table lists CMake variables to specify the path of AOCL library sources. These variables are useful when local copies of the repositories are available, particularly in environments without internet access.
CMake Variable or Option | Usage |
---|---|
UTILS_PATH | -DUTILS_PATH=<Directory Path where AOCL-Utils is present> . |
BLAS_PATH | -DBLAS_PATH=<Directory Path where AOCL-BLAS is present> . |
LAPACK_PATH | -DLAPACK_PATH=<Directory Path where AOCL-LAPACK is present> . |
SPARSE_PATH | -DSPARSE_PATH=<Directory Path where AOCL-Sparse is present> . |
CRYPTO_PATH | -DCRYPTO_PATH=<Directory Path where AOCL-Cryptography is present> . |
LIBM_PATH | -DLIBM_PATH=<Directory Path where AOCL-LibM is present> . |
COMPRESSION_PATH | -DCOMPRESSION_PATH=<Directory Path where AOCL-Compression is present> . |
The following table lists CMake variables to specify the GIT repository
and tag or branch name for cloning individual AOCL libraries. If the
source code path is not provided, CMake uses the specified GIT
repository and tag or branch. This is useful for building source code
from the dev
branch of individual libraries. If neither the source
code path nor the GIT repository and tag are provided, CMake defaults to
the repository and branch/tag for the AOCL stable public release.
CMake Variable or Option | Default Value | Usage |
---|---|---|
UTILS_GIT_REPOSITORY | https://github.com/amd/aocl-utils.git | -DUTILS_GIT_REPOSITORY=<AOCL-Utils Repository URL> |
UTILS_GIT_TAG | main |
-DUTILS_GIT_TAG=<AOCL-Utils Git Tag or Branch Name> |
BLAS_GIT_REPOSITORY | https://github.com/amd/blis.git | -DBLAS_GIT_REPOSITORY=<AOCL-BLAS Repository URL> |
BLAS_GIT_TAG | master |
-DBLAS_GIT_TAG=<AOCL-BLAS Git Tag or Branch Name> |
LAPACK_GIT_REPOSITORY | https://github.com/amd/libflame.git | -DLAPACK_GIT_REPOSITORY=<AOCL-LAPACK Repository URL> |
LAPACK_GIT_TAG | master |
-DLAPACK_GIT_TAG=<AOCL-LAPACK Git Tag or Branch Name> |
SPARSE_GIT_REPOSITORY | https://github.com/amd/aocl-sparse.git | -DSPARSE_GIT_REPOSITORY=<AOCL-Sparse Repository URL> |
SPARSE_GIT_TAG | master |
-DSPARSE_GIT_TAG=<AOCL-Sparse Git Tag or Branch Name> |
CRYPTO_GIT_REPOSITORY | https://github.com/amd/aocl-crypto.git | -DCRYPTO_GIT_REPOSITORY=<AOCL-Cryptography Repository URL> |
CRYPTO_GIT_TAG | main |
-DCRYPTO_GIT_TAG=<AOCL-Cryptography Git Tag or Branch Name> |
LIBM_GIT_REPOSITORY | https://github.com/amd/aocl-libm-ose.git | -DLIBM_GIT_REPOSITORY=<AOCL-LibM Repository URL> |
LIBM_GIT_TAG | master |
-DLIBM_GIT_TAG=<AOCL-LibM Git Tag or Branch Name> |
COMPRESSION_GIT_REPOSITORY | https://github.com/amd/aocl-compression.git | -DCOMPRESSION_GIT_REPOSITORY=<AOCL-Compression Repository URL> |
COMPRESSION_GIT_TAG | amd-main |
-DCOMPRESSION_GIT_TAG=<AOCL-Compression Git Tag or Branch Name> |