shinpei0208 / gdev

First-Class GPU Resource Management: Device Drivers, Runtimes, and CUDA Compilers for Nouveau.
http://www.pdsl.jp/
MIT License
344 stars 68 forks source link

Passing a value to running kernel #10

Closed GoelDeepak closed 12 years ago

GoelDeepak commented 12 years ago

I know that sometime back gdev was not supporting passing a value from CPU(host) to GPU(device) while GPU kernel is running via zero-copy memory. Is this support now?

wkbjerry commented 12 years ago

What do you mean by passing a value? You mean, copying data to a GPU memory object while some kernel, which is in the same context with the memory object being written, is executing?

You cannot do that with current implementation since all memory objects in a context are locked when a kernel in that context is executing. But it is certainly doable by revising GDev for your need to allow such operation to happen.

shinpei0208 commented 12 years ago

I think you are talking about asynchronous memory copy. It is technically possible, and Gdev has its all basic implementation, but you need a little modification to make it work. Do you need this functionality?

shinpei0208 commented 12 years ago

By the way, zero-copy and asynchronous memory copy are not identical. Gdev supports zero-copy between the GPU and I/O devices.

GoelDeepak commented 12 years ago

I am talking about zero-copy memory where a cuda kernel can directly access the pinned memory of the host. I am trying to create a communication channel between the GPU kernel and the CPU process (which initiated the kernel). As a simple example, lets say there are two integer arrays d2h, h2d which are allocated from zero-copy memory so that both CPU process and GPU kernel can access it. Now, kernel sends a message by writing an integer value in d2h array which is read by the CPU process. After reading the value, CPU process responses by writing a different value in h2d array. This value should be read by the kernel and so on... When I tried doing this, I observed that CPU process saw the value written by GPU kernel in d2h array but GPU kernel is not seeing the value written by CPU process in h2d array. At all time both CPU process and GPU kernel are running on their respective processors.

I just assumed that zero-copy memory is available to both GPU and CPU. Is my assumption correct?

GoelDeepak commented 12 years ago

[SOLVED] It worked after I used "volatile" in GPU kernel.