0

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?

4
  • You could just try it and then see if it works or not? Commented Feb 18, 2015 at 14:27
  • Yes. But I want know what MATLAB doing under-hood Commented Feb 18, 2015 at 14:29
  • But you do not ask what Matlab is doing under-hood. Shall the question be: "How does Matlab implement GPU computation in CPU parallel loops?"? Commented Feb 18, 2015 at 14:35
  • Yes. That's true. This title is better. Thank you. Commented Feb 18, 2015 at 14:36

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for answer Edric. So as you said this is appropriate when we have more than one GPU unit. Is this true?
Yes, that's right. Each worker can use a different GPU.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.