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

Porting to SX-9

From HLRS Platforms
Revision as of 10:04, 28 November 2008 by Hwwnec5 (talk | contribs)

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 conventions 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.
  • Only 2GB of memory can be allocated with malloc(). For historical reasons, size_t is 32bit, as well as sizeof(*void) is 64bit. Use -size_t64 for 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:
     		PROGRAM TEST
     		CALL CFUNC(5)
     		END
     		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.