IntroductionThe Intel® Integrated Performance Primitives (Intel® IPP) is a cross-architecture software library that provides a broad range of library functions for image processing, signal processing, data compression, cryptography, and computer vision, as well as math support routines for such processing capabilities. Intel® IPP is optimized for the wide range of Intel microprocessors. One of the key advantages within Intel® IPP is performance coming through highly optimized functions and resource management including memory management. This paper covers the different flavors of those functions in IPP dealing with memory allocation, deallocation, and alignment. After reading this article you should be able to use the correct memory allocation functions for your specific needs. Further documentation on Intel® IPP can be found at Intel® Integrated Performance Primitives – Documentation. What are the Intel® IPP memory functions?The Intel® IPP provides easy to use functions for pointer alignment, memory allocation and deallocation:
How are Intel IPP memory functions different from the standard malloc and free functions?Intel IPP memory functions align the memory to a 64-byte boundary for optimal performance on Intel architecture. How do I call ippsMalloc or ippiMalloc?Please take a look at the examples in the manual. void func_malloc(void) { Ipp8u* pBuf = ippsMalloc_8u(8*sizeof(Ipp8u)); if (NULL == pBuf) { // not enough memory ippsFree(pBuf); } } Example 3-2: Using the function ippsMalloc. ippiMalloc from Source Code Examples from Intel IPP book* (including the whole example project) What is the maximum amount of memory that can be allocated by Intel IPP functions?We expect that 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. For memory allocations beyond 2 GB on 64-bit systems the platform-aware (e.g. ippsMalloc_<datatype>_L, ippiMalloc_<mod>_L) have to be used instead. Those functions are available since IPP 2017. It is good practice to use platform-aware functions. 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® Developer Zone 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:
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. 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.
* Other names and brands may be claimed as the property of others. Microsoft, Windows, and the Windows logo are trademarks, or registered trademarks of Microsoft Corporation in the United States and/or other countries.
Copyright © 2002-2016, Intel Corporation. All rights reserved. |
↧
Intel® IPP Memory Function ippMalloc/Free FAQ
↧