PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

CUDA-x86.

How to get the number of the used GPU device?
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
xray



Joined: 21 Jan 2010
Posts: 85

PostPosted: Tue Apr 20, 2010 4:05 am    Post subject: How to get the number of the used GPU device? Reply with quote

Hello,
I was wondering how to get the number of the GPU device on which my program runs. acc_get_device only returns the type of my device, but not the number (i.e. 0,1,...).
There could be a possibility as pgaccelinfo also returns the device number. It's a pity a can't have a look into pgaccelinfo source files to get to know how they did it.
So, does anyone knows?
Back to top
View user's profile
mkcolg



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

PostPosted: Tue Apr 20, 2010 8:35 am    Post subject: Reply with quote

Hi Xray,

I just added a feature request to add a "acc_get_device_num" function to query the device number the application is currently using. (TPR#16863).

As for the pgaccelinfo source, for the most part it's the same as the example CUDA Fortran code "cufinfo.cuf" found in your installation's "etc/samples" directory.

Thanks,
Mat
Back to top
View user's profile
mkcolg



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

PostPosted: Tue May 04, 2010 12:10 pm    Post subject: Reply with quote

Hi Xray,

This feature will be available in 10.5. However, missed the deadline for documentation changes so documentation will follow in 10.6. Here's an example of it's usage.

Code:
% cat test.f90
  use accel_lib
  integer n

  call acc_init(acc_device_nvidia)
  n = acc_get_device_num(acc_device_nvidia)
  print *, n
  end
% pgf90 -ta=nvidia test.f90 -V10.5
% a.out
            0
% setenv ACC_DEVICE_NUM 2
% a.out
            2


- Mat
Back to top
View user's profile
xray



Joined: 21 Jan 2010
Posts: 85

PostPosted: Sun May 09, 2010 11:31 pm    Post subject: Reply with quote

Thanks a lot! I will try it out as soon as we have installed 10.5.
Back to top
View user's profile
xray



Joined: 21 Jan 2010
Posts: 85

PostPosted: Tue Jul 13, 2010 5:04 am    Post subject: Reply with quote

Hi,
with Fortran everything works fine. Today I tried it with C and then the output is just wrong:
Code:

$ cat getDevTest.c
#include <stdio.h>
#include <accel.h>

int main() {
  int n;

  acc_init(acc_device_nvidia);
  n = acc_get_device_num(acc_device_nvidia);
  printf("\t%d\n");
}

$ pgcc -ta=nvidia,3.0 getDevTest.c
$ a.out
        6354592

$ ACC_DEVICE_NUM=1 a.out
        6354592



Can it be that this is a bug? Or am I just to stupid?
BTW: I tried it with 10.5 and 10.6: same problem
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