- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -

Difference between revisions of "SX ACE Porting"

From HLRS Platforms
Jump to navigationJump to search
Line 18: Line 18:
: compiler for C++ (ISO standard compliant, mostly C++14)
: compiler for C++ (ISO standard compliant, mostly C++14)
: wrappers for MPI compilation, they link the MPI libraries without extra options (and do it right)
: wrappers for MPI compilation, they link the MPI libraries without extra options (and do it right)

Revision as of 15:02, 1 September 2017

general approach

Compilation is done using crosscompilers on frontend kabuki.

simple case: you have a makefile

insert name of proper cross-compilation tools into your makefile. The crosstools habe the prefix sx.

Namely there is:

compiler for Fortran90/Fortran95 with some Fortran2003 features (-f2003)
compiler for Fortran2003 with some Fortran2008 features
compiler for C89 and C99 (use sxcc -Kc99 for C99)
compiler for C++ (ISO standard compliant, mostly C++14)
wrappers for MPI compilation, they link the MPI libraries without extra options (and do it right)
make command as on SX, can deal with dependencies referencing objects within libraries
tool to create SX libraries (that one is often forgotten when editing makefiles!)
tool to display symbol names of SX objects
tool to display sizes of objects
preprocessor if called explicit
tool to strip symbold from objects
tool to format ftrace performance traces
tool to format profiling information generated with -p

As frontend has multiple cores, parallel compilation using

make -j 4


sxmake -P

can be used.

tips and traps

This is a collection of pitfalls people use to get trapped when porting to SX.

  • Code dumps core after C malloc() is used. Make sure you include stdlib.h when using malloc(), otherwise, return value is assumed to be int (C standard), and the SX calling convention strips significant bits from the address. Make sure outcome of malloc() is never assigned to int, SX is LP64, not ILP64, a pointer does not fit into an int.
  • size_t is 32bit by default for historical reasons while sizeof(void *) is 64bit. So, only 2GB of memory can be allocated with malloc(). Use -size_t64 for C, C++ or Fortran compilers to get rid of that restriction.
  • My C code seems to have a problem with integer divisions. SX uses 56bit precision division for 64bit integer types per default. Use -xint switch to get full 64bit division (and loose some performance).
  • Code stops with Loop count is greater than that assumed by the compiler: loop-count=n Compiler has sometimes to make a guess about loop length, to be able to allocate some work vectors (only for partially vectorized loops). This educated guess might be wrong. Help the compiler by giving -W,-pvctl,noassume,loopcnt=n where n is the maximum loop count, or a larger value, or use -W,pvctl=vwork=stack to allocate this work vectors on stack at runtime.
  • How are Fortran function names in the calling convention? Simply write them lowercase and append an underscore. Example:
     		CALL CFUNC(5)
     		void cfunc_(int *a) {
  • What about parameters? Fortran is passing by reference, so use pointers in C for scalars. Character strings lead to an additional parameter of type long at the end of the parameter list, containing the length of the string. See C compilers manual chapter 4 for details.
  • How to link when C and Fortran are mixed? Link with f90. He makes it right. When using C++ or using C++/SX as C compiler, use C++/SX as linker, using the option -f90lib.
  • for modern C++ code (like Boost) this might work
sxc++ -Krtti -Kusing_std -Kcpp11