C / C ++ - posix_memalign ()

I read a little about optimizing cache misses and learned this stdlib function. It does some kind of memory alignment for optimization, but can someone help me explain what this function really does? It takes 3 arguments: void * * memptr, size_t alignment, size_t size

The part that I do not receive means that the documentation means

"selected byte of size aligned to the boundary specified by alignment ..."

What I understood from reading is the type of memory block allocation function with size size, but after that I donโ€™t understand what they mean by โ€œborderโ€ . Is a memory block scattered into a smaller piece with alignment size?

Here is the documentation: http://www.opengroup.org/onlinepubs/9699919799/functions/posix_memalign.html

+5
source share
1 answer

I read a little about optimizing cache misses and learned this stdlib function. It does some kind of memory alignment for optimization, but can someone help me explain what this function really does?

The main purpose of the function is to allocate a buffer aligned to the size of the page. This is rarely done for performance - usually because you need a buffer that is suitable for a device driver or direct access to hardware.

. . - char, short, int, long - ( ) : ( struct field) . . (, char a; int b; a, sizeof(char)-sizeof(int) , , b sizeof(b).)

, ""... ?

H/W- ( -PCI) N N . , " ".

, , . , - . , :

  • , . . , , . ( , .) , , , , , . malloc() , - , TLB . ( .)

  • . , , " ". . , - . DRAM/DDR 16 . (32 64 ), . ( ): , , , , . std::map< struct aaa *, void * >. struct aaa , , , ( ), . , . , . -, . , .

, . , . . Intel .

+8

All Articles