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

In-place operation with ippsAdd_32u

attemarkus
Beginner
327 Views
Hi,

There is not in-place function ippsAdd_32u_I.

Nevertheless is it allowed to to use same source and destination array ?:

Ipp32u a[5];
Ipp32u b[5];

ippsAdd_32u( a, b, b, 5 )

Best regards,
Markus
0 Kudos
1 Solution
Vladimir_Dudnik
Employee
327 Views
Hi Markus,

we do separate in-place and out-of-place functions at API level specifically to allow optimized code do not worry about arrays overlapping for out-of-place case. This allow to achieve additional performance benefits. Although forsome particular functions and particular cpu-specific optimization out-of-place case could work the same way as in-place caseit is notguaranteed.

Regards,
Vladimir

View solution in original post

0 Kudos
3 Replies
Naveen_G_Intel
Employee
327 Views

Hi,

I think not possible to use same source and destination array for not in-place function ippsAdd_32u.

As mentioned in the documentation, pSrcDst is Pointer to the source and destination vector for in-place operation.

Good question.

Regards,

Naveen Gv

0 Kudos
attemarkus
Beginner
327 Views
Hi,

Actually I did some testing and it is working but should I expect to have some undefined behaviour sometimes ?

output:

u32a
1 2 3 4 5 6 7 8 9 10

u32b
1 4 9 16 25 36 49 64 81 100

ippStsNoErr: No error, it's OK

result u32b
2 6 12 20 30 42 56 72 90 110


code:

const int len = 10;

Ipp32u * u32a = ippsMalloc_32u( len );
Ipp32u * u32b = ippsMalloc_32u( len );

for( int i=0; i < len; i++ )
{
u32a = i+1;
u32b = ( i+1 ) * ( i+1 );
}

cout << "u32a" << endl;
for( int i=0; i < len; i++ )
{
cout << u32a << " ";
}
cout << endl << endl;

cout << "u32b" << endl;
for( int i=0; i < len; i++ )
{
cout << u32b << " ";
}
cout << endl << endl;

IppStatus st = ippsAdd_32u( u32a, u32b, u32b, len );
cout << ippGetStatusString( st ) << endl << endl;


cout << "result u32b" << endl;
for( int i=0; i < len; i++ )
{
cout << u32b << " ";
}
cout << endl << endl;

Best regards,
Markus
0 Kudos
Vladimir_Dudnik
Employee
328 Views
Hi Markus,

we do separate in-place and out-of-place functions at API level specifically to allow optimized code do not worry about arrays overlapping for out-of-place case. This allow to achieve additional performance benefits. Although forsome particular functions and particular cpu-specific optimization out-of-place case could work the same way as in-place caseit is notguaranteed.

Regards,
Vladimir
0 Kudos
Reply