13.1.2. Building from Source on Linux - 5.2 English - 57404

AOCL User Guide (57404)

Document ID
57404
Release Date
2025-12-29
Version
5.2 English

Complete the following steps to build AOCL-LibMem for Linux:

  1. Download and install the AOCL master installer (aocl-linux-<compiler>-<version>.tar.gz) from:

    https://www.amd.com/en/developer/aocl.html

  2. Locate the aocl-libmem folder in the root directory.

  3. Configure for one of the following builds as required:

    • GCC build

      Default Option - Compiling for Native CPU

      $ cmake -D CMAKE_C_COMPILER=gcc -S <source_dir> -B <build_dir>
      

      Compiling with Dynamic CPU Dispatcher

      $ cmake -D CMAKE_C_COMPILER=gcc -D ALMEM_DYN_DISPATCH=Y -S <source_dir> -B <build_dir>
      

      Compiling AVX2 binary

      $ cmake -D CMAKE_C_COMPILER=gcc -D ALMEM_ISA=avx2 -S <source_dir> -B <build_dir>
      

      Compiling AVX512 binary

      $ cmake -D CMAKE_C_COMPILER=gcc -D ALMEM_ISA=avx512 -S <source_dir> -B <build_dir>
      

      Compiling with Tunable Parameters

      $ cmake -D CMAKE_C_COMPILER=gcc -D ALMEM_TUNABLES=Y -S <source_dir> -B <build_dir>
      
    • AOCC (Clang) build

      Default Option - Compiling for Native CPU

      $ cmake -D CMAKE_C_COMPILER=clang -S <source_dir> -B <build_dir>
      

      Compiling with Dynamic CPU Dispatcher

      $ cmake -D CMAKE_C_COMPILER=clang -D ALMEM_DYN_DISPATCH=Y -S <source_dir> -B <build_dir>
      

      Compiling AVX2 binary

      $ cmake -D CMAKE_C_COMPILER=clang -D ALMEM_ISA=avx2 -S <source_dir> -B <build_dir>
      

      Compiling AVX512 binary

      $ cmake -D CMAKE_C_COMPILER=clang -D ALMEM_ISA=avx512 -S <source_dir> -B <build_dir>
      

      Compiling with Tunable Parameters

      $ cmake -D CMAKE_C_COMPILER=clang -D ALMEM_TUNABLES=Y -S <source_dir> -B <build_dir>
      

Note

‘ALMEM_ISA’ has precedence over ‘ALMEM_DYN_DISPATCH’ and ‘ALMEM_TUNABLES’ options.

  1. Build:

    $ cmake --build <build_dir>
    
  2. Install:

    $ cmake --install <build_dir>
    
    ## For custom install path, run configure with "CMAKE_INSTALL_PREFIX"
    

Note

Both shared (libaocl-libmem.so) and static (libaocl-libmem.a) library files are installed under <build_dir>/lib/ path.

A Dynamic dispatched binary may not always deliver the best performance of the library on the specified architecture. To achieve optimal performance on the given architecture, it’s advisable to use the default native build option.

The dynamic loading library APIs (dlopen, dlclose, and dlsym) were added to Glibc in version 2.34. To run on environments with Glibc versions below 2.34, you should recompile the library with that specific Glibc version to avoid runtime symbol resolution issues.