Skip to main content

Compilers

Compilers are tools that allow you to create executable binaries from source code.

Available Compilers

Palmetto offers the following compiler suites for C, C++ and Fortran applications:

  1. GNU Compiler Collection (gcc)
  2. Intel oneAPI DPC++/C++ Compiler (intel-onapi-compilers)
  3. AMD Optimizing C/C++ and Fortran Compiler (AOCC)
  4. NVIDIA HPC SDK (nvhpc)
module avail gcc
module avail intel-oneapi-compilers
module avail aocc
module avail nvhpc

Compiling "Hello World" Program

C

Simple hello.c file that reads

#include <stdio.h>

int main(void){
printf("Hello, world!\n");
return 0;
}

can be compiled on Palmetto using the following commands

CompilerModuleCommand
GCCgcc/12.3.0gcc hello.c -o hello.x
Intelintel-oneapi-compilers/2024.0.2icx hello.c -o hello.x
AOCCaocc/4.1.0clang hello.c -o hello.x
NVHPCnvhpc/23.11nvcc hello.c -o hello.x

C++

The same example in C++ put in a file hello.cpp

#include <iostream>

int main()
{
std::cout << "Hello, world!" << std::endl;
return 0;
}

can be compiled on Palmetto using the following commands

CompilerModuleCommand
GCCgcc/12.3.0g++ hello.cpp -o hello.x
Intelintel-oneapi-compilers/2024.0.2icpx hello.cpp -o hello.x
AOCCaocc/4.1.0clang++ hello.cpp -o hello.x
NVHPCnvhpc/23.11nvc++ hello.cpp -o hello.x

FORTRAN

To compile a simple FORTRAN program test.f90

program test
print *,'hello from fortran'
end program test

use a command appropriate for a given compiler suite

CompilerModuleCommand
GCCgcc/12.3.0gfortran test.f90 -o hello.x
Intelintel-oneapi-compilers/2024.0.2ifx test.f90 -o hello.x
AOCCaocc/4.1.0flang test.f90 -o hello.x
NVHPCnvhpc/23.11nvfortran test.f90 -o hello.x