It seems that i can not use the same memory buffer to read data first and then - write data to the same buffer, like in CUDA. I can not read from out buffers and write to not-out buffers, is it correct? Thanks
This restriction is implemented to avoid data races inside kernel.
You can disable this constaint if you set environment variable BRT_PERMIT_READ_WRITE_ALIASING
so, BRT_PERMIT_READ_WRITE_ALIASING leads to less-efitiency of memory use?
for example if i do some-thing like this
kernel void my_kernel(out float4 buffer[][]) { float4 x = read_data(buffer[tid]); ..// long computations; ~ 100-200 mads buffer[tid] = result; } // Is it worse than two separate buffers? // and what about this? kernel void my_kernel(out float4 buffer<>) { float4 x = read_data(buffer); ..// long computations; ~ 100-200 mads buffer = result; }
This won't work. Instead you should use kernel with two streams and call it with the same stream argument. Something like this-
kernel void test(float input<>, out output<>
{
}
// call from host
test(a, a);
ok, i see. So, what about efficiency. I suppose this is bad idea, right? - to use the same buffer for read and write? If we, for example have ~100-200 mads between read and write?