Skip to content

Usage

The project's Clang compiler can be used to compile OpenMP code with offloading to SX-Aurora VE cards using aurora-nec-veort-unknown as target triple for offloading.

For example:

clang -fopenmp -fopenmp-targets=aurora-nec-veort-unknown input.c

Will apply source transformation for target regions and declare target functions in input.c and compile an offloading binary for the VE architecture from it using the target compiler (by default this is Clang). Clang embeds this binary into the host executable as it would any other offloading binary.

The host executable generated by Clang can then be executed and will try to use the libomptarget plugin for SX-Aurora VE to offload target regions onto the VE cards. The VE card used for the execution can be controlled by the OMP_DEFAULT_DEVICE environment variable during runtime, or with OpenMP's device clause in the program.

Selecting a Target Compiler

When using the project's Clang compiler to compile OpenMP code with offloading, you can choose which compiler will be used for the target code with the compiler flag --fopenmp-nec-compiler=. This flag supports compilers configured as presets at build time, and compilers set at run time by full path.

  • --fopenmp-nec-compiler=clang (default) will use the preset for Clang with the LLVM back-end for VE. The path to the Clang compiler for this preset can be configured with CMake at build time and defaults to the installation path of the clang compiler built with this project.
  • --fopenmp-nec-compiler=rvclang will use the preset for Clang with region vectorizer (rvclang) and an LLVM back-end for VE. The path to the compiler for this preset can be configured with CMake at build time and defaults to the installation path of the rvclang compiler built with this project.
  • --fopenmp-nec-compiler=ncc will use the ncc compiler. The path to the ncc compiler can be configured with CMake at build time and defaults to the standard ncc install location.
  • A target compiler can also be set with a full path using the syntax --fopenmp-nec-compiler=path:$PATH_TO_COMPILER. If this is a Clang compiler you may also need to manually pass the compiler target to it, for example with -Xopenmp-target "--target=ve-linux". This is NOT necessary when using one of the compiler presets above.

The path for the compiler presets can be configured with CMake at build time of the project with the NECAURORA_TARGET_COMPILER_* CMake flags. The default preset can be configured with CMake at build time with the CMake flag NECAURORA_DEFAULT_TARGET_OPTION which defaults to ncc.

See the section CMake Options in Installation.

Passing Arguments to the Target Compiler

Not all arguments from the host compilation are automatically converted or passed on to the target compiler (although some are). To explicitly pass an argument to the wrapper and target compiler, Clang offers the argument -Xopenmp-target.

For example, to pass the argument -fno-fast-math to the target compiler, use the command line:

clang -fopenmp -fopenmp-targets=aurora-nec-veort-unknown -Xopenmp-target "-fno-fast-math" input.c -o program

Any option passed via -Xopenmp-target is not used for parsing and source transformation.

Static Linking

To link your target image statically, pass the option -Xlinker -fopenmp-static to the wrapper/target compiler via -Xopenmp-target, For example:

clang -fopenmp -fopenmp-targets=aurora-nec-veort-unknown -Xopenmp-target "-Xlinker -fopenmp-static" input.c -o program

Danger

Static linking is currently experimental, and the wrapper tool will not forward arguments to the linker from Clang.

Warning

Due to limitations with the VEO/AVEO API, target regions which are nested in a parallel region are not executed in parallel but one after the other (with the order being determined by which thread in the parallel region calls libomptarget first, and thus non-deterministic).


Last update: 2021-11-24
Back to top