- Infos im HLRS Wiki sind nicht rechtsverbindlich und ohne Gewähr -
- Information contained in the HLRS Wiki is not legally binding and HLRS is not responsible for any damages that might result from its use -

SX and configure

From HLRS Platforms
Revision as of 11:41, 25 February 2010 by Hpcaschu (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

Many software packages are developped for maximum portability with the so-called autotools package, consisting of:

All of these are GNU packages and are based on M4 macros and Shell code. There is a variety of already existing checks and macros available, e.g. for checking datatype-sizes and endian-ness, compiler-variations, Fortran naming conventions and so on.

As libtool and automake are optional and within this FAQ not really of importance to change, we will look only into autoconf


Cross-compilation using Autoconf for SX8 on the A1

The fastest way to handle cross-compilation is to configure & compile on the Asama frontend machine:

./configure --host=sx8-nec-superux --with-mpi-dir=/SX/usr CC=sxcc CCAS=sxas CCASFLAGS='-m -F' CXX=sxc++ MPICC=sxmpicc MPIF77=sxmpif77 F77=sxf90 F90=sxf90 FC=sxf90 AR=sxar LD=sxld RANLIB=echo, however, certain tests that require running the (cross-)compiled binaries fail. Therefore the suggested way is to run configure on a node of the SX8.

Cross-compilation with Autoconf on the SX8

In order to compile the software package with the cross-compiler on the frontend machine A1, one needs to obtain the hardware/software features of the SX8. To do so, one must possibly run automake, autoconf and libtool on the source code, possibly with the newest versions of the packages installed. By doing so automake generates the Makefile.in out of the Makefile.am files; autoconf generates the configure-file out of the existing macro-files included (.m4-files and .in/.ac-files).

Then, run the generated ./configure script on the interactive node of the NEC SX8. This produces output with the findings on the system.

To detect the system-type, configure uses the scripts in the file config.guess. This file may not yet contain the description of the NEC SX8 and the SuperUX OS, therefore just add to config.guess:

   SX-8:SUPER-UX:*:*)
       echo sx8-nec-superux${UNAME_RELEASE}
       exit 0 ;;

And to the recognition of the basic machine in config.sub:

      SX-NEC)
              basic_machine=sx-nec
              ;;

As an alternative, the CVS-version on the GNU-Savannah server contains the newest config.guess and config.sub, which contains the correct definitions for NEC-SX4 up to NEC-SX8R.

Then run the configure-script on the interactive node of the SX. If there are any errors of the configure-run, one may need to look into the shell-scripts. One should be able to verify the output produced, e.g. compiling a tracing-library which needs the system-wide MPI-library:

 hpc@v00:mpitrace/COMPILE-SX8> ../configure --with-mpi-dir=/usr/
 checking build system type... sx8-nec-superux15.1
 checking host system type... sx8-nec-superux15.1
 checking for gcc... no
 checking for cc... cc
 checking for C compiler default output file name... a.out
 checking whether the C compiler works... yes
 checking whether we are cross compiling... no
 checking for suffix of executables...
 checking for suffix of object files... o
 checking whether we are using the GNU C compiler... no
 checking whether cc accepts -g... yes
 checking for cc option to accept ANSI C... none needed

In this case we see, that the standard macro to detect the fortran compiler works,

 checking for f90... f90
 checking whether we are using the GNU Fortran 77 compiler... no
 checking whether f90 accepts -g... yes
 checking how to get verbose linking output from f90... -verbose
 checking for Fortran libraries of f90...  -lg -lu90sxe -lp90sx -lk90sxe -lm90sxe -lmxv90 -lv90sxe -lf90sxe -li90sxe -lcpp -lm -lz90sx
 Adding libi90sx.a to FLIBS
 checking for Fortran naming convention... HAVE_FORTRAN_UNDERSCORE
 checking for system-specific LDFLAGS for MPI... -li90sxe
 checking for the MPI directory... /usr/


however, we manually need to set the fortran libraries required for correct linking inside the configure.in-script:

 dnl On Nec SX5, above doesn't work out, therefore, we have to add this manually
 dnl in order to link C and Fortran object files with a C compiler.
 case "$host" in
   sx*-nec-*)
     FLIBS="$FLIBS -li90sx"
     AC_MSG_RESULT([Adding libi90sx.a to FLIBS])
     ;;
   *)
     ;;
 esac

and the libraries for MPI-compilation:

 dnl Add system-specific LDFLAGS.
 AC_MSG_CHECKING([for system-specific LDFLAGS for MPI])
 dnl SYS_LDFLAGS=""
 case "$host" in
   sx*-nec-*)
     SYS_LDFLAGS="-li90sxe"
     AC_DEFINE(USE_SX, 1, [Defined if the SX-counters should be read in])
     ;;
   *)
     ;;
 esac

To make the shift (configure on SX and make with the cross-compilation) as easy as possible, the /SX directory used on A1 has been setup as link on the interactive node v00 of the SX.

After a successful run, one may run the actual cross-compilation on the A1. One has to make sure, that the corresponding variables inside all Makefiles are correct, i.e. CC=sxcc, CXX=sxc++, F90=sxf90 and AR=sxar. If other directories to the system-libraries and headers have to be replaced in the cross-environment, this has to be done in the corresponding Makefiles.

In simple cases, this may be done using the flags directly on the make-command line: make CC=sxcc CCAS=sxas CCASFLAGS='-m -F' CXX=sxc++ F90=sxf90 AR=sxar LD=sxld. In more complex cases, You will need to edit libtool in order to replace /usr/bin/ld by sxld and adapt for using sxar.

Tipps and Tricks

One may need to play with environment variables to get the correct version of a programm, e.g. to get bison instead of yacc.

A software packages showing the difficulties is Paraver's mpitrace; A software showing the niceties of configure is VampirTrace (which was adapted heavily to accomodate the NEC-SX:

For cross-compilation on the a1:

 script -c "
   ../configure --host=sx8-nec-superux --prefix=/app/sx/tools/vampir/ \
                --with-mpi-dir=/SX/usr --with-zlib-dir=/SX/usr/local/ --with-mpisx \
                --with-mpi-status-size=6 \
                --with-wrapper-cc=mpicc \
                --with-wrapper-cxx=mpicxx \
                --with-wrapper-f77=mpif90 \
                --with-wrapper-fc=mpif90 \
      MPICC=sxmpicc CC=sxcc CFLAGS='-O -Kc99 -g' CCAS=sxas CCASFLAGS='-m -F' CXX=sxc++  \
      F77=sxf90 F90=sxf90 FC=sxf90 \
      AR=sxar LD=sxld STRIP=sxstrip RANLIB=echo" \
    -f output_configure_cross.txt
 
  script -c "make" -f output_make.txt

The various --with-wrapper-* flags allow the various vtcc-compilers to execute natively on the SX; for cross-compilation shell-scripts called sxvtcc have to be created (using the cross-compiler sxcc and using the flags returned by the (native) vtcc -vt:showme