1

I am trying to use OMPTrace which is a tool for tracing and visualizing OpenMP program execution as shown here https://github.com/passlab/omptrace. I have already tested the library on a simple code written in C and it works perfectly (the library is well installed in /home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so). I wonder now if it works also for codes written in Fortran. I created a makefile as following:

OMP_INSTALL=/home/hakim/llvm-openmp-install
OMP_LIB_PATH=${OMP_INSTALL}/lib
OMPTRACE_LIB=/home/hakim/llvm-openmp/BUILD/omptrace/build/libomptrace.so

default:runhecese

heceseclang: hecese_OpenMP.f90
    clang -g -fopenmp hecese_OpenMP.f90 -o heceseclang
    objdump -d heceseclang >heceseclang.objdump

runhecese: heceseclang
    LD_PRELOAD=${OMP_LIB_PATH}/libomp.so:${OMPTRACE_LIB} ./heceseclang 


clean:
    rm heceselang heceseclang.objdump core

and when executing it, I get :

/usr/bin/ld: /tmp/hecese_OpenMP-67d132.o: in function `__tasks_MOD_ww0':
hecese_OpenMP.f90:(.text+0x1dc6): undefined reference to `pow'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x1df7): undefined reference to `pow'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x1e1c): undefined reference to `pow'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x1e37): undefined reference to `pow'
/usr/bin/ld: /tmp/hecese_OpenMP-67d132.o: in function `__tasks_MOD_w':
hecese_OpenMP.f90:(.text+0x1ed0): undefined reference to `pow'
/usr/bin/ld: /tmp/hecese_OpenMP-67d132.o:hecese_OpenMP.f90:(.text+0x1eeb): more undefined references to `pow' follow
/usr/bin/ld: /tmp/hecese_OpenMP-67d132.o: in function `MAIN__':
hecese_OpenMP.f90:(.text+0x36f1): undefined reference to `_gfortran_st_open'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x372c): undefined reference to `_gfortran_st_read'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x373b): undefined reference to `_gfortran_st_read_done'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x3776): undefined reference to `_gfortran_st_read'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x3794): undefined reference to `_gfortran_transfer_integer'
/usr/bin/ld: hecese_OpenMP.f90:(.text+0x37a3): undefined reference to `_gfortran_st_read_done'

I didn't show you all the errors because the following ones are the same as the ones I've already showed. It is all about the undefined references. I wonder if it comes from the clang compiler.
Should I install the flang compiler and use it instead of the clang one? The result I'm waiting for is a .graphml file.

Any help, please ?

hakimo2
  • 143
  • 12
  • 2
    This might help: [What is an undefined reference/unresolved external symbol error and how do I fix it in Fortran?](https://stackoverflow.com/questions/66855252/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix). It looks like you're not linking to the `gfortran` compiler library. – veryreverie Jun 07 '21 at 14:07
  • 1
    Looks like you are linking with the C compiler and so missing references to things in the fortran run time library. What happens if you link with the Fortran compiler? https://stackoverflow.com/questions/19148378/gfortran-pow-c8-i4-error-when-linking-o-files-from-g-and-gfortran-using-g might be relevant. – Ian Bush Jun 07 '21 at 14:33
  • 1
    You must link the runtime libraries yourself if you are using a different software for linking. `gfortran` links in several libraries for you `-lm -lgfortran ...`. Check the linked questions. – Vladimir F Героям слава Jun 07 '21 at 14:51
  • 1
    Also likely `-lgomp`, in other cases you may need `-lpthread`, just add any other libraries if the are outstanding symbols missing. – Vladimir F Героям слава Jun 07 '21 at 15:04
  • 2
    If you are unsure about any step, compile your code with gfortran+clang withOUT any OMPtrace first. Only after you found out how to do that, add another layer of complexity. When reporting a problem with arrer messages coming from a Makefile, DO NOT only show the errors themselves, show also the commands that were issued by make and caused the errors you show. – Vladimir F Героям слава Jun 07 '21 at 17:02

0 Answers0