[ English | Japanese ]

Compiling and Linking (For Fortran)

This page describes how to compile your program that uses NEC Numeric Library Collection for Vector Engine and how to link it with the library.

The required compiler options vary depending on:

  • the libraries you are to use,
  • the distributed memory parallelism,
  • the shared memory parallelism, and
  • the size of the default integer type.

Preparation

Before compiling and linking, you need to execute the compiling environment setup script nlcvars.sh or nlcvars.csh once in advance.

sh or its variant:

 $ source /opt/nec/ve/bin/nlcvars.sh  [Argument...] 

csh or its variant:

 % source /opt/nec/ve/bin/nlcvars.csh [Argument...] 

The arguments required to be specified are as shown in Table 1.

Table 1: The arguments required to be specified
for the compiling environment setup script
Distributed Memory parallelism Default Integer Type Arguments
none32bit(none)
none64biti64
MPI32bitmpi
MPI64bitmpi i64

Remarks
  • NEC Fortran compiler (nfort) Version 5.0.0 or later is necessary. Also, NEC MPI is necessary only when using distributed memory parallel functions. NEC MPI 3.0.0 or later is required in Mellanox OFED (MOFED) 5.x environment. NEC MPI 2.24.0 or later and less than 3.0.0 is required in MOFED 4.x environment.
  • For the 32-bit integer library, the type of the integer arguments in subroutines is "32-bit integer". For the 64-bit integer library, the type of the integer arguments in subroutines is "64-bit integer". If you use the automatic precision expansion function of the compiler, link the libraries that are compatible with the argument sizes after the (precision) expansion.
  • If you compile using the nfort or mpinfort with the -fdefault-real=8 option, a real or a complex declaration statement without specifying a kind type parameter is interpreted as real(kind=8) or complex(kind=8). In this case, please call the subroutine whose argument types of floating point data are real(kind=8) or complex(kind=8).
  • It is recommended to create an executable file with static linking by using the linking option -static, because defaulted dynamic linking tends to make performance worse.
  • To create a shared object that calls the library functions or routines, the linking option -static must not be specified. Otherwise, programs using the shared object will fail to run by dynamic library loading errors.
  • When you execute programs created with dynamic linking, the environment variable VE_LD_LIBRARY_PATH must be set properly in advance. The value is required to include the library path of NEC Numeric Library Collection.
  • The sequential version and the MPI parallel version of ASL are not thread-safe. Therefore, an OpenMP parallelized or hybrid parallelized program is required to use the OpenMP parallel version or the hybrid parallel version, respectively.
  • When you execute programs linked with HeteroSolver, the environment variable LD_LIBRARY_PATH also must be set before executing the programs. Please see "Remarks on Execution".
  • The musl libc version is deprecated.

Preparation with specifying the version of NEC Numeric Library Collection

NEC Numeric Library Collection 3.0.0 and later provides libraries and include files for VE30 and for VE20, VE10, or VE10E.

  • For VE30
     /opt/nec/ve3/nlc/X.X.X/{include/, lib/, bin/} 
  • For VE20, VE10, or VE10E
     /opt/nec/ve/nlc/X.X.X/{include/, lib/, bin/} 

If you want to specify the version of the NEC Numeric Library Collection, specify the version in the following manner before compiling and linking.

  • For VE30

    sh or its variant:

     $ source /opt/nec/ve3/nlc/X.X.X/bin/nlcvars.sh  [Argument...] 

    csh or its variant:

     % source /opt/nec/ve3/nlc/X.X.X/bin/nlcvars.csh [Argument...] 

    Here, X.X.X denotes the version number of NEC Numeric Library Collection. The arguments required to be specified are as shown in Table1.

  • For VE20, VE10, or VE10E

    sh or its variant:

     $ source /opt/nec/ve/nlc/X.X.X/bin/nlcvars.sh  [Argument...] 

    csh or its variant:

     % source /opt/nec/ve/nlc/X.X.X/bin/nlcvars.csh [Argument...] 

    Here, X.X.X denotes the version number of NEC Numeric Library Collection. The arguments required to be specified are as shown in Table1.


Compiling

The command for compiling is nfort when using the sequential or OpenMP parallel libraries, and is mpinfort when using the MPI parallel or hybrid parallel libraries. The compiling options described in Table 2 are required when using the 32-bit integer libraries. The compiling options described in Table 3 are required when using the 64-bit integer libraries.


Table 2: Compiling options to use the 32-bit integer libraries
Libraries Compiling Options
ASL Native Interface Sequential (none)
OpenMP parallel -fopenmp
ASL Unified Interface Sequential (none)
OpenMP parallel -fopenmp
MPI Parallel (none)
Hybrid Parallel -fopenmp
FFTW3 Interface Sequential (none)
OpenMP parallel -fopenmp
MPI Parallel (none)
Hybrid Parallel -fopenmp
BLAS Sequential (none)
OpenMP parallel -fopenmp
LAPACK Sequential (none)
OpenMP parallel -fopenmp
ScaLAPACK
BLACS
MPI Parallel (none)
Hybrid Parallel -fopenmp
SBLAS Sequential (none)
OpenMP parallel -fopenmp
HeteroSolver OpenMP parallel -fopenmp
Hybrid Parallel
Stencil Code Accelerator Sequential (none)
OpenMP parallel -fopenmp

Table 3: Compiling options to use the 64-bit integer libraries
Libraries Compiling Options
ASL Native Interface Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
ASL Unified Interface Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
MPI Parallel -fdefault-integer=8 -fdefault-real=8
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -fopenmp
FFTW3 Interface Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
MPI Parallel -fdefault-integer=8 -fdefault-real=8
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -fopenmp
BLAS Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
LAPACK Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
ScaLAPACK
BLACS
MPI Parallel -fdefault-integer=8 -fdefault-real=8
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -fopenmp
SBLAS Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp
HeteroSolver OpenMP parallel -fdefault-integer=8 -fopenmp
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -fopenmp
Stencil Code Accelerator Sequential -fdefault-integer=8
OpenMP parallel -fdefault-integer=8 -fopenmp

Linking

The command for linking is nfort when using the sequential or OpenMP parallel libraries, and is mpinfort when using the MPI parallel or hybrid parallel libraries. The linking options described in Table 4 are required when using the 32-bit integer libraries. The linking options described in Table 5 are required when using the 64-bit integer libraries. The linking option -static is required when creating executable files with static linking. No additional options are required when creating executable files with dynamic linking, but -shared-mpi must be specified only when using MPI. As for the musl libc version, only static linking is supported.


Table 4: Linking options to use the 32-bit integer libraries
Libraries Linking Options
ASL Native Interface Sequential -lasl_sequential
OpenMP parallel -lasl_openmp -fopenmp
ASL Unified Interface Sequential -lasl_sequential
OpenMP parallel -lasl_openmp -fopenmp
MPI Parallel -lasl_mpi_sequential
Hybrid Parallel -lasl_mpi_openmp -fopenmp
FFTW3 Interface Sequential -laslfftw3 -lasl_sequential
OpenMP parallel -laslfftw3 -lasl_openmp -fopenmp
MPI Parallel -laslfftw3_mpi -lasl_mpi_sequential
Hybrid Parallel -laslfftw3_mpi -lasl_mpi_openmp -fopenmp
BLAS Sequential -lblas_sequential
OpenMP parallel -lblas_openmp -fopenmp
LAPACK Sequential -llapack -lblas_sequential
OpenMP parallel -llapack -lblas_openmp -fopenmp
ScaLAPACK
BLACS
MPI Parallel -lscalapack -llapack -lblas_sequential
Hybrid Parallel -lscalapack -llapack -lblas_openmp -fopenmp
SBLAS Sequential -lsblas_sequential
OpenMP parallel -lsblas_openmp -fopenmp
HeteroSolver OpenMP parallel -lheterosolver_openmp -lblas_sequential -fopenmp
Hybrid Parallel -lheterosolver_mpi_openmp
-lblas_sequential -fopenmp
Stencil Code Accelerator Sequential -lsca_sequential
OpenMP parallel -lsca_openmp -fopenmp

Table 5: Linking options to use the 64-bit integer libraries
Libraries Linking Options
ASL Native Interface Sequential -lasl_sequential_i64
OpenMP parallel -lasl_openmp_i64 -fopenmp
ASL Unified Interface Sequential -lasl_sequential_i64
OpenMP parallel -lasl_openmp_i64 -fopenmp
MPI Parallel -fdefault-integer=8 -fdefault-real=8 -lasl_mpi_sequential_i64f
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -lasl_mpi_openmp_i64f -fopenmp
FFTW3 Interface Sequential -laslfftw3_i64 -lasl_sequential_i64
OpenMP parallel -laslfftw3_i64 -lasl_openmp_i64 -fopenmp
MPI Parallel -fdefault-integer=8 -fdefault-real=8 -laslfftw3_mpi_i64f -lasl_mpi_sequential_i64f
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -laslfftw3_mpi_i64f -lasl_mpi_openmp_i64f -fopenmp
BLAS Sequential -lblas_sequential_i64
OpenMP parallel -lblas_openmp_i64 -fopenmp
LAPACK Sequential -llapack_i64 -lblas_sequential_i64
OpenMP parallel -llapack_i64 -lblas_openmp_i64 -fopenmp
ScaLAPACK
BLACS
MPI Parallel -fdefault-integer=8 -fdefault-real=8 -lscalapack_i64f -llapack_i64
-lblas_sequential_i64
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -lscalapack_i64f -llapack_i64
-lblas_openmp_i64 -fopenmp
SBLAS Sequential -lsblas_sequential_i64 -fdefault-integer=8
OpenMP parallel -lsblas_openmp_i64 -fopenmp -fdefault-integer=8
HeteroSolver OpenMP parallel -lheterosolver_openmp_i64
-lblas_sequential_i64 -fopenmp
Hybrid Parallel -fdefault-integer=8 -fdefault-real=8 -lheterosolver_mpi_openmp_i64f -lblas_sequential_i64
-fopenmp
Stencil Code Accelerator Sequential -lsca_sequential_i64
OpenMP parallel -lsca_openmp_i64 -fopenmp