2

I'm using Intel compilers collection from Parallel Studio 2019 and trying to build MPICH-3.2 against it for the recent CPU. My configure scenario:

MPICHLIB_CFLAGS="-xCORE-AVX512" \
MPICHLIB_CXXFLAGS="-xCORE-AVX512" \
MPICHLIB_FCFLAGS="-xCORE-AVX512" \
MPICHLIB_FFLAGS="-xCORE-AVX512" \
LDFLAGS="-Wl,--disable-new-dtags" \
./configure \
CC="/opt/intel/bin/icc" \
CXX="/opt/intel/bin/icpc" \
FC="/opt/intel/bin/ifort" \
F77="/opt/intel/bin/ifort" \
--with-pic \
--enable-shared \
AR="ar" \ 
RANLIB="ranlib" \ 
--enable-f77 \
--enable-fc \
--enable-cxx \
--enable-fast=all,nompit \
--prefix=/usr \
--host=x86_64-pc-linux-gnu \
--with-cross=/root/fort.types

/root/fort.types contains:

CROSS_F77_SIZEOF_INTEGER=4
CROSS_F77_SIZEOF_REAL=4
CROSS_F77_SIZEOF_DOUBLE_PRECISION=8
CROSS_F77_TRUE_VALUE=1
CROSS_F77_FALSE_VALUE=0
CROSS_F90_ADDRESS_KIND=8
CROSS_F90_INTEGER_KIND=4

configure completes successfully but build fails with the following error:

CC       src/glue/romio/lib_libmpi_la-all_romio_symbols.lo
src/binding/fortran/use_mpi/create_f90_real.c(75): error: expected an expression
    { MPIR_F90_REAL_MODEL, MPI_REAL},
                         ^

src/binding/fortran/use_mpi/create_f90_real.c(76): error: expected an expression
    { MPIR_F90_DOUBLE_MODEL, MPI_DOUBLE_PRECISION } };
                           ^

compilation aborted for src/binding/fortran/use_mpi/create_f90_real.c (code 2)
make[2]: *** [src/binding/fortran/use_mpi/lib_libmpi_la-create_f90_real.lo] Error 1
make[2]: *** Waiting for unfinished jobs....
src/binding/fortran/use_mpi/create_f90_complex.c(76): error: expected an expression
    { MPIR_F90_REAL_MODEL, MPI_COMPLEX},
                         ^

src/binding/fortran/use_mpi/create_f90_complex.c(77): error: expected an expression
    { MPIR_F90_DOUBLE_MODEL, MPI_DOUBLE_COMPLEX } };
                           ^

compilation aborted for src/binding/fortran/use_mpi/create_f90_complex.c (code 2)
make[2]: *** [src/binding/fortran/use_mpi/lib_libmpi_la-create_f90_complex.lo] Error 1
make[2]: Leaving directory `/root/mpich-3.2'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/mpich-3.2'
make: *** [all] Error 2

I google about this and have founded that mpif90model.h isn't initialized and therefore macros MPIR_F90_* is undefined. There was mentioned in the above link:

More specifically, the binaries that are supposed to run and tell configure what it wants to know fail to link because configure tries to set rpath.

How can I done cross compile MPICH-3.2 against Intel compilers without disabling fortran libraries?

I compile MPICH-3.2 in Docker environment with SLES 11 SP4 as container OS.

Yurij Goncharuk
  • 159
  • 1
  • 11

2 Answers2

2

The problem has been solved by appending to /root/fort.types the following variables:

CROSS_F90_OFFSET_KIND=8
CROSS_F90_REAL_MODEL=6,37
CROSS_F90_DOUBLE_MODEL=15,307
CROSS_F90_INTEGER_MODEL=9
CROSS_F90_ALL_INTEGER_MODELS=2,1,4,2,9,4,18,8,
CROSS_F90_INTEGER_MODEL_MAP={2,1,1},{4,2,2},{9,4,4},{18,8,8},

It seems configure from MPICH-3.2 isn't ready jet to build cross compile version without little "magic". Official mailing list of MPICH project doesn't get any help to solve problem. I hope my discover helps to anybody.

Yurij Goncharuk
  • 159
  • 1
  • 11
1

To add on to Yurij Goncharuk's answer, here are some steps you can take to find the appropriate values for the CROSS_ variables by building and running some programs manually for whatever target platform you like. I don't think these steps are specific to Intel's compilers; you just need working C and Fortran (cross-)compilers and a working linker.

For reference, I performed these steps with clang and gfortran. The programs themselves were adapted from the configure script included with mpich-3.3.2.


CROSS_F90_OFFSET_KIND

You should build and run the following program:

      program main
      integer ii
      ii = selected_int_kind(16)
      open(8, file="conftest1.out", form="formatted")
      write (8,*) ii
      close(8)
      stop
      end

The output file, conftest1.out, gives the value to which you should set CROSS_F90_OFFSET_KIND. In my case, I got the following output:

           8

Thus, I set CROSS_F90_OFFSET_KIND=8.


CROSS_F90_REAL_MODEL

You should build and run the following program:

      program main
      real aa
      open(8, file="pac_fconftest.out", form="formatted")
      write(8,*) precision(aa), ",", range(aa)
      close(8)
      end

The output file, pac_fconftest.out, gives the value to which you should set CROSS_F90_REAL_MODEL. In my case, I got the following output:

           6 ,          37

Thus, I set CROSS_F90_REAL_MODEL=6,37.


CROSS_F90_DOUBLE_MODEL

You should build and run the following program:

      program main
      double precision aa
      open(8, file="pac_fconftest.out", form="formatted")
      write(8,*) precision(aa), ",", range(aa)
      close(8)
      end

The output file, pac_fconftest.out, gives the value to which you should set CROSS_F90_DOUBLE_MODEL. In my case, I got the following output:

          15 ,         307

Thus, I set CROSS_F90_DOUBLE_MODEL=15,307.


CROSS_F90_INTEGER_MODEL

You should build and run the following program:

      program main
      integer aa
      open(8, file="pac_fconftest.out", form="formatted")
      write(8,*) range(aa)
      close(8)
      end

The output file, pac_fconftest.out, gives the value to which you should set CROSS_F90_INTEGER_MODEL. In my case, I got the following output:

           9

Thus, I set CROSS_F90_INTEGER_MODEL=9


CROSS_F90_ALL_INTEGER_MODELS

You should build and run the following program:

      program main
      integer r, lastkind
      lastkind=selected_int_kind(1)
      open(8, file="pac_fconftest.out", form="formatted")
      do r=2,30
         k = selected_int_kind(r)
         if (k .ne. lastkind) then
            write(8,*) r-1, ",", lastkind
            lastkind = k
         endif
         if (k .le. 0) then
            exit
         endif
      enddo
      if (k.ne.lastkind) then
         write(8,*) 31, ",", k
      endif
      close(8)
      end

The output file, pac_fconftest.out, gives the value to which you should set CROSS_F90_ALL_INTEGER_MODELS. In my case, I got the following output:


           2 ,           1
           4 ,           2
           9 ,           4
          18 ,           8

Thus, I set CROSS_F90_ALL_INTEGER_MODELS=2,1,4,2,9,4,18,8.


CROSS_F90_INTEGER_MODEL_MAP

First you will need to build a C file providing the cisize function.

int cisize_(char *,char*);
int cisize_(char *i1p, char *i2p)
{
  int isize_val=0;
  isize_val = (int)(i2p - i1p);
  return isize_val;
}

Then, for each line in the output for CROSS_F90_ALL_INTEGER_MODELS, let $range be the first integer, and let $offset be the second integer. Compile the following program, substituting in $range and $offset for the given line, and run it.

      program main
      integer (kind=$kind) a(2)
      integer cisize
      open(8, file="pac_fconftest.out", form="formatted")
      write(8,*) $range, ",", $kind, ",", cisize( a(1), a(2) )
      close(8)
      end

After running this program for each line, you can concatenate all of the outputs together. (Keep in mind that the program above will output to the same file, pac_fconftest.out, each time.) In my case, my concatenated output was as follows.

           2 ,           1 ,           1
           4 ,           2 ,           2
           9 ,           4 ,           4
          18 ,           8 ,           8

Thus, I set CROSS_F90_INTEGER_MODEL_MAP={2,1,1},{4,2,2},{9,4,4},{18,8,8}.

fakedad
  • 1,292
  • 1
  • 10
  • 21