Closed Masterwater-y closed 2 months ago
Hello @Masterwater-y,
Since the DiscoPoP profiler is built upon LLVM-IR, analyzing Fortran code is theoretically possible. However, i have to admit that for a while now no one in our team is "fluent" in Fortran, which is why it has been neglected a bit, and i can not guarantee that it will work out of the box, simply because we have not tested it in some time. The same is true for the analysis steps after the profiling.
Nevertheless, i would be more than happy to help! I will try instrumenting a simple benchmark and get back to you asap.
Best Lukas
Hello again,
a possible approach to instrument a Fortran application is to create a llvm-ir .ll
file from it using the following flags -g -O0 -fno-discard-value-names -S -emit-llvm
, and apply the DiscoPoP instrumentation pass located in <build>/libi/LLVMDiscoPoP.so
named -DiscoPoP
via opt
.
Unfortunately, my environment does not allow this optimization out of the box.
@lukasrothenberger Thank you for your response, I'll try the solution. I would like to ask how your team used Discopop to experiment with NPB, as it contains a lot of Fortran code. Did you use the C version implementation or the solution you provided above?
Hello @Masterwater-y, The wrappers are a fairly recent addition to the "ecosystem", which is why they do not support fortran (yet). Nevertheless, it should be possible to instrument Fortran code manually. Unfortunately, i am not aware of any documentation for the mentioned case. My guess is a mix of both, since even C code needed to be manually instrumented up until fairly recently.
Hello @lukasrothenberger I have made some attempts in the past few days and encountered some problems. Firstly, I installed flang from llvm-project, but the flang from llvm11 failed to generate LLVM IR correctly and reported the following error.
flang -S -g -O0 -emit-llvm square.f90 gfortran: warning: square.o: linker input file unused because linking not done
Then I installed the latest llvm and the corresponding flang, which is called flang-new, and it can generate LLVM IR correctly.
I ran the following command and encountered some errors. I want to know if I misunderstood something or if there is a problem with the command I ran.
flang-new -g -O0 -fno-discard-value-names -S -emit-llvm -o output.ll ff.f90 flang-new: error: unknown argument: '-fno-discard-value-names'
flang-new -g -O0 -S -emit-llvm -o output.ll ff.f90 opt -load ../build/libi/LLVMDiscoPoP.so -DiscoPoP -o output_inst.ll output.ll
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump:
Segmentation fault (core dumped)
Hello @Masterwater-y,
your approach and the used command in the second try should be correct, as far as i can tell.
I've tried it myself, and ran into issues due to version mismatches of llvm-17's flang-new
, or rather opt
, and the LLVMDiscoPoP.so
, since it was compiled using llvm-11.
I suspsect the only true solution to solve the issue is to update the Instrumentation pass to use llvm-17, then it should be compatible with opt-17
and flang-new
.
Unfortunately, we do not have the time to tackle this at the moment, as this change would require some major changes.
I am really sorry for this.
Perhaps it is possible to get it working for a specific combination of clang, flang and manual linking, but i can not guarantee anything.
I was wondering if it is possible to use Discopop to analyze Fortran code, as I only see C and CXX wrappers in the discopop/build/scripts directory. However, in the experimental section of the paper "Unveiling parallelization opportunities in sequential programs," I noticed that Discopop was used to analyze NPB3.3.1, which consists mostly of Fortran code. I would like to inquire about how to use Discopop to analyze NPB or Fortran code.
Thank you for your time and assistance.