0
votes

I am trying to compare solvers with one of them being parallelized in OpenMP; Solvers are all running in parallel under OpenMPI using Fixed Form Fortran 77; mpif77 does not let me link the object files with the -fopenmp switch; Make does not create the executable. I tried to compile the OpenMP source files separately with gfortran and then tried to link them with mpif77 - does not work; When I do not use the switch it throws the common error:

Undefined symbols for architecture x86_64:
  "_GOMP_parallel", referenced from:
      _parmatdiff_ in matdiff.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [solvercomp] Error 

1

My question is does OpenMPI support OpenMP and if yes, how do I ensure that 'make' links object files created to functions in OpenMP libraries?

Here is a copy of my makefile:

SOURCES = solvcomp.f matdiff.f seqjacobi.f seqconjgrad.f parsor.f
FCC = mpif77
MPIRUN = mpirun
OBJECTS = $(SOURCES:.f=.o)
TARGET = soln
FFLAGS = -o
CFLAGS = -c
NP = 4

all: $(TARGET) clean

$(TARGET): $(OBJECTS)
        $(FCC) $(FFLAGS) $(TARGET) $(OBJECTS)

$(OBJECTS): $(SOURCES)
        $(FCC) $(CFLAGS) $(SOURCES)

clean:
    rm -rf *.o *.dSYM
2
which version of Open MPI are you using ? can you post the error produced by mpif77 -fopenmp ? - Gilles Gouaillardet
Note that OpenMPI is only one of many implementations of MPI while OpenMP is a standard. So two very different things. We really need to know more details (see How to Ask). Which versions do you use? What does mpif77 -v print? How does the last command executed by make look like? How does the complete output of make look like? - Vladimir F
Also, what exactly happened when "mpif77 does not let me link the object files with the -fopenmp switch"? We need details, details, details? Any error message? Which comands did make execute? What was the complete output? Any error message? Where did you put the flag into the Makefile? - Vladimir F
It is really best to first try to link a simple example without any Makefile, only with a simple.command with mpif77 -fopenmp. The answer to your question is likely yes, it does support. You haven't show us what "does not work" but OpenMPI is likely not at fault, your Makefile probably is, so show the makefile and the complete output. We need the details. - Vladimir F
Please do NOT put important info in the comments. It is very hard to read it hear. Edit the question instead. It is useful to post all error messages. - Vladimir F

2 Answers

1
votes

Your link command is bogus

mpif77 -o -fopenmp a.out foo.o

Try

LDFLAGS='-fopenmp -o'

As far as I am concerned, having -o in your LDFLAGS looks pretty messed up in the first place.

0
votes

OpenMPI compiler mpicc|mpic++|mpif70|... is basically a program that calls a backend compiler with the appropriate flags that you need in order to include the necessary headers and link with the runtime library.

If you add the flag -showme, you will be able to see which compiler are you using. Although OpenMP is a standard, the compilers may have use different flags to indicate that your program must interpret OMP constructs and link with OpenMP runtime library. You can add -showme:link to your link command in order to see what options are being passed to the backend fortran compiler.

MPI and OpenMP are two parallel programming models commonly used together, so there shouldn't be any problem for you to do so in your programs.

https://www.open-mpi.org/doc/v2.0/man1/mpicc.1.php