Well defined ways of detecting product ID

Problem: Often optimized kernels are written for a particular chip (say very optimized kernel specifically for AMD Tahiti GPUs) or for a particular family (say very optimized kernels for Nvidia Fermi GPUs). However, currently it is very difficult to correctly detect the chip family or chip ID from just OpenCL APIs without using vendor extensions.

OpenCL device information can usually tell you the vendor ID and the device name, but the device name returned can sometimes be the brand name of the product. Brand names are difficult to keep track of. For example, same chip may be rebranded to 10 totally different product names and new product names for the same chip may very well be introduced after my software ships. Meanwhile similar looking names may very well be two very different chip families so a simple pattern matcher on the device name string is also not useful.

Thus, I propose that APIs be added to return slightly more detailed info, for example a triplet of numeric codes like vendor ID, product family and product ID. The product IDs here should not be tied to product branding. Vendors can list the product family and product IDs in their documentation and implement it in some sane way. Even just implementing product family codes will be a big help.

Thoughts? I know that there are often vendor specific extensions that I can use but I do feel that this should be more standardized.

(Note: I had posted in the wrong forum earlier, copying it here now.)

Rahul Garg, PhD student, McGill University

All the major OpenCL platforms expose the relevant information in the form of macros that you can test for in the kernel. Quality and amount of documentation of these macros varies. For example, AMD documents these in the APP OpenCL Programming guide, “Predefined Macros” section.