Skip to content

AOCC on MeluXina

The MeluXina system environment provides the AOCC compiler. AOCC is the "AMD Optimizing C/C++ and Fortran Compilers" suite.

EasyBuild module description

  AMD Optimized C/C++ & Fortran compilers (AOCC) based on LLVM 12.0.

You can use AOCC to compile your C/C++ programs.

AOCC usage

Interactive

Reserve an interactive session:

salloc -A COMPUTE_ACCOUNT -t 01:00:00 -q dev --res cpudev -p cpu -N 1

The example above will allocate one CPU node in interactive mode (dev QoS with cpudev reservation). Load the AOCC (Will load default version if not specified) module as in below script.

module load AOCC
clang hello.c -o ./HelloTest_C

Batch

AOCC can also be used in a batch job using Slurm. The script below compile a simple C HelloWorld test on one CPU node allocated for 5 minutes.

#!/bin/bash -l
#SBATCH -N 1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH -p cpu
#SBATCH -q test
#SBATCH --time 00:05:00

#Load AOCC module
module load AOCC

#Check AOCC version
clang --version

#Compile C program with AOCC
clang hello.c -o ./hello_c

#Execute the program
hello_c

It is recommended to use a Makefile to compile your program. Your Makefile should look like the example below:

#Defines compiler
CC=clang

# These are the options we pass to the compiler.
# -std=c++1y means we want to use the C++14 standard (called 1y in this version of AOCC).
# -stdlib=libc++ specifies that we want to use the standard library implementation called libc++
# -c specifies making an object file, as you saw before
# -g specifies that we want to include "debugging symbols" which allows us to use a debugging program.
# -O0 specifies to do no optimizations on our code.
# -Wall, -Wextra, and -pedantic tells the compiler to look out for common problems with our code. -Werror makes it so that these warnings stop compilation.
CFLAGS = -std=c++1y -stdlib=libc++ -c -g -O0 -Wall -Wextra -Werror -pedantic

all: hello

hello: hello.o
        $CC $CFLAGS -o hello_c hello.o

hello.o: hello.cpp
          $CC $CFLAGS -c hello.c

It is also possible to compile via a Makefile inside a batch job:

#!/bin/bash -l
#SBATCH -N 1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=128
#SBATCH -p cpu
#SBATCH -q test
#SBATCH --time 00:05:00

#Load AOCC module
module load AOCC

#Check AOCC version
clang --version

#Compile C program with AOCC (in parallel)
make -j

#Execute the program
hello_c