PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

usage of acc_set_device & acc_init
Goto page 1, 2  Next
 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming
View previous topic :: View next topic  
Author Message
Bullish



Joined: 21 Mar 2010
Posts: 5

PostPosted: Thu Apr 01, 2010 7:41 pm    Post subject: usage of acc_set_device & acc_init Reply with quote

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
View user's profile
BeachHut



Joined: 14 Mar 2010
Posts: 11

PostPosted: Fri Apr 02, 2010 7:25 am    Post subject: Reply with quote

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
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5943
Location: The Portland Group Inc.

PostPosted: Fri Apr 02, 2010 8:35 am    Post subject: Reply with quote

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
View user's profile
TheMatt



Joined: 06 Jul 2009
Posts: 306
Location: Greenbelt, MD

PostPosted: Fri Apr 02, 2010 10:05 am    Post subject: Re: usage of acc_set_device & acc_init Reply with quote

$%^& 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
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 5943
Location: The Portland Group Inc.

PostPosted: Fri Apr 02, 2010 12:48 pm    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Accelerator Programming All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group