Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.

New user: overwhelmed

chuck37
Beginner
1,041 Views

Let me start by saying that I'm not a software programmer by trade, I'm using C as a tool to get some work done. I've got a computationally intensive program that I'm trying to speed up, and it's based around FFTW3 and fftw_complex variable type. I'm working on a quad-core 64 bit machine. I have a few really dumb questions.

My install of MKL is local to me, which makes things more painful.

I've written a really basic test program to attempt to use some of the vector math functionality. I chose to try MulByConj. I'm having a heck of a time figuring out what stuff I need to #include in the program, and what stuff I need to link with the (gcc) compile. Can someone help me out?

The next thing is, how do I reconcile FFTW_COMPLEX type with MKL_complex16 type? FFTW_Complex is compatible with functions like "conj", "cexp" and so on, as well as the usage of the value "I". These functions don't appear to be happy with MKL_complex. Or is this just because I don't have things linked and compiled correctly?

Here's the flavor of what I was trying. I know it's still dumb, but just a comparison of old way vs. new way:

int main()
{
static MKL_Complex16 big1[8192], big2[8192], big3[8192];
int x;

for (x=0;x<8192;x++)
{
big1=53217.1237*(cos(0.73412894791273*x)+I*sin(0.2342356*x));
big2=8517.1237*(cos(0.77432894791273*x)+I*sin(0.26542356*x));
}

system ("date");

for (x=0;x<8192;x++)
{
big3=big1*conj(big2);
}

system ("date");

vzMulByConj(8192,big1,big2,big3);

system ("date");

}

Like I said, I'm stumped on what to include and what to link. Thanks for any help.

0 Kudos
7 Replies
chuck37
Beginner
1,041 Views

Hi chuck37,

What MKL version are you using? Please find MKL_ROOTdocmklsupport.txt file and provide Package ID string.

Ican send to you the test case where you can see how to use vzMulByConj and MKL Complex data types by properly way and makefile for building this test.

--Gennady


I've got l_mkl_p_10.0.4.023. Thanks for the help.

0 Kudos
chuck37
Beginner
1,041 Views

I simplified my program and got it to compile with some random trial and error. I'm seeing no speedup with VML versus brute force for loops:

#include "/accts/cemcdowe/intel/mkl/10.0.4.023/include/mkl.h"

#include "/accts/cemcdowe/intel/mkl/10.0.4.023/include/mkl_vml.h"

int main()

{

static double big1[67000000], big2[67000000], big3[67000000];

int x,y;

for (x=0;x<67000000;x++)

{

big1=53217.1237*(cos(0.73412894791273*x));

big2=8517.1237*(cos(0.77432894791273*x));

}

system ("date");

for (y=0;y<100;y++){

for (x=0;x<67000000;x++)

{

big3=big1*big2;

}

}

system ("date");

for (y=0;y<100;y++){

vdMul(67000000,big1,big2,big3);

}

system ("date");

}

I compiled like:

gcc mkl_test.c -lpthread -L/mkl/10.0.4.023/lib/em64t -lmkl_em64t -lmkl_core -lm -o mkl_test

Am I doing something wrong? Shouldn't I get some speedup?

0 Kudos
Gennady_F_Intel
Moderator
1,041 Views
Hi Chuck37,
if you works on em64 system - I 've uploaded to this thread Makefile.
Please pay attention on libguide.a (out threading library) you didn't link previous time.
--Gennady

0 Kudos
chuck37
Beginner
1,041 Views
Quoting - Gennady Fedorov
Hi Chuck37,
if you works on em64 system - I 've uploaded to this thread Makefile.
Please pay attention on libguide.a (out threading library) you didn't link previous time.
--Gennady

Thanks for the reply, but I'm confused, is there a file someplace I should be able to see/access?

Incidentally, I got a complex number example to work, and the vector implementation took at least twice as long:

[c-sharp]
[/c-sharp]
[c-sharp]

#define M 128

#define N 3276800

int main()

{

static MKL_Complex16 big1, big2, big3;

int x,y;

for (x=0;x

{

big1.real=53217.1237*cos(0.73412894791273*x);

big1.imag=53217.1237*cos(0.54812894791273*x);

big2.real=8517.1237*cos(0.77432894791273*x);

big2.imag=82359.7923*cos(0.8592894791273*x);

}

system ("date");

for (y=0;y

{

for (x=0;x

{

big3.real=big1.real*big2.real-big1.imag*big2.imag;

big3.imag=big1.real*big2.imag+big1.imag*big2.real;

}

}

system ("date");

for (y=0;y

{

vzMul(M,big1,big2,big3);

}

system ("date");

}

What the heck is going on? I'll try adding the thread linking like you suggest, but I want to compare apples to apples. My code is already threaded; I want to see what I can get from the MKL functions.

By the way, I can't figure out how to post legibly on this forum! All the indents are stripped from my code, and the syntax highlighter thing truncates 75% of what I paste into it. Now I have no line breaks, and there is no way to preview.

Thanks for the help though.

[/c-sharp]

0 Kudos
chuck37
Beginner
1,041 Views
Sorry about that last post. This forum software seems to defy all forum software conventions. Here's another paste of the code that shows vzMul taking 2-3x as long as regular for loops. I tried numerous different values for M and N and it's always worse with vzMul:

#define M 128

#define N 3276800

int main()

{

static MKL_Complex16 big1, big2, big3;

int x,y;

for (x=0;x

{

big1.real=53217.1237*cos(0.73412894791273*x);

big1.imag=53217.1237*cos(0.54812894791273*x);

big2.real=8517.1237*cos(0.77432894791273*x);

big2.imag=82359.7923*cos(0.8592894791273*x);

}

system ("date");

for (y=0;y

{

for (x=0;x

{

big3.real=big1.real*big2.real-big1.imag*big2.imag;

big3.imag=big1.real*big2.imag+big1.imag*big2.real;

}

}

system ("date");

for (y=0;y

{

vzMul(M,big1,big2,big3);

}

system ("date");

}

0 Kudos
Gennady_F_Intel
Moderator
1,041 Views

Chuck,

We are updating our forum page so sometimes we are expecting some errors,

but nevertheless, below I snip from makefile I sent you in previous message:

+++++++++++++++++++++++++++++++++++++++++++

MKLINCLUDE=/opt/intel/mkl/10.0.4.023/include

MKLROOT=/opt/intel/mkl/10.0.4.023/lib/em64t

all:

gcc -w mkl_test.c -I ${MKLINCLUDE} ${MKLROOT}/libmkl_intel_lp64.a ${MKLROOT}/libmkl_intel_thread.a ${MKLROOT}/libmkl_core.a ${MKLROOT}/libguide.a -lpthread -lm -o test.out

clean:

rm -f *.x *.mod

+++++++++++++++++++++++++++++++++++++++++++

Please try to use this link and let me know the result.

--Gennady

0 Kudos
chuck37
Beginner
1,041 Views

Chuck,

We are updating our forum page so sometimes we are expecting some errors,

but nevertheless, below I snip from makefile I sent you in previous message:

+++++++++++++++++++++++++++++++++++++++++++

MKLINCLUDE=/opt/intel/mkl/10.0.4.023/include

MKLROOT=/opt/intel/mkl/10.0.4.023/lib/em64t

all:

gcc -w mkl_test.c -I ${MKLINCLUDE} ${MKLROOT}/libmkl_intel_lp64.a ${MKLROOT}/libmkl_intel_thread.a ${MKLROOT}/libmkl_core.a ${MKLROOT}/libguide.a -lpthread -lm -o test.out

clean:

rm -f *.x *.mod

+++++++++++++++++++++++++++++++++++++++++++

Please try to use this link and let me know the result.

--Gennady

That worked, thanks!

0 Kudos
Reply