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

ippsMalloc question

jcamin
Beginner
604 Views

I have a fairly fundamental noob question I cant seem to find an answer to. I need to copy portions of one array to another array. Can I do the following, or will it give inconsistant results with aligned memory? Fundamentally, I'm interested in understanding how aligned memory is accessed. And specifically, I am doing an overlap/save convolution where I need to save off a chunk of one vector to be saved and then added to another vector later. Thanks!

int N1 = 200, N2 = 100;

Ipp32f init = 1.0;

Ipp32f* pSrc = ippsMalloc_32f(N1);

Ipp32f* pDst = ippsMalloc_32f(N2);

ippsSet_32f(init, pSrc, N1);

ippsZero_32f(pDst, N2);

// Important question: is this valid?

ippsCopy_32f(pSrc+N2, pDst, N2); //????

0 Kudos
6 Replies
Vladimir_Dudnik
Employee
604 Views
Hello,

IPP memory allocation functions provide you 32-bytes aligned memory buffer in transparent manner. You just got aligned pSrc and pDst pointers. Of course you are able to copy part of this buffer into another place. IPP copy function will process both aligned and unaligned buffers.

Regards,
Vladimir
0 Kudos
jcamin
Beginner
604 Views
Great, thanks for the quick reply! I hoped that was the case, as my experimental programs indicated such. But I wanted to verify that it wasnt just coincidence.

Thanks again!
0 Kudos
Gaiger_Chen
New Contributor I
604 Views
Hi

May I ask what is the different between ippsMalloc/ippsFree and malloc/free ?

Ipp8u* pBuf = ippsMalloc_8u(8);

ippsFree(pBuf);

is lookly same as

Ipp8u* pBuf = (Ipp8u*)malloc(8*sizeof(Ipp8u));

ippsFree(pBuf);


so, why we should use ippsMalloc/ippsFree instead of using standard C funcion ?

Is there bonus beware to using ipp allocating/delocating memory function?

(more fast or always crash when pointer out of bound...etc)
thank you !!



0 Kudos
Gennady_F_Intel
Moderator
604 Views
so, why we should use ippsMalloc/ippsFree instead of using standard C funcion ?
Is there bonus beware to using ipp allocating/delocating memory function?
That's because of the performance of IPP functions can be significantly different when the operation with aligned or unaligned data...
Access to memory is faster if pointers to the data are aligned.
--Gennady
0 Kudos
Vladimir_Dudnik
Employee
604 Views
That's right. As Gennady mentioned, IPP memory allocation functions provide 32-bytes aligned buffer. Except that there is no difference between C run time malloc and IPP variant. Moreover, IPP memory allocation internally based on malloc. They just allocate a little bit bigger buffer, and return you 32-bytes aligned pointer inside of this buffer. That is why you need to call IPP memory deallocation functon, which know where the original pointer is located.

Regards,
Vladimir
0 Kudos
Gaiger_Chen
New Contributor I
604 Views
thank you two, I have more recognized SSE properties now.

just as wiki said :


http://en.wikipedia.org/wiki/Data_structure_alignment , the varible "align" is 32 in IPP.

0 Kudos
Reply