NERSC logo National Energy Research Scientific Computing Center
  A DOE Office of Science User Facility
  at Lawrence Berkeley National Laboratory
 

Programming on DaVinci

Compilers

There are two families of compilers available on DaVinci. As with most Linux-based systems, the GNU compilers gcc, g++, and g77 are present in the default path for all users. For more information on the GNU compilers, see the man pages for the specific compiler.

In addition to the GNU compilers, NERSC has chosen to make available the Intel compilers ifort, icc, and icpc. These compilers can be accessed by first issuing the following command:

$ module load intel

The ifort, icc, and icpc man pages (available after loading the above module) describe the Intel Fortran and C/C++ compilers. Please note the following distinction between icc and icpc, adapted from the man pages:

The icpc command uses the same compiler options as the icc command. Invoking the compiler using icpc builds C++ source files using C++ libraries and include files. Using icpc with a C source file causes it to be compiled as a C++ file. Use icpc to link C++ object files. Invoking the compiler using icc builds C source files using C libraries and include files. Using icc with a C++ source file still causes it to be compiled as a C++ file. Use icc to link C object files.

In addition to the man pages, complete Intel compiler documentation is available on the NERSC website:

For users porting applications from SGI IRIX machines (for example, the previous NERSC visualization server Escher), SGI has produced a useful guide.

Little endian to big endian conversion

DaVinci is "little endian", and this will affect ability to read binary data transferred from "big endian" machines like Escher.The Intel Fortran Compiler can write unformatted sequential files in big-endian format and also can read files produced in big-endian format by setting at run time the endian F_UFMTENDIAN environment variable. The variable has the following syntax:

setenv F_UFMTENDIAN "type[:unit];type[:unit]" (csh)
export F_UFMTENDIAN="type[:unit];type[:unit]" (ksh or bash)

where type is big for big to little endian conversion, and little to specify data in little endian format (i.e. no conversion). Default is little. For information on Endian Order and an example see: Porting IRIX Applications to SGI Altix Guide. For a detailed description of the endian environment variable, please refer to the Little-endian-to-Big-endian Conversion.

Note that this environment variable is only functional on DaVinci and using the Intel Fortran compiler ifort. It does NOT work for the GNU g77 compiler.

For C and C++ use byteswap functions. Here is an example for such a function that byte-swaps an array of n elements of data type with size nb:

void swap_bytes(void *a, int n, int nb) { 
  char tmp[16]; 
  char* b=(char*)a; 
  int i,j; 
  char* cd=tmp; 
  char* cs; 
		
  for (i=0;i<n;i++) {
    cs=&b[nb*i];
    for (j=0;j<nb;j++) 
      cd[j]=cs[nb-1-j];
    bcopy(cd,cs,nb); 
  } 
}

For example, when this function is called like this:

swap_bytes( array_of_floats,23, sizeof(float));

it converts an array containing 23 floats.

Parallel Programming

To link MPI codes, please include in your link line.

  • For Fortran and C
      -lmpi
  • For C++
      -lmpi++ -lmpi

Debugging

To use the Intel debugger IDB please load the intel module.

Programming Libraries

MKL provides a highly optimized library of BLAS, LAPACK and FFT routines, MKL can be used with both the Intel and GNU compilers.

To use the Intel MKL library please load the mkl module. To use the MKL library with the Intel or GNU compilers, include $MKL flag for both compile and link options E.g.

$ module load mkl
$ ifort ... $MKL
$ icc ... $MKL
$ g77 ... $MKL
$ gcc ... $MKL


LBNL Home
Page last modified: Thu, 23 Mar 2006 21:25:08 GMT
Page URL: http://www.nersc.gov/nusers/systems/davinci/programming.php
Web contact: webmaster@nersc.gov
Computing questions: consult@nersc.gov

Privacy and Security Notice
DOE Office of Science