pyopencl - Is the device address of a buffer the same for different kernels/programs in OpenCL -
When passing buffers as the argument of OpenCL kernel, buffer is detected by the kernel code buffer?
I used to check the code below and it seems that the address is actually the same. However, I can not get anything in the standard to guarantee this.
Import np def main (as moist imports as pyopencl): ctx = cl.create_some_context () queue = cl.CommandQueue (Ctx) mf = cl.mem_flags buf = cl in .Buffer (ctx, mf.READ_ONLY, 1000) buf2 = cl.Buffer (ctx, mf.READ_WRITE, 8) PRG = cl.Program (ctx, "" "__krnl zero get_addr (__global const int *, __global long out) {* out = (long);} "" ") .build () knl = prg.get_addr knl.set_args (buf, buf2) cl.enqueue_task (Qi, knl) B = np.empty ([1] , Dtype = np.int64) cl.enqueue_copy (qi, b, buff 2). Watts () Print (B [0]) PRG = CL. Program (Sitiaks, "" "__krnl zero get_addr (__ global const int * in, __global out long) {* out = (long);}" "") .build () knl = prg.get_addr knl.set_args (buf, buf2) cl.enqueue_task (queue), Knl) b = np.empty ([1], dtype = np.int64) cl.enqueue_copy (queue, b, buf2). Wait () print (b [0]) If __name__ == '__main__': main () Use the matter is that I am running a simulation using Opansiel which equals (Arrays) is equal ameters. In order to pass these arrays in the form of logic, I fill them in a straight and give the point around the structure around it. Since this structure will be used many times (and by all work items) I would not like to fill it in every part of every kernel and I would like to know that indicators will change between different run / working items.
This is not guaranteed for OpenCL 1.x. This is why it is unsafe to store pointers in buffers, runtime is allowed to move allocation for each kernel launch. There is no guarantee that he will move it, and of course it is worthwhile to expect that buffer will not need to be moved often, so it is not surprising that you will see results seeing. If you allocate lots of buffers and force them to run the cycle, then they will be more likely to see this problem.
The shared virtual memory feature for OpenCL 2.0 guarantees through this definition: If the address can not be shared when it is changed.
Comments
Post a Comment