Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

problem of using IPP in C#

Liang_Wen
Beginner
785 Views

a little question when using IPP.

just migrate these code to C#:

void mulpack( void ) {
Ipp32f xMusic, XMusic, hMusic={1.0f/3,1.0f/3,1.0f/3,0,0,0,0,0}, HMusic;
IppStatus st;
IppsFFTSpec_R_32f* spec;
st = ippsFFTInitAlloc_R_32f(&spec, 3, IPP_FFT_DIV_INV_BY_N,
ippAlgHintNone);
ippsSet_32f( 3, x, 8 );
x[3] = 5;
st = ippsFFTFwd_RToPack_32f( x, X, spec, NULL );
st = ippsFFTFwd_RToPack_32f( h, H, spec, NULL );
ippsMulPack_32f_I( H, X, 8 );
st = ippsFFTInv_PackToR_32f( X, x, spec, NULL );
printf_32f("filtered =", x, 8, st );
ippsFFTFree_R_32f( spec );
}

this is if from mannual of intel.

the warpper is here:

[SuppressUnmanagedCodeSecurityAttribute()]
[DllImport(ipp.sp.libname)] public static extern
IppStatus ippsFFTInitAlloc_R_32f ( IppsFFTSpec_R_32f **pFFTSpec, int order, int flag, IppHintAlgorithm hint );

then , it is difficult to transfer IppsFFTSpec_R_32f **pFFTSpec for me.

ipp.IppsFFTSpec_R_32f[] spec = new ipp.IppsFFTSpec_R_32f[length];
fixed (ipp.IppsFFTSpec_R_32f* pspec = spec)
{
//ipp.IppsFFTSpec_R_32f** ppspec = pspec;
&nbs p; ipp.IppsFFTSpec_R_32f** ppspec = (ipp.IppsFFTSpec_R_32f**)pspec;

st = ipp.sp.ippsFFTInitAlloc_R_32f(ppspec, 3, 0, ipp.IppHintAlgorithm.ippAlgHintNone);

//st = ipp.sp.ippsFFTInitAlloc_R_32f(&pspec, 3, 0, ipp.IppHintAlgorithm.ippAlgHintNone);
}

i get an error said "can'tget addr ofread only variable "...

maybe , i use it in a wrong way.anybody kind enough to tell me the correct way??

thanks...

0 Kudos
2 Replies
Vladimir_Dudnik
Employee
785 Views

Hello,

our expert did changes in your code to make it work

IppsFFTSpec_R_32f spec = new IppsFFTSpec_R_32f();

IppsFFTSpec_R_32f* pSpec = &spec;

float[] h = {1.0f/3, 1.0f/3 ,1.0f/3 ,0 ,0 ,0 ,0 , 0}, x = {0,0,0,0,0,0,0,0}, X = {0,0,0,0,0,0,0,0}, H = {0,0,0,0,0,0,0,0};

IppStatus st;

st = sp.ippsFFTInitAlloc_R_32f(&pSpec,3,IPP_FFT_DIV_INV_BY_N,IppHintAlgorithm.ippAlgHintNone);

fixed( float* px = x, pX = X, ph = h, pH = H )

{

st = sp.ippsSet_32f(3.0f, px, 8 );

x[3] = 5.0f;

st = sp.ippsFFTFwd_RToPack_32f(px, pX, pSpec, null);

st = sp.ippsFFTFwd_RToPack_32f(ph, pH, pSpec, null);

st = sp.ippsMulPack_32f_I(pH, pX, 8);

st = sp.ippsFFTInv_PackToR_32f(pX, px, pSpec, null);

}

sp.ippsFFTFree_R_32f(pSpec);

Regards,
Vladimir

0 Kudos
bodyguard
Beginner
785 Views
Hi Thanks for the code with corrections,

It worked very well.

Thanks Alot
bodyguard
0 Kudos
Reply