Memory Alignment

Access to memory is faster if pointers to the data are aligned, and Intel IPP functions perform better if they process data with aligned pointers.

The following Intel IPP functions can be used for pointer alignment, memory allocation and deallocation:

     void* ippAlignPtr(void* ptr, int alignBytes)

          Aligns a pointer, can align to the powers of 2, that is 2, 4, 8, 16 and so on.

      void* ippMalloc(int length)

          32-byte aligned memory allocation. Memory can be freed only with the function ippFree.

     void ippFree(void* ptr)

          frees memory allocated by the function ippMalloc.

     Ipp<datatype>* ippsMalloc_<datatype>(int len)

          32-byte aligned memory allocation for signal elements of different data types. Memory can be freed only with the function ippsFree.

     void ippsFree(void* ptr)

          Frees memory allocated by the function 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. Memory can be freed only with the function ippiFree.

      void ippiFree(void* ptr) -

          Frees memory allocated by the function ippiMalloc.

The amount of memory that can be allocated is determined by the operating system and system hardware, but it cannot exceed 2GB.

Caution iconCaution

The followint code example shows how to call the function ippiMalloc.

Calling the Function ippiMalloc

                #include "stdafx.h"
                #include "ipp.h"
                #include "tools.h"
                
                int main(int argc, char *argv[])
                {
                   IppiSize size = {320, 240};
                
                   int stride;
                   Ipp8u* pSrc = ippiMalloc_8u_C3(size.width, size.height, &stride);
                   ippiImageJaehne_8u_C3R(pSrc, stride, size);
                   ipView_8u_C3R(pSrc, stride, size, "Source image", 0);
                
                   int dstStride;
                   Ipp8u* pDst = ippiMalloc_8u_C3(size.width, size.height, &dstStride);
                   ippiCopy_8u_C3R(pSrc, stride, pDst, dstStride, size);
                   ipView_8u_C3R(pDst, dstStride, size, "Destination image 1", 0);
                
                   IppiSize ROISize = { size.width/2, size.height/2 };
                   ippiCopy_8u_C3R(pSrc, stride, pDst, dstStride, ROISize);
                   ipView_8u_C3R(pDst, dstStride, ROISize, "Destination image, small", 0);
                
                   IppiPoint srcOffset = { size.width/4, size.height/4 };
                   ippiCopy_8u_C3R(pSrc + srcOffset.x*3 + srcOffset.y*stride, stride,
                      pDst, dstStride, ROISize);
                   ipView_8u_C3R(pDst, dstStride, ROISize, "Destination image, small & shifted", 1);
                
                   return 0;
                }
                

Optimization Notice

The Intel® Integrated Performance Primitives (Intel® IPP) library contains functions that are more highly optimized for Intel microprocessors than for other microprocessors. While the functions in the Intel® IPP library offer optimizations for both Intel and Intel-compatible microprocessors, depending on your code and other factors, you will likely get extra performance on Intel microprocessors.

While the paragraph above describes the basic optimization approach for the Intel® IPP library as a whole, the library may or may not be optimized to the same degree for non-Intel microprocessors for optimizations that are not unique to Intel microprocessors. These optimizations include Intel® Streaming SIMD Extensions 2 (Intel® SSE2), Intel® Streaming SIMD Extensions 3 (Intel® SSE3), and Supplemental Streaming SIMD Extensions 3 (Intel® SSSE3) instruction sets and other optimizations. Intel does not guarantee the availability, functionality, or effectiveness of any optimization on microprocessors not manufactured by Intel. Microprocessor-dependent optimizations in this product are intended for use with Intel microprocessors.

Intel recommends that you evaluate other library products to determine which best meets your requirements.


Submit feedback on this help topic

Copyright © 2008 - 2010, Intel Corporation. All rights reserved.