On Sunday, 22 January 2017 at 00:13:10 UTC, Chris Wright wrote:
On Sat, 21 Jan 2017 22:44:49 +0000, bitwise wrote:
So I use a custom aligned allocator:

template <class T, int ALIGN>
class AlignedAllocator {
     T* allocate(size_type n) {
         return (T*)_aligned_malloc(ALIGN, n * sizeof(T));
     }
};

SIMD operations(aligned load and store) can now safely be used on the contents of the std::vector<Vec4>.


alignedAllocate() is for when the code consuming the allocator knows more about alignment needs than whoever is supplying the allocator, which is more likely to crop up with coarse-grained allocator control.

I understand this, but I've given a solid example which supports the former, and haven't seen a counter example which supports the latter.


Reply via email to