Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
13 Views

Intel Fortran Inconsistency

Hi, everybody!
I'm having a bit of trouble getting some code to 1) run and 2) parallelize. First, I started running a bit of code with the Intel Fortran (ifort, the most recent) compiler and there was an issue (core dump). The Intel help pages informed me that I need to run the openmp with dynamic linking (even though that seems to be the default). So, in all of my make files where I saw -openmp, I put in
"-openmp-link=dynamic"
since I'm running this through a Mac terminal. Now, I start running the program and everything is merry until I decide to add in parallelization sites. The bottom line is, it's not parallelizing with the "-link=dynamic" added. I also checked this on another computer to check if my source files were heading to the right place.
So, my question to all of the far more expert programmers is how do I get the program to run correctly and parallelize? If I take out the "-link=dynamic" everything works splendidly (i.e. numbers other than zeros come up for the thread number in the sample program below and the system usage application lights up like a pinball machine). But in the other, larger program, I can't get rid of the dynamic linking libraries and get it to parallelize and work...so there's a bit of a dilemma.
Below is a sample test code I've been running to see if things are working. When the code is parallelized, it will post from which thread the print command was made. If it's not parallelized, then everything is zeros or the number of threads. If there's some other way to avoid the problem (I apologize for not keeping the link) other than to add "-link=dynamic" then we should try that too.
I can't thank you enough for just reading this. I definitely appreciate any thoughts you might have. Please let me know if there's something else that might help solve this.
Regards.
**********************
#Makefile
PROG1 =test
OBJS1 = multiply.o
LIBS = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -liomp5 -lpthread
#F90FLAGS = -O3 -openmp
F90FLAGS = -O3 -openmp-link=dynamic
F90 = ifort -m64
#LDFLAGS = -openmp -mkl $(LIBS)
LDFLAGS = -openmp-link=dynamic -mkl $(LIBS)
all: $(PROG1)$(PROG2)
$(PROG1): $(OBJS1)
$(F90) -o $@ $(OBJS1) $(LDFLAGS)
clean:
rm -f $(PROG1) $(PROG2) *.{o,mod,u}
.SUFFIXES: $(SUFFIXES) .f90
.f90.o:
$(F90) $(F90FLAGS) -c $<
**********************
!multiply.f90
program multiply
use omp_lib
implicit none
integer :: i, TID, NTHREADS
!$OMP PARALLEL PRIVATE(NTHREADS,TID)
!$OMP DO
do i=1,8*4+1
TID = OMP_GET_THREAD_NUM()
PRINT *, 'Thank you! From thread = ', TID
IF (TID .EQ. 0) THEN
NTHREADS = OMP_GET_NUM_THREADS()
PRINT *, 'Number of threads = ', NTHREADS
END IF
end do
!$OMP END DO
!$OMP END PARALLEL
end program multiply
0 Kudos
2 Replies
Highlighted
Black Belt
13 Views

Ifort defaults to linking against the dynamic OpenMP library, so your openmp-link flag is redundant (if spelled correctly). If misspelled, it will be taken as an unintended over-ride for your output file name, which no doubt is confusing you. I suspect that the -openmp-link flag doesn't cause -openmp option to be set implicitly.
-liomp5 -lpthread options also are redundant when you use ifort -openmp to link.
The linux/mac Fortran forum is the place to ask questions which may not be covered adequately in the docs, if your subject fits there.
You really should stick closer to the recommendations of the compiler and MKL docs (including the link advisor at the top of the MKL forum), at least until you have a working base to depart from.
0 Kudos
Highlighted
Beginner
13 Views

Ok, apologies for posting on the wrong place. I will go and check out the document you mention. Thank you for the help.
0 Kudos