3.3. LLVM

It shows how to use C and C++ compilers based on LLVM. The compiler is available on the login node (Intel) and compute node.

3.3.1. Environment setting

These compilers are in /vol0004/apps/oss/llvm-v19.1.4

(v19.1.0 has been deprecated due to a minor bug. Please use v19.1.4.)

Execute the followin gcommand to setup the environment before runnig compliers.

login node

[_LNIlogin]$ . /vol0004/apps/oss/llvm-v19.1.4/init.sh

compute node

[_CNlogin]$ . /vol0004/apps/oss/llvm-v19.1.4/init.sh

Available compilers are following

Software

Language

Version

Command

Clang

C

19.1.4

clang

Clang++

C++

19.1.4

clang++

Flang

Fortran

19.1.4

flang

3.3.2. How to Use

Here is an example of how to compile C. The commands are common for both nodes.

[Sequential execution]

Login node

[_LNIlogin]$ clang -O3 source_file

Compute node

[_CNlogin]$ clang -O3 source_file

[OpenMP]

You can use Fujitsu OpenMP libarary. Please add ‘-Kopenmp’ option.

Login node

[_LNIlogin]$ clang -O3 -Kopenmp source_file

Compute node

[_CNlogin]$ clang -O3 -Kopenmp source_file

[Fujistu MPI]

You can use Fujitsu MPI libraries by mpiclang/mpiclang++ commands on login node.

Login node

[_LNIlogin]$ mpiclang -O3 -Kopenmp source_file

Compute node

[_CNlogin]$ mpiclang -O3 -Kopenmp source_file

See also

In the case of C++, please just command to clang++/mpiclang++.

3.3.3. How to execute

The compiled binary can be executed either from an interactive job or from a script. Here is an example of script.

[Sequential execution]

#!/bin/sh -x
#PJM -L  "node=1"
#PJM -L  "rscgrp=small"
#PJM -L  "elapse=01:00:00"
#PJM -x PJM_LLIO_GFSCACHE=/vol0004
#PJM -g groupname
#PJM -s
#

. /vol0004/apps/oss/llvm-v19.1.4/init.sh
./a.out

[OpenMP]

#!/bin/sh -x
#PJM -L  "node=1"
#PJM -L  "rscgrp=small"
#PJM -L  "elapse=01:00:00"
#PJM -x PJM_LLIO_GFSCACHE=/vol0004
#PJM -g groupname
#PJM -s
#

export OMP_NUM_THREADS=12
. /vol0004/apps/oss/llvm-v19.1.4/init.sh
./a.out

[Fujistu MPI]

#!/bin/sh -x
#PJM -L  "node=1"
#PJM -L  "rscgrp=small"
#PJM -L  "elapse=01:00:00"
#PJM --mpi  "proc=4"
#PJM -x PJM_LLIO_GFSCACHE=/vol0004
#PJM -g groupname
#PJM -s
#

export OMP_NUM_THREADS=12
. /vol0004/apps/oss/llvm-v19.1.4/init.sh
mpiexec ./a.out

See also

Binaries compiled clang++ can be executed in the same way.