Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7108 Discussions

catastrophic error: cannot open source file "iostream"

Georgios_S_
New Contributor II
8,388 Views

I am compiling a correct example (taken from here), but I am getting:

gsamaras@pythagoras:~/intel/code$ ../bin/icc -mkl nine_by_nine.c -o n
nine_by_nine.c(2): catastrophic error: cannot open source file "iostream"
  #include <iostream>

If I compile with mpicc nine_by_nine.c -l../../mpich-install ${MKLROOT}/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a -Wl,--end-group ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_lp64.a -liomp5 -ldl -lpthread -lm, as suggested here, I am getting the very same error message.

What should I do?

Notice that this does not seem to help me.

---

EDIT:

An example that includes these headers works just fine:

#include <stdio.h>
#include <stdlib.h>
#include "mkl.h"

 

0 Kudos
1 Solution
Georgios_S_
New Contributor II
8,388 Views

Hi Tim,

  I really want to clear up the confusion, but I didn't have what you have in mind. Not sure if I have it now too, to be accurate. First of all,, there is no such thing as mpiCC in my MPICH2 installation. See first code block of post #6, which lists what it has. So you mean how am I compiling a C++ with MPI program? If this is the case (if not, *please* let me know and I will report back ASAP), then I would do this (for compiling this .cpp example):

gsamaras@pythagoras:~/mpich-3.1.4/code$ ../../mpich-install/bin/mpic++ ring.cpp -o r
gsamaras@pythagoras:~/mpich-3.1.4/code$ mpiexec -n 2 ./r

This won't compile with g++, because of MPI errors.

Notice that I also tried to compile what I have in post #6 with g++, but it didn't recognize -mkl again.

Thanks,

George

EDIT:

It compiled with:

 ../mpich-install/bin/mpic++ -o test n.cpp -I../intel/mkl/include  ../intel/mkl/lib/intel64/libmkl_scalapack_ilp64.a -Wl,--start-group ../intel/mkl/lib/intel64/libmkl_intel_ilp64.a ../intel/mkl/lib/intel64/libmkl_core.a ../intel/mkl/lib/intel64/libmkl_sequential.a -Wl,--end-group ../intel/mkl/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -lpthread -lm -ldl

from a new directory I created. Not sure why this worked, but it compiled by just giving a warning:

 warning: deprecated conversion from string constant to âchar*â [-Wwrite-strings]
     Cblacs_gridinit(&ictxt, "Row", nprow, npcol);
                                                ^

EDIT_2:

Just for the future users:

However, it will produce a floating point exception (which is weird, since I took it from a guy that knows what he is doing):

gsamaras@pythagoras:~/konstantis$ mpiexec -n 1 ./test
Returned:  Hello World! I am 0 of 1


===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   PID 4738 RUNNING AT pythagoras
=   EXIT CODE: 8
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Floating point exception (signal 8)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions

and I am pretty sure that this happens in this line:

locR = numroc_(&matrix_size, &block, &myrow, &izero, &nprow);

 

View solution in original post

0 Kudos
10 Replies
TimP
Honored Contributor III
8,388 Views

You should be using a C++ MPI wrapper and a C++ source file suffix (mpiicpc in the case of Intel MPI) to compile C++ MPI code.  gcc will make the switch automatically when it sees source files with a C++ suffix or when -x c++ is specified, but that switchover will still not take care of the link step.

Part of this was covered in the parts of the URL you gave which you ignored.

0 Kudos
Georgios_S_
New Contributor II
8,388 Views

Tim, sorry but I missed it, I didn't ignore anything. :) However, I am still unable to compile it:

gsamaras@pythagoras:~/intel/code$ ../bin/mpiicpc -mkl nine_by_nine.c -o n
-bash: ../bin/mpiicpc: No such file or directory
gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpiicpc -mkl nine_by_nine.c -o nnine_by_nine.c
-bash: ../../mpich-install/mpiicpc: No such file or directory
gsamaras@pythagoras:~/intel/code$ ../bin/icpc -mkl nine_by_nine.c -o nnine_by_nine.c
/tmp/icpc3iCx8w.o: In function `main':
nine_by_nine.c:(.text+0x47): undefined reference to `MPI_Init'
// similar errors about MPIT

Note that `../../mpich-install` is the path where I have installed MPICH2, since it wasn't provided with MKL.

Also note that `mpiicpc` alone is not found. What am I missing?

0 Kudos
TimP
Honored Contributor III
8,388 Views

If you are using mpich I guess the c++ wrapper may be mpiCC but you may still need a cpp or equivalent suffix for c++ source files. 

0 Kudos
VipinKumar_E_Intel
8,388 Views

Could you try again after setting the environment for Intel Tools by sourcing the scripts located in these locations, in case you have not done so?

<your installation folder>/bin/compilervars.sh intel64  (assuming you are building for Intel64.

<your installation folder>/mkl/bin/mklvars.sh intel64

<your installation folder>/impi/x.x.x.xxx/bin64/mpivars.sh

0 Kudos
Georgios_S_
New Contributor II
8,388 Views

Tim no, I had tried what seemed to be needed for C++ and MPI, but it didn't recognize -mkl. Should have included this information in my previous post.

Vipin Kumar E, the first two worked, but the later failed, because their so no such directory as impi. Here is what I have:

gsamaras@pythagoras:~/intel/bin$ ls
codecov           gdb-mic      icpc           map_opts   tselect
compilervars.csh  icc          inspxe-inject  profdcg    xiar
compilervars.sh   iccvars.csh  inspxe-runsc   profmerge  xild
gdb-ia            iccvars.sh   inspxe-wrap    proforder
gsamaras@pythagoras:~/intel/bin$ ls ../
advisor_xe                    intel_sdp_products.db
advisor_xe_2015               ipp
advisor_xe_2015.1.10.380555   ism
bin                           lib
code // I created this        licenses
composerxe                    man
composer_xe_2015              mkl
composer_xe_2015.3.187        parallel_studio_xe_2015
include                       tbb
inspector_xe                  vtune_amplifier_xe
inspector_xe_2015             vtune_amplifier_xe_2015
inspector_xe_2015.1.2.379161  vtune_amplifier_xe_2015.3.0.403110
gsamaras@pythagoras:~/intel/bin$ ls ../../mpich-install/bin
hydra_nameserver  mpic++        mpicxx         mpif77   mpirun
hydra_persist     mpicc         mpiexec        mpif90   mpivars
hydra_pmi_proxy   mpichversion  mpiexec.hydra  mpifort  parkill

PS - My product is: Intel® Parallel Studio XE Professional Edition for C++ Linux* for student-use only.

EDIT:

As expected, by using the MPI compilers, MKL is not "visible", thus an error:

gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpic++ -mkl nine_by_nine.c -o n
g++: error: unrecognized command line option ‘-mkl’
gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpic++ nine_by_nine.c -o n
nine_by_nine.c:7:17: fatal error: mkl.h: No such file or directory
 #include <mkl.h>
                 ^
compilation terminated.
gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpicxx -mkl nine_by_nine.c -o n
g++: error: unrecognized command line option ‘-mkl’
gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpicc -mkl nine_by_nine.c -o n
gcc: error: unrecognized command line option ‘-mkl’

EDIT_2:

I created a new file, with a .cpp extension, instead of .c. However, the errors are still alive:

gsamaras@pythagoras:~/intel/code$ ../../mpich-install/bin/mpicxx nine_by_nine.cpp -o n -I/../../intel/include
nine_by_nine.cpp:7:17: fatal error: mkl.h: No such file or directory
 #include <mkl.h>
                 ^
compilation terminated.

mpicxx nine_by_nine.cpp -l../../mpich-install ${MKLROOT}/lib/intel64/libmkl_scalapack_lp64.a -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_core.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a -Wl,--end-group ${MKLROOT}/lib/intel64/libmkl_blacs_intelmpi_lp64.a -liomp5 -ldl -lpthread -lm
g++: error: /lib/intel64/libmkl_scalapack_lp64.a: No such file or directory
g++: error: /lib/intel64/libmkl_intel_lp64.a: No such file or directory
g++: error: /lib/intel64/libmkl_core.a: No such file or directory
g++: error: /lib/intel64/libmkl_intel_thread.a: No such file or directory
g++: error: /lib/intel64/libmkl_blacs_intelmpi_lp64.a: No such file or directory

Same errors with mpic++ and mpicc. I also checked manually for '/lib/intel64/libmkl_scalapack_lp64.a' for example, but it's not there! I am really stuck, what I should do?

0 Kudos
TimP
Honored Contributor III
8,388 Views

If your mpiCC doesn't recognize -mkl i would guess it's configured to use g++

You would check mpich docs on how to fix that with mpich.

it doesn't make sense to continue with this thread if you don't intend to clear up this confusion .

0 Kudos
Georgios_S_
New Contributor II
8,389 Views

Hi Tim,

  I really want to clear up the confusion, but I didn't have what you have in mind. Not sure if I have it now too, to be accurate. First of all,, there is no such thing as mpiCC in my MPICH2 installation. See first code block of post #6, which lists what it has. So you mean how am I compiling a C++ with MPI program? If this is the case (if not, *please* let me know and I will report back ASAP), then I would do this (for compiling this .cpp example):

gsamaras@pythagoras:~/mpich-3.1.4/code$ ../../mpich-install/bin/mpic++ ring.cpp -o r
gsamaras@pythagoras:~/mpich-3.1.4/code$ mpiexec -n 2 ./r

This won't compile with g++, because of MPI errors.

Notice that I also tried to compile what I have in post #6 with g++, but it didn't recognize -mkl again.

Thanks,

George

EDIT:

It compiled with:

 ../mpich-install/bin/mpic++ -o test n.cpp -I../intel/mkl/include  ../intel/mkl/lib/intel64/libmkl_scalapack_ilp64.a -Wl,--start-group ../intel/mkl/lib/intel64/libmkl_intel_ilp64.a ../intel/mkl/lib/intel64/libmkl_core.a ../intel/mkl/lib/intel64/libmkl_sequential.a -Wl,--end-group ../intel/mkl/lib/intel64/libmkl_blacs_intelmpi_ilp64.a -lpthread -lm -ldl

from a new directory I created. Not sure why this worked, but it compiled by just giving a warning:

 warning: deprecated conversion from string constant to âchar*â [-Wwrite-strings]
     Cblacs_gridinit(&ictxt, "Row", nprow, npcol);
                                                ^

EDIT_2:

Just for the future users:

However, it will produce a floating point exception (which is weird, since I took it from a guy that knows what he is doing):

gsamaras@pythagoras:~/konstantis$ mpiexec -n 1 ./test
Returned:  Hello World! I am 0 of 1


===================================================================================
=   BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
=   PID 4738 RUNNING AT pythagoras
=   EXIT CODE: 8
=   CLEANING UP REMAINING PROCESSES
=   YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Floating point exception (signal 8)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions

and I am pretty sure that this happens in this line:

locR = numroc_(&matrix_size, &block, &myrow, &izero, &nprow);

 

0 Kudos
TimP
Honored Contributor III
8,388 Views

If your mpich wrapper is spelled mpic++, that's a new one to me, but you could do e.g.

mpic++ -v

or mpic++ -V

to see whether it is attached to g++ or icpc.

-mkl option is peculiar to Intel compilers.  The link advisor app on the Intel site documents how to link with g++ linux and mac (or with Intel compilers, if you want something different from what is included in -mkl options).

0 Kudos
Georgios_S_
New Contributor II
8,388 Views

Hi Tim,

 I guess mpiCC would be the older version. Well, why would it be attached to icpc? I mean I installed MPICH2 and it's standalone. Here is also the output of -v:

gsamaras@pythagoras:$ mpic++ -v
mpicxx for MPICH version 3.1.4
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.9 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --with-arch-32=i586 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Debian 4.9.2-10)

By the way, if somebody finds the bug in the example I compiled, it would be nice to let us know.

Thanks guys.

0 Kudos
TimP
Honored Contributor III
8,388 Views

You are running mpich built to use g++, so it is expected to behave as g++ rather than icc or icpc.  When g++ compiles a .c source file, without the option -x c++, it might be expected not to handle C++ include files, even though it accepts it as input to gcc.  Nor will it understand the -mkl option, so you must refer to the link advisor https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/ for advice on options for compiling and linking with g++ against MKL.

Any up to date mpich site should document how to make mpich C++ wrapper invoke icpc.  There is sufficient compatibility between g++ and icpc (including ability to share libstc++) that it may not require a completely separate build of mpich, although that is the usual way in my experience. If you want separate g++ and icpc builds of mpich to coexistm a likely method would be to build and install in separate directories.  You have done the right thing by having that mpich-install directory for your g++ mpich build, rather than putting it on one of the default system paths; you would need another such directory for a separate icpc build.

You could quite likely build files which don't include any mpi headers with icpc and include them in a build using mpich g++, but that is a higher level of complication.

0 Kudos
Reply