Community
cancel
Showing results for 
Search instead for 
Did you mean: 
ploeger__lennert
Beginner
407 Views

the -mveclibabi=svml in gcc

Consider some very simple c program, vec_example.c:
"
#include
#include
#define N 16

double in = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0,
11.0, 12.0, 13.0, 14.0, 15.0, 16.0 };
double out;

int main ()
{
int i;

for (i = 0; i < N; i++)
out = exp (in);

for (i = 0; i < N; i++)
printf ("%f\\n", out);

return 0;
}
"
Now, suppose we want to compile using gcc (4.5.0 from MinGW on Windows XP) and use Intel MKL for SSE instructions of the "exp":
"
gcc -c vec_example.c -O2 -msse2 -ffast-math -ftree-vectorize -mveclibabi=svml
"
That works. Problems come with linking:
gcc vec_example.o -o vec_example "-LC:\\Program Files\\Intel\\Composer XE 2011 SP1\\mkl\\lib"
or with
gcc vec_example.o -o vec_example "-LC:\\Program Files\\Intel\\Composer XE 2011 SP1\\mkl\\lib\\ia32"
(The latter directory has the mkl_*.lib and mkl_*_dll.lib files)
Both give the same error message:
"
vec_example.o:vec_example.c:(.text+0x1d): undefined reference to `vmldExp2'
collect2: ld returned 1 exit status
"
How should I fix this?
0 Kudos
12 Replies
barragan_villanueva_
Valued Contributor I
407 Views

"Short Vector Math Library" (SVML)is a part ofthe Intel compiler

but not MKL.
So, please try additionally link with svml_disp*.lib (e.g. svml_dispmt.lib) where symbol `vmldExp2' is defined.

The Intel compiler has intrinsic names for the SVML functions in the header file ia32intrin.h
ploeger__lennert
Beginner
407 Views

Thanks. So I added svml_dispmt.lib to this directory "C:\Program Files\Intel\Composer XE 2011 SP1\mkl\lib\ia32" and then linked using this line:
gcc vec_example.o -o vec_example "-LC:\Program Files\Intel\Composer XE 2011 SP1\mkl\lib\ia32" "-IC:\Program Files\Intel\Composer XE 2011 SP1\mkl\include" -lsvml_dispmt

However, that gave many error messages like this one:
"
C:\Program Files\Intel\Composer XE 2011 SP1\mkl\lib\ia32/svml_dispmt.lib(D:/users/nbtester/x86win_nightly/branch-12_1/20110812_000000/dev/build_objs/qax86win
_d0p0flexlm/libobj/svml/staticmt/svml_dsincos2_la_maskiface.obj):(.text[___svml_sincos2_mask]+0x21): undefined reference to `__intel_cpu_indicator_init'
"
Any clue?
Andrey_G_Intel2
Employee
407 Views

Hello!

I don`t see any calls to MKL in your source. So, you should be able to build executable by run followinc command:
gccvec_example.c -O2 -msse2 -ffast-math -ftree-vectorize -mveclibabi=svml
Is it true?
TimP
Black Belt
407 Views

I have doubts as to whether this gcc svml option was ever implemented in MinGW. The Windows ICL libraries weren't set up with any requirement for gcc compatibility.
ploeger__lennert
Beginner
407 Views

Sorry, I was thinking that the "-mveclibabi=svml" at compilation would translate the "exp" from math.h to
a vectorized call to the Intel mkl sse instruction set, after proper linking.
So I was thinking that no explicit calls to mkl were needed in the code.
Is that not so?

Anyway,
gcc vec_example.c -O2 -msse2 -ffast-math -ftree-vectorize -mveclibabi=svml
gives
"
C:\DOCUME~1\H44B3~1.SPR\LOCALS~1\Temp\cc65Yp4X.o:vec_example.c:(.text+0x1d): undefined reference to `vmldExp2'
collect2: ld returned 1 exit status
"
ploeger__lennert
Beginner
407 Views

I should have added that I also got multiple times this warning:
"
Warning: .drectve `-defaultlib:"libirc" ' unrecognized
"
Gennady_F_Intel
Moderator
407 Views

>> So I added svml_dispmt.lib to this directory "C:\Program Files\Intel\Composer XE 2011 SP1\mkl\lib\ia32"
You need to add the following path"C:\Program Files\Intel\Composer XE 2011 SP1\compiler\lib\ia32\" where you can find all svml libs.
--Gennady
Andrey_G_Intel2
Employee
407 Views

Quoting L. Ploeger
Sorry, I was thinking that the "-mveclibabi=svml" at compilation would translate the "exp" from math.h to
a vectorized call to the Intel mkl sse instruction set, after proper linking.
So I was thinking that no explicit calls to mkl were needed in the code.
Is that not so?
"


No, that GCC option tells GCC to use svml library in vectorizer.
If you want to use exp from MKL, you need to call it manually. You need to read "Vector Mathematical Functions" chapter from Intel Math Kernel Library Reference Manual (http://software.intel.com/sites/products/documentation/hpc/mkl/updates/10.3.5/mklman/index.htm).

Andrey

ploeger__lennert
Beginner
407 Views

I don't understand what you mean, I linked to that directory:
"-LC:\Program Files\Intel\Composer XE 2011 SP1\mkl\lib\ia32"
ploeger__lennert
Beginner
407 Views

Ok, but would that make any difference with respect to speed, direct linking to mkl or using the vml library as a vectorizer?
TimP
Black Belt
407 Views

If you have the Intel compiler installed, it's difficult to see why you are attempting to link against the Intel libraries in MinGW.
My expectation would be that SVML would give you good vector speedup on shorter loops, beginning around a loop count of 50, while VML should be faster on longer loops, perhaps upwards of 1000, until you reach a length where the memory system limits performance, and then the SVML may be faster again if your exp is embedded in a loop with other calculations, taking advantage of cache locality. So, if you really want to know, or don't want to divulge sufficient data, you'll need to test it yourself.
ploeger__lennert
Beginner
407 Views

It works now. libirc.lib should be linked against, too.
So, to summarize:
gcc -c vec_example.c -O2 -msse2 -ffast-math -ftree-vectorize -mveclibabi=svml

gcc vec_example.o "-LC:\Program Files\Intel\Composer XE\compiler\lib\ia32" -lsvml_dispmt -llibirc

---> a.exe

Warning: .drectve `-defaultlib:"libirc" ' unrecognized

remains.
Reply