OpenCL zerocopy

Zero-copy!

This is both CPU and GPU main memory. How to avoid copying buffers from and to the same memory?

Allocate aligned memory

// note: buffer_size is re-written in place
void *zerocopy_alloc(size_t &buffer_size)
{
    // OpenCL zero-copy buffers need to be aligned on a page size (i.e., 4KB),
    // and the allocated size to be a multiple of a cach line (i.e., 64 bytes).

    const uint32_t size_mult = 64;
    if(buffer_size % size_mult != 0)
    {
        buffer_size += size_mult - (buffer_size % size_mult);
    }
    aligned_alloc(4096, buffer_size);
}