how to run a function on GPU cores

5 vues (au cours des 30 derniers jours)
Memo Remo
Memo Remo le 24 Jan 2023
I want to run a very simple custom function on GPU. This function repeat reading an image and perform some predictions using an available machine learning model (mdl) by the "predict" command. Can anyone guide me in performing these calculations on each GPU core?
I am not sure if my understanding is correct but using CPU parallel processing, we can run such commands on each core at a time. For instance, if we have 12 images and 12 cores in our CPU, then using the "parfor loop", we can run the function on 12 images simultaneously. I want to do this using the GPU. I know that GPUs usually have a lot of cores (~1000s), so it would be great if we could have a function like "parfor" for GPU-based parallel processing.
I would appreciate any help you could provide.

Réponse acceptée

Matt J
Matt J le 24 Jan 2023
so it would be great if we could have a function like "parfor" for GPU-based parallel processing.
No, you cannot use GPU cores in a manner that is analogous to parpool workers. It is a very different ype of "core" than what CPUs have.
  3 commentaires
Memo Remo
Memo Remo le 24 Jan 2023
Okay. Thanks for letting me know.
Our University should have it, but I don't know how to work with it. I can read the documentation.
Thanks for your help!

Connectez-vous pour commenter.

Plus de réponses (2)

Walter Roberson
Walter Roberson le 24 Jan 2023
Nvidia GPUs are constructed in a hierarchy. GPU cores individually cannot decode instructions and cannot run programs independently of others in the same group. GPU cores are grouped together and each group has a controller. Controllers are somewhat independent of each other. Each controller decodes an instruction and makes the information available on a bus shared by the group of cores. Each core in the group then executes the same instruction, just with different addresses.
Conditional work is not handled by having different cores in a group execute different instructions. Instead, the controller has a way of informing each core whether it is to perform the action, or if instead it should just idle. So if/else is handled by having a subset of the cores sit idle for one branch, and then the controller changes the information about which cores are to take part and has the other cores sit idle when some cores do work.
In traditional CPUs, each physical core (not hyperthreaded core) has its own instruction decoder and register set and can execute independently. The number of simultaneous independent programs is based on the number of physical cores.
In Nvidia GPUs, the number of simultaneous independent programs is based not on the number of cores, but rather on the number of controllers. The old generations of Nvidia GPUs started with only two or three controllers. The number has increased a fair bit in more modern models, but you should still expect each controller to be controlling at least 128 cores.
  4 commentaires
Memo Remo
Memo Remo le 24 Jan 2023
Awesome! I can understand it now.
Your help is greatly appreciated.

Connectez-vous pour commenter.

Joss Knight
Joss Knight le 26 Jan 2023
It's probably best to read the extensive documentation available online that should give you a complete picture of how to leverage your GPU and what applications it is useful for.


En savoir plus sur Get Started with GPU Coder dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by