Eghbal
Eghbal

Reputation: 3783

How does Matlab implement GPU computation in CPU parallel loops?

Can we improve performance by calculating some parts of CPU's parfor or spmd blocks using gpuArray of GPU functions? Is this a rational way to improve performance or there are limitations in this procedure? I read somewhere that we can use this procedure when we have some GPU units. Is this the only way that we can use GPU computing besides CPU parallel loops?

Upvotes: 0

Views: 238

Answers (1)

Edric
Edric

Reputation: 25140

It is possible that using gpuArray within a parfor loop or spmd block can give you a performance benefit, but really it depends on several factors:

  1. How many GPUs you have on your system
  2. What type of GPUs you have (some are better than others at dealing with being "oversubscribed" - i.e. where there are multiple processes using the same GPU)
  3. How many workers you run
  4. How much GPU memory you need for your alogrithm
  5. How well suited the problem is to the GPU in the first place.

So, if you had two high-powered GPUs in your machine and ran two workers in a parallel pool on a problem that could keep a single GPU fully occupied - you'd expect to see good speedup. You might still get decent speedup if you ran 4 workers.

One thing that I would recommend is: if possible, try to avoid transferring gpuArray data from client to workers, as this is slower than usual data transfers (the gpuArray is first gathered to the CPU and then reconstituted on the worker).

Upvotes: 1

Related Questions