[ English | Japanese ]

Compiling and Linking (For C)

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 C/C++ compiler (ncc/nc++) 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 functions is "32-bit integer". For the 64-bit integer library, the type of the integer arguments in functions is "64-bit integer".
  • 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".

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 ncc when using the sequential or OpenMP parallel libraries, and is mpincc 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
CBLAS Sequential (none)
OpenMP 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 (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
CBLAS Sequential (none)
OpenMP parallel -fopenmp
SBLAS Sequential (none)
OpenMP parallel -fopenmp
HeteroSolver OpenMP parallel -fopenmp
Hybrid Parallel (not available)
Stencil Code Accelerator Sequential (none)
OpenMP parallel -fopenmp

Linking

The command for linking is ncc when using the sequential or OpenMP parallel libraries, and is mpincc 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.


Table 4: Linking 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
CBLAS Sequential -lcblas -lblas_sequential
OpenMP parallel -lcblas -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 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 -lasl_mpi_sequential_i64c
Hybrid Parallel -lasl_mpi_openmp_i64c -fopenmp
FFTW3 Interface Sequential -laslfftw3_i64 -lasl_sequential_i64
OpenMP parallel -laslfftw3_i64 -lasl_openmp_i64 -fopenmp
MPI Parallel -laslfftw3_mpi_i64c -lasl_mpi_sequential_i64c
Hybrid Parallel -laslfftw3_mpi_i64c -lasl_mpi_openmp_i64c -fopenmp
CBLAS Sequential -lcblas_i64 -lblas_sequential_i64
OpenMP parallel -lcblas_i64 -lblas_openmp_i64 -fopenmp
SBLAS Sequential -lsblas_sequential_i64
OpenMP parallel -lsblas_openmp_i64 -fopenmp
HeteroSolver OpenMP parallel -lheterosolver_openmp_i64 -lblas_sequential_i64
-fopenmp
Hybrid Parallel (not available)
Stencil Code Accelerator Sequential -lsca_sequential_i64
OpenMP parallel -lsca_openmp_i64 -fopenmp