[NSWI131] 03-counter-spinner - papi problem

Karel Maděra KarelMad at email.cz
Fri Mar 20 20:46:12 CET 2020


I had a similar problem, what helped was these StackOverflow question 
https://stackoverflow.com/questions/35897290/what-is-the-right-order-of-
linker-flags-in-gcc
(https://stackoverflow.com/questions/35897290/what-is-the-right-order-of-linker-flags-in-gcc)
and https://stackoverflow.com/questions/20731220/compile-error-gcc-lpthread-
position
(https://stackoverflow.com/questions/20731220/compile-error-gcc-lpthread-position)
.




In a nutshell, try moving the -lpapi "option" to the last position,  so 
something like this:  $(CXX) $(CXXFLAGS) -O3 -Wall -o $@ counter-spinner.cpp
harness.cpp -lpapi



>From what I understand (and i may be wrong on this), the -l option is 
processed as soon as it is encountered, so if it is used before mentioning 
the files that use the library, it is discarded.

So it s not really an option or switch of gcc, as the form -l would suggest,
and more like a command.

It used to work on older gcc versions, but then they changed some default 
properties or something.





Karel Maděra

---------- Původní e-mail ----------
Od: Petr Tůma <petr.tuma at d3s.mff.cuni.cz>
Komu: William Tatarko <william.tatarko at gmail.com>
Datum: 20. 3. 2020 18:33:27
Předmět: Re: [NSWI131] 03-counter-spinner - papi problem 
"Hi,

this is seriously weird :-) and in fact exactly the same error I get if I 
omit "-lpapi" from the command line. (Why it is weird is because from the 
log you have sent, it is clear that "-lpapi" is there, and if the library 
file was missing, GCC would display an error message saying "cannot find -
lpapi".)

What you can try to do is see what library file the "papi_avail" command 
uses, on my machine it is something like this:

> ldd $(which papi_avail)
linux-vdso.so.1 (0x...)
libpapi.so.5 => /lib64/libpapi.so.5 (0x...)
...

This library obviously works, or the "papi_avail" command would not start. 
As the next step, you can try to use the library on the GCC command line 
directly:

> g++ -O3 -Wall /lib64/libpapi.so.5 -o counter-spinner counter-spinner.cpp 
harness.cpp

(Obviously, replace the library file name with whatever ldd shows on your 
system.)

If this also fails, and you do not see any obvious permission issues on the 
files involved, then I would recommend to simply use a lab computer (remote 
access should work) otherwise you will waste too much time with this.

Petr


On 20/03/2020 10:41, William Tatarko wrote:
> Hello,
> 
> thank you very much for the answer, but I am still unable to make ti work.
> 
> Initially I tried to install from the Git repository. From the src folder 
I ran "./configure", "make" and then I tried "make test", which resulted in 
"PASSED". Finally I ran "make install" with sudo, because otherwise I got a 
permission denied message. Later I also tried "make install-all" and papi 
versions 6.0 and 5.7 (which allegedly worked for a random person on the 
web). I also tried to install papi-tools using the "apt install" command (I 
am running Ubuntu).
> 
> Command "papi_available" show no available events, which was suspicious. 
After I ran "papi_native_avail" I got a message that essentially said that 
with paranoid=3 it cannot work. This was weird, because I got this error 
message when I was installing papi for the first time and I had done what 
the error message had asked me to do, after which I have not seen this error
message (until running "papi_native_avail"). Anyway, I executed "sudo sh -c 
'echo -1 >/proc/sys/kernel/perf_event_paranoid" and then "papi_available" 
suddenly showed 59 available events and "papi_native_avail" stoped 
complaining. However the compilation still throws the same error (it is in 
the attachment).
> 
> I believe it was initially installed (at least) into "/usr/local/lib/" 
directory. I tried to copy it also to different folders ("/lib/", "/lib64/",
"/usr/lib/" and "/usr/lib64/") but it did not helped either. I also tried to
explicitly set the path by modifying the compilation command to "$(CXX) $
(CXXFLAGS) -O3 -Wall -L/usr/local/lib/ -lpapi -o $@ counter-spinner.cpp 
harness.cpp", but still no luck.
> 
> Best regards
> William
> 
> On Fri, Mar 20, 2020 at 8:09 AM Petr Tůma <petr.tuma at d3s.mff.cuni.cz <
mailto:petr.tuma at d3s.mff.cuni.cz>> wrote:
> 
> Hi,
> 
> this sounds like a PAPI installation problem. It's hard to debug with 
little information, but these are the steps I would try (if they do not 
help, please include exact log of what commands you were running and what 
was the output):
> 
> - Did you install using your distribution packages, or from the Git 
repository ? If the latter, did you do 'make install' ?
> 
> - Do the 'papi_avail' and 'papi_native_avail' commands work, when launched
from any directory (not just the build directory) ?
> 
> - Do you have the PAPI library in your system default library path, e.g. /
lib64/libpapi.so.* ?
> 
> Hope this puts you on the right path, Petr
> 
> 
> On 19/03/2020 19:19, William Tatarko wrote:
> > Hello,
> >
> > I have some trouble with papi. I installed it without any problem (and 
even passed the original papi test). However when I try to run the make for 
the c++ version (without modifying the code at all) I got several errors 
like "undefined reference to `PAPI_*', where * is "stop", "start", "library_
init" and many more. I also tried the java version (again without changing 
the code), but the run.sh script resulted in "error: PAPI library 
initialization: Invalid argument (-1)". I am probably doing something 
terribly wrong, but after about 4 hours of debugging I have not figured it 
out.
> >
> > Can anybody please help me?
> >
> > Best regards
> > William
> >
> > _______________________________________________
> > NSWI131 mailing list
> > NSWI131 at d3s.mff.cuni.cz <mailto:NSWI131 at d3s.mff.cuni.cz>
> > https://d3s.mff.cuni.cz/mailman/listinfo/nswi131
> >
> 
_______________________________________________
NSWI131 mailing list
NSWI131 at d3s.mff.cuni.cz
https://d3s.mff.cuni.cz/mailman/listinfo/nswi131
"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://d3s.mff.cuni.cz/pipermail/nswi131/attachments/20200320/8215187d/attachment.html>


More information about the NSWI131 mailing list