[Insight-users] Custom Memory Allocators

Panagiotis Foteinos panagiotis.foteinos at gmail.com
Sun Dec 9 16:00:44 EST 2012


Greetings.

I am building a shared memory parallel application, and I would like
to create a read-only image per core/thread such that its
corresponding cache lines are accessed only if a core needs to access
the image. In other words, I am trying to solve the false sharing
problem, where a thread invalidates these read-only cache lines simply
because it wrote a shared variable that belonged to the cache lines of
the read-only image.


The function posix_memalign can align a memory block on the boundary
of a cache line and can pad extra space at the end, such that the
block is never used for storing any other variable. I would like to
use this function and create a read-only image. It seems, however,
that the functions itk::Image::New() and itk::Image::Allocate cannot
be overloaded and accept my own "memory buffer". In other words, I
would like to be able to the following (pseudo-code follows):


void* buffer = posix_memalign(64,
64*ceil(number_of_voxels*PixelType/64.0) ); //now buffer points to
contiguous memory that will ocuppy multiples of cache lines.

itkImage->Allocate(buffer); //take space from the buffer and not from
the system's heap.



Is something like that possible?



Regards,
Panagiotis Foteinos


More information about the Insight-users mailing list