I would like to pass the address of a device function to a kernel, which can be done according to this post. However, I'm wondering that, when I have multiple devices, whether the addresses are specific to a certain device? Do I have to keep track of the addresses of each function on different devices?
Asked
Active
Viewed 90 times
1 Answers
2
Yes, the addresses are specific to a certain device. There is no guarantee that addresses will be the same between two devices. (A simple modification of the code in the answer you have linked to can prove this, on a system with 2 non-identical GPUs.)
If you review various mechanisms for determining device function addresses or function pointers, you will discover that they all depend on discovery in some form via device code. It's not possible to directly discover a __device__
function address in host code.
Therefore it should be no trouble to keep track of this on a device-by-device basis, because the discovery must be performed on a device-by-device basis.

Robert Crovella
- 143,785
- 11
- 213
- 257
-
Thank you Robert! What are the other mechanisms of determining the addresses that you were thinking of? – shaoyl85 Sep 11 '15 at 03:02
-
[This answer](http://stackoverflow.com/questions/31057870/passing-host-function-as-a-function-pointer-in-global-or-device-function/31058123#31058123) links to a few examples, other than the one you have already linked to. – Robert Crovella Sep 11 '15 at 04:03
-
Thank you Robert! I tried more experiments on this and got more questions here http://stackoverflow.com/questions/32534593/behavior-of-pointer-to-device-functions. If you have time would you take a look? Thank you! – shaoyl85 Sep 12 '15 at 02:35