How to create an library (static or dynamic) with inline infromations

How to create an library (static or dynamic) with inline infromations

Hi all,

I have a C++ application wich use a library of objects, as the functions in it are small the applications have great perfomances improvement when they are unline. But I didn't succeed to create an library with inline informations, or the link fail or the timing are not good !!

I have tryed to make a static library but during the link it fails with the following messages (ecc release 7.1.029):
% ecc -c -DLINUX -O3 -ipo Matrix.C
% ecc -c -DLINUX -O3 -ipo Point2D.C
% ar rvf mylib.a Matrix.o Point2D.o
a - Matrix.o
a - Point2D.o

% ecc -c -DLINUX -O3 -ipo Main2.C
% ecc -DLINUX -O3 -ipo Main2.o mylib.a -lm -o TestPerf2
IPO: using IR for Main2.o
IPO: performing single-file optimizations
mylib.a: could not read symbols: Archive has no index; run ranlib to add one

% ranlib mylib.a
% ecc -DLINUX -O3 -ipo Main2.o mylib.a -lm -o TestPerf2
IPO: using IR for Main2.o
IPO: performing single-file optimizations
mylib.a: could not read symbols: Archive has no index; run ranlib to add one

But I have also tryed also with "xild" :

% ecc -c -DLINUX -O3 -ipo Matrix.C
% ecc -c -DLINUX -O3 -ipo Point2D.C
% xild -lib -o mylib.a Matrix.o Point2D.o
IPO: using IR for Matrix.o
IPO: performing single-file optimizations
xiar: error: /intel-compilers/7.1.029/compiler70/ia64/bin/ias: core dumped
xiar: error: Fatal error in /intel-compilers/7.1.029/compiler70/ia64/bin/ias, terminated by unknown signal(139)
xiar: error: problem during multi-file optimization compilation (code 1)

I have also tryed to make a dynamic library but during the link it fails with the following messages (ecc release 7.1.029):
% ecc -c -DLINUX -O3 -prof_dir /tmp -prof_gen Matrix.C
% ecc -c -DLINUX -O3 -prof_dir /tmp -prof_gen Point2D.C
% xild -shared -soname libobj.so.1 -o libobj.so.1.o Matrix.o Point2D.o
xild: executing 'ld'
% cp libobj.so.1.o LIB_DYN/
% cd LIB_DYN
% ldconfig -v -n .
.:
libobj.so.1 -> libobj.so.1.o (changed)
% ln -s libobj.so.1 libobj.so
% cd ../
% ecc -c -DLINUX -O3 Main2.C
% ecc -DLINUX -O3 Main2.o -lobj -lm -o TestPerf2 -LLIB_DYN/
% setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:'./LIB_DYN/'
% ./TestPerf2
./LIB_DYN/libobj.so.1: undefined symbol: __dso_handle

I have also tryed with 8.0.x release but I have the same trouble.
And the option "-ipo_obj" during compilation does give me good performances ... (the functions have not been inlined)

Does somes one have any idea ???

2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,

If you look in the C++ User's Guide from the 8.0 release, this is discussed on p. 97.

Looking at you're posting, you are trying 3 things.

1) use -ipo w/o using xild (ie use ar, this is known not to work)

2) use xild to create static lib. This should work but we are getting an error:

xiar: error: /intel-compilers/7.1.029/compiler70/ia64/bin/ias: core dumped

You should submit an issue at http://premier.intel.com on this so we can investigate it. I'd recomend reducing the number of object files you put in the library to isolate which one is causing the problem. Are you able to build the app w/o putting the objects in a library ? This again will help isolate what the problem is.

3) create shared lib. I will post an example of this below

file a.cxx
#include
float asqrt(float b) { return sqrt(b); }

file b.cxx
#include
float bsqrt(float b) { return sqrt(b); }
file main.cxx
float asqrt( float a);
float bsqrt( float a);
#include
using namespace std;
int main() {
float ans, b = 16.0;
ans =asqrt(b);
cout << "asqrt: ans= " << ans << " b = " << b << endl;
ans =bsqrt(ans);
cout << "bsqrt: ans= " << ans << " b = " << b << endl;
}
Step 1: Create shared lib, create optimization report file /tmp/libopt.txt
icpc -shared -o libobj.so a.cxx b.cxx -ipo -opt_report_file /tmp/libopt.txt
IPO: using IR for /tmp/iccWLa1J8.o
IPO: using IR for /tmp/icc0AQcdg.o
IPO: performing multi-file optimizations
Step 2: Link app w/ shared lib, create optimization report file /tmp/mainopt.txt
icpc main.cxx -lobj -L. -ipo -opt_report_file /tmp/mainopt.txt
IPO: using IR for /tmp/icpctyI4Ff.o
IPO: performing single-file optimizations
IPO link: can not find -lobj
IPO Warning: unresolved : _Z5asqrtf
Referenced in ipo_icpcTBSAPK.o
IPO Warning: unresolved : _Z5bsqrtf
Referenced in ipo_icpcTBSAPK.o
The optimization reports for the library indicates that asqrt & bsqrt functions are inlined (the optimization report shows the c++ mangled names, you can use c++filt to decode: c++filt _Z5asqrtf gives asqrt(float) ).
grep asqrt /tmp/libopt.txt
INLINING: (_Z5asqrtf)
The main program optimizatoin report indicates that these functions are inlined.

Hope this helps,
John O'Neill

Leave a Comment

Please sign in to add a comment. Not a member? Join today