[RFC] OpenCL: Allow enabling/disabling an extension by command line options

Currently Clang defines supported OpenCL extensions for each target, and there is a feature under review for defining supported extensions in header files.

OpenCL runtime needs a flexible way to define supported extensions for a device in a specific environment. It is desirable to be able to enable/disable support of an extension by command line options.

One possible solution is to use -D and -U followed by the name of an extension to enable or disable support of the extension.

There may be multiple -D and -U options, each of which is followed by the name of an extension.

Basically, when Clang decides whether an extension is supported, it not only uses Target information, but also checks if the macro with the same name is defined or undefined.

Your feedback is welcome.



Hi Sam,

I think this feature is useful and there is an alternative solution under review here: https://reviews.llvm.org/D23712.

This solution introduces new command line option to enable/disable supported OpenCL extensions. This approach doesn’t overload meaning of –D and –U option and allows controlling all extensions at once: enable/disable all.

The alternative solution looks good to me.



I would see target triple as a mean to control extensions setting in general as target triple encapsulates the platform settings - HW architecture and runtime. But if there are too many platforms with slightly different extensions creating a new triple for each of them might be too much overhead indeed.