aplavin
aplavin

Reputation: 2229

Keeping data in OpenCL

I need to process some data for a long time in OpenCL, and due to time limitation (the driver automatically restarts) I start the kernel many times with different parameters. Each time it has to process the same data, which is about 50 Mb, so I want to copy it only once. I've read many articles and tutorials about OpenCL, but have no idea about how to do this, to keep the data between execution.

If it's important, I use C# binding for OpenCL called OpenCLTemplate.

Upvotes: 0

Views: 962

Answers (4)

Tim Child
Tim Child

Reputation: 3012

You have several problems;

1) How to get 50MB of data on to the GPU 2) On windows, the GPU driver will reset frequently when you run long computations 3) A persistence mechanism for ~50MB

Possible answers 1a) create an OpenCL memory buffer of 50M 1b) Enqueue (write) the data to the GPU 1c) Set a kernel arg to this buffer 1d) Access the data as a kernel arg in the GPU's global memory

2) When the OpenCL driver( graphics) driver resets your application will die. You can write script that kills it before the system does and then restarts the application. The script should read back an intermediate result before it kills the app. Otherwise you're never going to be in control. Only running with a Nvida Tesla GPU on Windows or running on Linux will avoids the O/S thinking display is not functioning and doing the reset of the driver.

3) I would use MMAPed files to persist the 50MB of data and any intermediate results. The MMAPed file address can be used to create the OpenCL buffers for the application.

Finally, I will question the approach. Running on Windows vs Linux, due driver reset issues and more. I couldn't find an effective solution to solving driver timeout on Windows even using PostgreSQL database and my own PgOpenCL, which guarantees all GPU kernel executions are ACID.

Upvotes: 0

Lubo Antonov
Lubo Antonov

Reputation: 2318

Any data that you store in a global memory buffer will persist on the GPU. You don't need to do anything special.

Upvotes: 3

bill automata
bill automata

Reputation: 527

Why can't you just keep a read only buffer for all of your kernel executions and put your results in a different buffer?

What makes you think you have to write to the same buffer you are reading from?

Upvotes: 0

Poul K. Sørensen
Poul K. Sørensen

Reputation: 17570

As I have understood from reading online, only one kernel may run simultaneous. This means you should be able to start it with one set of parameters, when complete a new set of parameters can be started and then while that run you can read out the 50mb.

If the driver restarts - this might be due to an error/exception?

Upvotes: -1

Related Questions