From: Tim Roberts on 28 Jan 2010 23:06 "Chris M. Thomasson" <no(a)spam.invalid> wrote: >"Tim Roberts" <timr(a)probo.com> wrote: > >> persres <persres(a)googlemail.com> wrote: >[...] >>>3) how do I allocate cache-aligned memory in heap?. I believe it is >>>_aligned_malloc?. Is there any C++ call? >> >> _aligned_malloc works just fine in C++. You can always use placement >> "new" >> with it: >> >> MyObject pobj = new (_aligned_malloc(sizeof MyObject)) MyObject; >> >> Note, however, that cache-aligning an object is not a terribly useful >> thing to do. > >I am curious as to what makes you say that? Padding critical data-structures >to L2 cache lines and aligning them in memory on cache line boundaries can >be __essential__ if you are interested in scalability and performance. I am being too obscure. Aligning arrays and data structures is clearly a vital tactic in high performace applications. However, C++ objects often have extra "surprises" that add an extra element. -- Tim Roberts, timr(a)probo.com Providenza & Boekelheide, Inc. |