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

AOCL User Guide (57404)

Document_ID
57404
Release_Date
2026-05-13
Version
5.3 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 for Specific Zen Architecture (zen1, zen2, zen3, zen4, zen5)

      $ cmake -D CMAKE_C_COMPILER=gcc -D ALMEM_ARCH=zen4 -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 for Specific Zen Architecture (zen1, zen2, zen3, zen4, zen5)

      $ cmake -D CMAKE_C_COMPILER=clang -D ALMEM_ARCH=zen4 -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>
      

    Compiling Strict-Bounds Variant

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

    Note

    ‘ALMEM_ARCH’ has highest precedence, followed by ‘ALMEM_ISA’, then ‘ALMEM_DYN_DISPATCH’ and ‘ALMEM_TUNABLES’ options.

    Note

    ‘ALMEM_STRICT_BOUNDS’ can be combined with any of the above build modes. By default, the library uses page-boundary-safe unmasked vector loads for small-size code paths to improve throughput. The strict-bounds variant replaces these with masked loads that never read beyond the caller-specified buffer size, even within the same mapped page. The tradeoff is a slight reduction in performance, as masked loads have higher latency than unmasked loads.

  4. Build:

    $ cmake --build <build_dir>
    
  5. 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.