Reputation: 11
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
Upvotes: 0
Views: 1498
Reputation: 8380
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.
Upvotes: 1
Reputation: 3086
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
Upvotes: 0