Performance Tools for Software Developers - Memory Function FAQ

Submit New Article

Last Modified On :   November 25, 2009 10:52 PM PST
Rate
 


What are the Intel® IPP memory functions?
The Intel® IPP provides easy to use functions for pointer alignment, memory allocation and deallocation:

Function Purpose Notes
void* ippAlignPtr( void* ptr, int alignBytes ); Aligns a pointer Can align to 2/4/8/16/…
void* ippMalloc( int length ); 32-byte aligned memory allocation Can only free memory with ippFree
void ippFree( void* ptr ); Free memory allocated by ippMalloc Can only free memory allocated by ippMalloc
Ipp<datatype>* ippsMalloc_<datatype>( int len ); 32-byte aligned memory allocation
for signal elements of different data types
Can only free memory with ippsFree
void ippsFree( void* ptr ); Free memory allocated by ippsMalloc Can only free memory allocated by ippsMalloc
Ipp<datatype>* ippiMalloc_<mod>(int widthPixels, int heightPixels,
int* pStepBytes);
32-byte aligned memory allocation for images
where every line of the image is padded with zeros
Can only free memory with ippiFree
void ippiFree( void* ptr ); Frees memory allocated by ippiMalloc Can only free memory allocated by ippiMalloc

How are Intel IPP memory functions different from the standard malloc and free functions?
Intel IPP memory functions align the memory to a 32-byte boundary for optimal performance on Intel architecture.

How do I call ippsMalloc or ippiMalloc?
Please take a look at our examples for:

What is the maximum amount of memory that can be allocated by Intel IPP functions?
There are no restrictions to the amount of memory that can be allocated except as defined by the the user's operating system and system hardware.

How do I deallocate memory?
Use the corresponding Intel IPP memory deallocation functions: ippFree, ippsFree and ippiFree. These functions cannot be used to free memory allocated by standard functions like malloc or calloc; nor can the memory allocated by the Intel IPP malloc functions be freed by the standard function free.

What is the advantage of using ipp*Malloc functions?
Intel IPP functions can perform better on aligned data. By calling an ipp*Malloc functions to allocate data, the data is aligned for optimal performance on your Intel processor.

Why should memory be aligned?
Processor pipeline stalls occur when memory is accessed on the cache-line boundary. Alignment of memory buffers is used in order to minimize such occurrences. Please check the Intel® Software Network to access Software Optimization Guides for your Intel processor.

How is the image stride or step used when calling ippiMalloc?
Image stride or step is the number of bytes in one row of the image. The ippiMalloc function takes the width and height of the image in pixels as arguments and returns the memory stride in bytes and a pointer to the memory. The size of the memory allocated is not known until after the function call; then it can be calculated as:

memSize = stride * height * numChannels;
Examples:
  • The function ippiMalloc_8u_C3 first sets the stride to the smallest multiple of 32 that is greater than width * numChannels. Then the function allocates stride * height bytes.
  • The function ippiMalloc_32f_C3, which allocates 32-bit floating-point pixels, sets the stride to the smallest multiple of 32 that is greater than width * numChannels * bytesPerChannel .

Is there any difference between IppMalloc /IppFree() and IppsMalloc/IppsFree() functions?
Basically there is no difference between these functions. Both allocating array of bytes (where for example ippsMalloc_16s allocates array of short integers) and both provide the same alignment for allocated buffer.
It is recommended you use corresponding free functions, ippFree for ippMalloc and ippsFree for all ippsMalloc variants. To get more information about these functions refer to IPP User Guide or IPP Reference Manuals.
http://software.intel.com/en-us/articles/intel-integrated-performance-primitives-documentation/

Is there any requirement for Intel® IPP functions to use memory only allocated through ippMalloc?
No, Intel® IPP functions does not require that memory should be allocated only with Intel® IPP functions. You also may use CRT malloc or any other memory manager API. In that case you have to care about alignment by yourself if you want to maximize calculation speed.

Operating System:

Windows Server* 2003 Enterprise x64 Edition, Mac OS*, Red Hat* Enterprise Linux 2.1, SUSE* Linux Enterprise Server 8.0, SUSE* Linux Enterprise Server 9.0, Windows* XP Professional, Red Hat* Linux 7.3, Red Hat* Linux 8.0, Windows Server* 2003, Red Hat* Linux 9.0, Red Hat* Enterprise Linux 3.0, Windows* XP 64-Bit Edition Version 2003




This article applies to: Intel® Integrated Performance Primitives Knowledge Base