How can I find the id of a gang in OpenACC?

Richard

In OpenMP I can use omp_get_thread_num() to get the numerical id of the thread executing the code.

Is there a similar function I can use in OpenACC to get id of the gang executing a piece of code?

Richard

The OpenACC standard does not yet include such a function, but, with the PGI compiler, you can use the compiler extension function __pgi_gangidx() as follows:

//pgc++ -fast -acc -ta=tesla,cc60 -Minfo=accel test.cpp
#include <iostream>
#include "openacc.h"

int main(){
  int gangs = 100;
  int *ids  = new int[gangs];

  //Ensure everything is zeroed
  for(int i=0;i<gangs;i++)
    ids[i] = 0;

  #pragma acc parallel num_gangs(gangs) copyout(ids[0:gangs])
  {
    ids[__pgi_gangidx()] = __pgi_gangidx();
  }

  for(int i=0;i<gangs;i++)
    std::cout<<ids[i]<<" ";
  std::cout<<std::endl;
}

Compile with:

pgc++ -fast -acc -ta=tesla,cc60 -Minfo=accel test.cpp

This gives as output:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

as expected.

A suite of additional functions are available:

extern int __pgi_gangidx(void);
extern int __pgi_workeridx(void);
extern int __pgi_vectoridx(void);
extern int __pgi_blockidx(int);
extern int __pgi_threadidx(int);

Note that omp_get_thread_num() does not (yet?) work for GPU-targeted code.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How can I access value of ID to find the average?

分類Dev

How can I find the Id property or properties related to a navigational property?

分類Dev

How can I find my User ID (UID) from terminal?

分類Dev

How can I find the deleted id between an continuous id range in MYSQL?

分類Dev

Where can I find my Enterprise ID for Box API?

分類Dev

How can I find the version of Ubuntu that is installed?

分類Dev

How can I find my DHCP server?

分類Dev

How can I find and copy using gsutil?

分類Dev

How can I list files with find and Perl?

分類Dev

How can I find available network interfaces?

分類Dev

How can I find my DHCP server?

分類Dev

How can i find the similarity in 2 arrays

分類Dev

how can i find two substrings

分類Dev

how can i combine href with id number

分類Dev

How can i get the facebook post id?

分類Dev

How can I find why system can not run my application?

分類Dev

How can I find the answers I gave in a Jhipster project?

分類Dev

How to find an object by id?

分類Dev

How can I find application using hard drive?

分類Dev

How can I find all the APIs of my website?

分類Dev

How can I find second key name in JSON using javascript

分類Dev

How can I find current element on mouseover using jQuery?

分類Dev

How can i find out facebook API version

分類Dev

How can i find out size of RethinkDB table?

分類Dev

How can I use collection.find as a result of a meteor method?

分類Dev

How can I find the occurence number of each suffix in a string?

分類Dev

How can I find the percentage of a regex match on a string?

分類Dev

How can I find the file extension of the currently running code?

分類Dev

How can I find out the source of this glibc backtrace originating with clone()?

Related 関連記事

  1. 1

    How can I access value of ID to find the average?

  2. 2

    How can I find the Id property or properties related to a navigational property?

  3. 3

    How can I find my User ID (UID) from terminal?

  4. 4

    How can I find the deleted id between an continuous id range in MYSQL?

  5. 5

    Where can I find my Enterprise ID for Box API?

  6. 6

    How can I find the version of Ubuntu that is installed?

  7. 7

    How can I find my DHCP server?

  8. 8

    How can I find and copy using gsutil?

  9. 9

    How can I list files with find and Perl?

  10. 10

    How can I find available network interfaces?

  11. 11

    How can I find my DHCP server?

  12. 12

    How can i find the similarity in 2 arrays

  13. 13

    how can i find two substrings

  14. 14

    how can i combine href with id number

  15. 15

    How can i get the facebook post id?

  16. 16

    How can I find why system can not run my application?

  17. 17

    How can I find the answers I gave in a Jhipster project?

  18. 18

    How to find an object by id?

  19. 19

    How can I find application using hard drive?

  20. 20

    How can I find all the APIs of my website?

  21. 21

    How can I find second key name in JSON using javascript

  22. 22

    How can I find current element on mouseover using jQuery?

  23. 23

    How can i find out facebook API version

  24. 24

    How can i find out size of RethinkDB table?

  25. 25

    How can I use collection.find as a result of a meteor method?

  26. 26

    How can I find the occurence number of each suffix in a string?

  27. 27

    How can I find the percentage of a regex match on a string?

  28. 28

    How can I find the file extension of the currently running code?

  29. 29

    How can I find out the source of this glibc backtrace originating with clone()?

ホットタグ

アーカイブ