flozz / pypapi

Python binding for the PAPI (Performance Application Programming Interface) library
https://flozz.github.io/pypapi/
Do What The F*ck You Want To Public License
43 stars 11 forks source link

Issue at compilation time #16

Closed lmontigny closed 6 years ago

lmontigny commented 6 years ago

The libpapi.a seems to be missing, I attached my commands:

python pypapi/papi_build.py generating ./pypapi/_papi.c the current directory is '/home/lmontigny/Software/pypapi' running build_ext building 'pypapi._papi' extension gcc -pthread -B /home/lmontigny/anaconda3/envs/graphwave_env_clean/compiler_compat -Wl,--sysroot=/ -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/lmontigny/Software/pypapi/pypapi -I/home/lmontigny/anaconda3/envs/graphwave_env_clean/include/python2.7 -c pypapi/_papi.c -o ./pypapi/_papi.o gcc -pthread -shared -B /home/lmontigny/anaconda3/envs/graphwave_env_clean/compiler_compat -L/home/lmontigny/anaconda3/envs/graphwave_env_clean/lib -Wl,-rpath=/home/lmontigny/anaconda3/envs/graphwave_env_clean/lib -Wl,--no-as-needed -Wl,--sysroot=/ ./pypapi/_papi.o /home/lmontigny/Software/pypapi/pypapi/../papi/src/libpapi.a -L/home/lmontigny/anaconda3/envs/graphwave_env_clean/lib -lpython2.7 -o ./pypapi/_papi.so gcc: error: /home/lmontigny/Software/pypapi/pypapi/../papi/src/libpapi.a: No such file or directory

flozz commented 6 years ago

Hello,

:)

lmontigny commented 6 years ago

Thank you!

Is it supposed to work for Python 2.*? /home/lmontigny/Software/pypapi/papi/src/papi.c:1026: undefined reference to __intel_sse2_strncmp' ../libpapi.a(papi.o): In functionPAPI_read': /home/lmontigny/Software/pypapi/papi/src/papi.c:2596: undefined reference to `_intel_fast_memcpy'

I was able to compile with Python 3.* without trouble. (my script is in Python 2 unfortunately...)

Note that you need to install cffi, I did with pip.

flozz commented 6 years ago

It should work with Python 2.7

what is your linux distribution?

lmontigny commented 6 years ago

I am using CentOS 7, inside Conda environment

flozz commented 6 years ago

I made an update to allow passing flags to the compiler using environment variable.

Please pull the last commit from this repository:

git pull

Then can you try the following:

cd papi/src
make clean
cd -
export CFLAGS=-msse2
python setup.py build
python pypapi/papi_build.py

If this does not work, can you provide the output of the following command:

gcc -Q --help=target -march=native
lmontigny commented 6 years ago

Alright, I tried but I had the same issue.

If it helps, I am using: conda create -n papi_compiled -c intel python=2.7 pip -y

gcc output: gcc.txt

gcc (GCC) 7.2.0 icc (ICC) 18.0.2 20180210 on Xeon Skylake SP 8180

I tried with CFLAGS=-march=core-avx2 and others without success. Note that this variable is passed to gcc and icc.

flozz commented 6 years ago

Hello,

I thenk the problem is caused because papapi is built using a compiller (maybe icc?) and the python extension with an other one (probalbly gcc). Can you try this?

export CC=gcc
cd papi/src
make clean
cd -
python setup.py build
python pypapi/papi_build.py
lmontigny commented 6 years ago

Hi, Alright, I was able to compile it!

Unfortunately at running time, I got

from pypapi import papi_high
  File "/home/lmontigny/anaconda3/envs/papi_compiled_1/lib/python2.7/site-packages/python_papi-5.5.1.3-py2.7-linux-x86_64.egg/pypapi/__init__.py", line 1, in <module>
    from . import papi_high
  File "/home/lmontigny/anaconda3/envs/papi_compiled_1/lib/python2.7/site-packages/python_papi-5.5.1.3-py2.7-linux-x86_64.egg/pypapi/papi_high.py", line 48, in <module>
    from ._papi import lib, ffi
ImportError: /home/lmontigny/anaconda3/envs/papi_compiled_1/lib/python2.7/site-packages/python_papi-5.5.1.3-py2.7-linux-x86_64.egg/pypapi/_papi.so: undefined symbol: __intel_sse2_strcpy

I tried different CXX flags, I couldn't find a workaround... It seems that the compiler was not aware of the SIMD extension, it could be that Python itself was compiled with a old gcc.

flozz commented 6 years ago

Is both Python and PyPAPI compiled with the same compiler? Maybe you will have to recompile Python with the same compiler than the one used for PyPAPI.

lmontigny commented 6 years ago

I am using Python directly from conda. It will try to compile my own. Thanks!

flozz commented 6 years ago

Hello,

I close this issue, please re-open it if you still have questions :)