AMD AOCC Compiler - HECC Knowledge Base (2024)

The AMD Optimizing C/C++ and Fortran Compiler (AOCC) is highly optimized for x86 targets, especially for AMD Zen architecture-based processors.

AOCC leverages LLVM, a project that includes a collection of modular and reusable compiler and toolchain technologies. With LLVM, converting a source code to a machine code (object code) for a specific processor involves three phases:

Frontend phase
In this phase, the frontend parses, validates, and diagnoses errors in the source code, and converts the parsed code into the LLVM language-independent intermediate representation (LLVM IR)
One option that can be used as a C/C++ language compiler frontend is Clang, which is a project under the LLVM umbrella. Similarly, Flang is a Fortran language frontend integrated with LLVM.
Optimizer phase
The IR is transformed into an optimized IR by going through a series of optimization passes (e.g., inlining, unrolling, dead code elimination, and so on.)
Backend phase
The optimized IR is transformed into a target-specific machine code.

AOCC is a proprietary fork of LLVM+Clang, with changes to improve performance for processors based on the AMD Zen microarchitectures. For example, AOCC version 4.2 is based on LLVM version 16.0.3.

AOCC 4.2 supports the following standards:

  • C: C17 (default), C11, C99.
  • C++: C++20, C++17 (default), C++14, C++11, C++98.
  • Fortran: Fortran-95, Fortran-2003, partial support of Fortran-2008.
  • OpenMP:
    • For C and C++: OpenMP 5.0 and earlier standards.
    • For Fortran: OpenMP 4.5.

AOCC Usage

Multiple versions of AOCC are installed on NAS systems. We recommend using the latest version.

Load an AOCC Modulefile

After one of the modules is loaded, the environment variables PATH, LIBRARY_PATH, LD_LIBRARY_PATH, C_INCLUDE_PATH, and CPLUS_INCLUDE_PATH are modified.

You can load an AOCC modulefile as follows:

% module use -a /nasa/modulefiles/testing% module avail comp-aocc--- /nasa/modulefiles/toss4 ---comp-aocc/3.2.0--- /nasa/modulefiles/testing ---comp-aocc/4.0.0 comp-aocc/4.1.0 comp-aocc/4.2.0% module load comp-aocc/4.2.0

Compile and Link using the Clang, Clang++, or Flang Compiler Driver

Use one of the following command lines:

clang [command-line options] program.cclang++ [command-line options] program.cppflang [command-line options] program.f90

A few command-line options are provided here:

  • -O3: provides more optimization then the -O3 in the base LLVM version.
    Note: -O2 is the default in AOCC 4.2.
  • -Ofast: -O3 plus other aggressive optimizations that may violate strict compliance with language standards.
    Note: -Ofast in AOCC has more optimization than -Ofast in the base LLVM version.
  • -march=znver3: generates instructions that target AMD Zen 3 processor (such as Milan).
  • -ffast-math: enables faster but less-precise math operations.
  • -ffp-model={precise,fast}: is only applicable to Flang; "precise" disables optimizations that are not value-safe on floating-point data.
  • -fopenmp: parses OpenMP programs/directives and generates parallel code.
  • -flto: provides whole program analysis with Link Time Optimization (LTO).
  • -fuse-ld=lld: uses the LLD linker (default).
  • -fgen-aor: generates compiler-time AOCC optimization report (AOR); for link-time AOR generation, add -flto -fuse-ld=lld.
    Note: The generation of AOR requires python3. With AOCC 4.2, the script run_opt-viewerthat is used to generate the report requires python3.8.

You can find a list of command-line options on the Clang help page (clang --help) or in Chapter 5: Command-line Options in the AMD AOCC User Guide. Additional options can be found in Compiler Options Quick Reference Guide for Zen 3 and Zen 4 processors.

Link to an AMD AOCL Library

Some applications might perform better on the AMD Zen processors when they use AOCL, rather than using other scientific and math libraries from other sources. For more information, see AMD Optimizing CPU Libraries (AOCL).

Link to an MPI Library

HPE MPT

HPE MPT provides the wrapper scripts mpicc, mpicxx, and mpif90for compiling and linkingMPI applications. Each of the scripts detects which compilers are available in your environment, and uses the first one it finds when checking against a list of compilers included in the script.

With the module mpi-hpe/mpt.2.2825Apr23_rhe187, the list of precedence for the mpif90 script is {ifort openf90 pgf90 pgf95 lf95 gfortran}. For mpicc and mpicxx scripts, the only choice in the list is gcc and g++.

In order to use an AOCC compiler with these wrapper scripts, you must set some environment variables, as shown below. You can use the option -show of these wrapper scripts to find out which compiler is chosen.

% module use -a /nasa/modulefiles/testing% module load comp-aocc/4.2.0% module load mpi-hpe/mpt
  • C code
    % export MPICC_CC=clang% mpicc -showclang -I/nasa/hpe/mpt/..../include -lpthreads -L/nasa/hpe/mpt/... -lmpi% mpicc [options] program.c
  • C++ code
    % export MPICXX_CXX=clang++% mpicxx -showclang++ -I/nasa/hpe/mpt/..../include -lpthreads -L/nasa/hpe/mpt/... -lmpi% mpicxx [options] program.cc
  • Fortran code
    % export MPIF90_F90=flang% mpif90 -showflang -I/nasa/hpe/mpt/..../include -lpthreads -L/nasa/hpe/mpt/... -lmpi% mpif90 [options] program.f

OpenMPI

OpenMPI provides the wrapper compilers mpicc, mpic++ (or mpicxx, mpiCC), and mpifort for compiling and linking MPI applications. The legacy wrappers mpif77 and mpif90 still exist, but are symbolic links to mpifort. The compilers used by these wrappers default to the compilers used to build the OpenMPI library. After loading an OpenMPI module, you can run one of these commands to find the compilers used: ompi_info, mpicc --showme, mpic++ --showme, or mpifort --showme.

When building your application with an AOCC compiler and an OpenMPI library, the OpenMPI library that you use should be one that is also built with the AOCC compiler. This is especially true if your application is written in Fortran.

For applications written in C, you may be able to compile with an AOCC compiler and link with an OpenMPI library built with a different compiler, as shown below:

% module use -a /nasa/modulefiles/testing% module load comp-aocc/4.2.0% module load openmpi/4.1.6-toss4-gnu% export OMPI_CC=clang% mpicc --showmeclang -I/nasa/openmpi/4.1.6-gnu/include -pthread -L/nasa/openmpi/4.1.6-gnu/lib -Wl, -rpath -Wl,/nasa/openmpi/4.1.6-gnu/lib -Wl,--enable-new-dtags -lmpi% mpicc [options] program.c

References

AMD AOCC Compiler - HECC Knowledge Base (2024)
Top Articles
Yard Sale Treasures: Uncover Hidden Gems with Craigslist for Yard Sales - First Republic Craigslist
Motorcycles for Sale on Craigslist: The Ultimate Guide - First Republic Craigslist
Layla Deline Leaks
Bbwcumdreams
Craigslist Rooms For Rent Oxnard
When His Eyes Opened 3001
Seething Storm
Walmart Careers Stocker
Learnnow Pizza Hut
Rumsey Yost Funeral Home Obituaries
truckoo | Gebrauchte LKW mit einem Klick kaufen | Truckoo
Morse Road Bmv Hours
How to Read XML Files into Python
Living Room Furniture | Gavigan's Home Furnishings
Fast X Showtimes Near Regal Spartan
Magellan Outdoors Men's Luther Ii Boots
7 Movierulz
Rachel Griffin | Singer Songwriter from New York, NY
The Autopsy Report: Overview, Suggested Autopsy Report Headings, An Overview of the Autopsy Report
Crooked Wand Of Fireballs Bg3
Madness Combat Wiki
George Hamilton Deck Commercial
Wjga District 2
Behind the Idea: OpenPayd | The Fintech Times
Scammer phone number lookup. How to check if a phone number is a scam
Dynasty League Forum
In The Heights Gomovies
Spirit Airlines Flightaware
Barber Gym Quantico Hours
Walmart Tire Center York Pa
Matthew 14 Nasb
Mytowerlearninghub
Ogeechee Tech Blackboard
Rhode Island Weather by Month – Btobers.com
Contact & Support – BOC UK Official Shop
Petsmart Donations Request
Kamado Joe 457 Manual
Wicked Local Plymouth Police Log 2022
Updated contract info for new secondary coach John Butler, rest of NU staff
Gasmonkeygarage.com Cars For Sale
Der frühere Jenaer Prorektor Otto Stamfort im Porträt
My995Fm/Contests
The Culhanes Of Cornfield County
Megan Olivia Hall Facebook
Cvs Minuteclinic Locations Near Me
Sewing Alterations Near Me
Truck SAE Codes Such as J1939, J1708, SPN, FMI, & MID Explained
Select Truck Greensboro
Ctip General Awareness Quiz Answers 2022
Ruthless Rs3
Perani's Columbus Ohio
Latest Posts
Article information

Author: Reed Wilderman

Last Updated:

Views: 5289

Rating: 4.1 / 5 (72 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Reed Wilderman

Birthday: 1992-06-14

Address: 998 Estell Village, Lake Oscarberg, SD 48713-6877

Phone: +21813267449721

Job: Technology Engineer

Hobby: Swimming, Do it yourself, Beekeeping, Lapidary, Cosplaying, Hiking, Graffiti

Introduction: My name is Reed Wilderman, I am a faithful, bright, lucky, adventurous, lively, rich, vast person who loves writing and wants to share my knowledge and understanding with you.