| OGRE 1.11.1 Object-Oriented Graphics Rendering Engine

Static Public Member Functions | List of all members
Ogre::AlignedMemory Class Reference
Core » General

Class to provide aligned memory allocate functionality. More...

`#include <OgreAlignedAllocator.h>`

## Static Public Member Functions
static DECL_MALLOC void * | allocate (size_t size, size_t alignment)
| Allocate memory with given alignment. More...
static DECL_MALLOC void * | allocate (size_t size)
| Allocate memory with default platform dependent alignment. More...
static void | deallocate (void *p)
| Deallocate memory that allocated by this class. More...

## Detailed Description

Class to provide aligned memory allocate functionality.

Remarks
  All SIMD processing are friendly with aligned memory, and some SIMD routines are designed for working with aligned memory only. If the data are intended to use SIMD processing, it's need to be aligned for better performance boost. In additional, most time cache boundary aligned data also lead to better performance even if didn't used SIMD processing. So this class provides a couple of functions for allocate aligned memory.

  Anyways, in general, you don't need to use this class directly, Ogre internally will take care with most SIMD and cache friendly optimisation if possible.

  This isn't a "one-step" optimisation, there are a lot of underlying work to achieve performance boost. If you didn't know what are you doing or what there are going, just ignore this class.

Note
  This class intended to use by advanced user only.

## Member Function Documentation

## ◆ allocate() [1/2]

static DECL_MALLOC void* Ogre::AlignedMemory::allocate | ( | size_t | size,
|  | size_t | alignment
| ) |  |
| static

Allocate memory with given alignment.

Parameters

  size | The size of memory need to allocate.
  alignment | The alignment of result pointer, must be power of two and in range [1, 128].

Returns
  The allocated memory pointer.

  On failure, exception will be throw.

Referenced by Ogre::AlignedAllocator< T, Alignment >::allocate().

## ◆ allocate() [2/2]

static DECL_MALLOC void* Ogre::AlignedMemory::allocate | ( | size_t | size | ) |
| static

Allocate memory with default platform dependent alignment.

Remarks
  The default alignment depend on target machine, this function guarantee aligned memory according with SIMD processing and cache boundary friendly.

Parameters

  size | The size of memory need to allocate.

Returns
  The allocated memory pointer.

  On failure, exception will be throw.

## ◆ deallocate()

static void Ogre::AlignedMemory::deallocate | ( | void * | p | ) |
| static

Deallocate memory that allocated by this class.

Parameters

  p | Pointer to the memory allocated by this class or NULL pointer.

  On NULL pointer, nothing happen.

Referenced by Ogre::AlignedAllocator< T, Alignment >::deallocate().

The documentation for this class was generated from the following file:

- OgreAlignedAllocator.h