C: OpenMP and MPI hybrid

For GNU/Linux, assuming you have some implementation of MPI (openmpi/LAM MPI/MPICH*) installed and that you are using a compiler that understands OpenMP primitives (GCC >= 4.2.0, ICC, Pathscale etc):

This should work for the MPI wrapper to GCC:
Code:
mpicc -fopenmp blah.c -o blah

This should work for the MPI wrapper to ICC:
Code:
mpicc -openmp blah.c -o blah

On a cluster that should probably be:
Code:
mpicc -cluster-openmp blah.c -o blah

If you're using Windows, IIRC MSVS has had support for OpenMP since the 2005 edition. You could probably get away with using DeinoMPI for the MPI stuff.
 
I had used this

Code:
mpicc -openmp blah.c
dont really need to specify -o blah?

but the issue came when trying to run it, I'm not sure what the command is but I tried this

Code:
mpiexec -n 4 ./penmp.out
and the Linux terminal gave this error

mpiexec was unable to launch the specified application as it could not access or execute an executable
 
Last edited:
Things to consider on the 4 other PC's
-How are they accessing the file? Because you're telling them all that they can find the executable at "./penmp.out" which is where the other pc's will then look for the file.
-Have you set up the appropriate users on the other pcs?
-Have the private/public keys been made and been added to authenticated_keys list?

If you're running it locally
-Make sure the file actually exists and you have at least execute privileges on the user account
 
Last edited:
I had used this

Code:
mpicc -openmp blah.c
dont really need to specify -o blah?
No, I just prefer to avoid unintentionally clobbering the output file.

but the issue came when trying to run it, I'm not sure what the command is but I tried this

Code:
mpiexec -n 4 ./penmp.out
and the Linux terminal gave this error

This could be something simple like your MPI implementation trying to use rsh instead of ssh (MPICH*), or because your ssh setup doesn't work without passwords. This is usually a requirement for using MPI. Another possible cause is that the full environment is not sent with a non-interactive shell. This can be addressed by adding the necessary binary paths to $PATH and library paths to $LD_LIBRARY_PATH by placing them in ~/.bashrc or something that will have a similar effect.
 
Here's what I'm doing now, it's on one local machine with 4 cores

Code:
---@linHons4:~/HPCII$ mpicc -openmp suffixarray.c -o blah
----@linHons4:~/HPCII$ mpiexec -n 4 blah
[linHons4:02885] *** Process received signal ***
[linHons4:02885] Signal: Segmentation fault (11)
[linHons4:02885] Signal code: Address not mapped (1)
[linHons4:02885] Failing at address: (nil)
[linHons4:02885] [ 0] [0x43240c]
[linHons4:02885] [ 1] blah(getFileLength+0x21) [0x8048d65]
[linHons4:02885] [ 2] blah(main+0xc3) [0x8049b07]
[linHons4:02885] [ 3] /lib/libc.so.6(__libc_start_main+0xe7) [0x244ce7]
[linHons4:02885] [ 4] blah() [0x8048cb1]
[linHons4:02885] *** End of error message ***
--------------------------------------------------------------------------
mpiexec noticed that process rank 0 with PID 2885 on node linHons4 exited on signal 11 (Segmentation fault).
The "---" are just what I removed (for privacy ;))
 
Never mind guys, blonde moment. I was suppose to be reading in a file and since I had copied my old code in a new directory, I forgot to copy the target file as well :erm::D
 
Last edited:
Top
Sign up to the MyBroadband newsletter
X