| View previous topic :: View next topic |
| Author |
Message |
Bullish
Joined: 21 Mar 2010 Posts: 5
|
Posted: Thu Apr 01, 2010 7:41 pm Post subject: usage of acc_set_device & acc_init |
|
|
| I noticed that the accelerator enabled program works smoothly even without using acc_set_device( )& call acc_init( ) to initialize GPU card. Then why we have to add these two functions in the code? thanks! |
|
| Back to top |
|
 |
BeachHut
Joined: 14 Mar 2010 Posts: 11
|
Posted: Fri Apr 02, 2010 7:25 am Post subject: |
|
|
My guess:
If you have multiple GPUs attached you can select which you want to use. For the init it might perform the initialisation that is normally done at the first GPU-related call (you might want to do this for timing purposes, for example). |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Fri Apr 02, 2010 8:35 am Post subject: |
|
|
| Quote: | | Then why we have to add these two functions in the code? | They're optional. The set device is only needed when selecting a device other then the default.
The init call is useful for performance timing. By default the device is initialized on first use, but since the initialization time is approximately 1 second per attached device (Linux only), this can have impact on timing. Placing the acc_init call outside of your timers removes this overhead.
- Mat |
|
| Back to top |
|
 |
TheMatt
Joined: 06 Jul 2009 Posts: 263 Location: Greenbelt, MD
|
Posted: Fri Apr 02, 2010 10:05 am Post subject: Re: usage of acc_set_device & acc_init |
|
|
| $%^& wrote: | | I noticed that the accelerator enabled program works smoothly even without using acc_set_device( )& call acc_init( ) to initialize GPU card. Then why we have to add these two functions in the code? thanks! |
acc_set_device() is useful for when you have multiple devices. Say, two Tesla cards or a Tesla S-box. With that command you can set which device you want to run on, so you can do multi-GPU jobs, say, or test how your code runs on different devices with different compute capabilities in the same machine. If you don't use acc_set_device() on a multi-device machine, you'll always get the "default" device, which I think is device 0...though which device is 0 might not be what you think should be "default".
As for acc_init(), in the old days before PGI autoinitialized, I used acc_init() early in a program so that I could "hide" the initialization spinup from timing routines. (ETA: Looks like this is still the case at times. Thanks for letting me know, Mat.) |
|
| Back to top |
|
 |
mkcolg
Joined: 30 Jun 2004 Posts: 4996 Location: The Portland Group Inc.
|
Posted: Fri Apr 02, 2010 12:48 pm Post subject: |
|
|
| Quote: | | Looks like this is still the case at times. | Nothing's changed here. Though we did add an external utility "pgcudainit" which holds the device open and eliminates the initialization cost.
- Mat |
|
| Back to top |
|
 |
|