[PATCH] D21698: [OpenCL] Allow disabling types and declarations associated with extensions

Yaxun Liu via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 19 13:24:46 PDT 2016

yaxunl added a comment.

In https://reviews.llvm.org/D21698#540237, @Anastasia wrote:

> I have made an experiment with a simple kernel:
>   void foo1(void);
>   void foo2(void);
>   void foo3(void);
>   void foo4(void);
>   void foo5(void);
>   void foo6(void);
>   void foo7(void);
>   void foo8(void);
>   void foo9(void);
>   void foo10(void);
>   void test(){
>     foo1();
>     foo2();
>     foo3();
>     foo4();
>     foo5();
>     foo6();
>     foo7();
>     foo8();
>     foo9();
>     foo10();
>   }
> I am using time utility of linux to measure the compile time running Clang in CL2.0 mode and average over 100 samples. It shows me around 7% overhead with your approach.

Since the program is very small, it is difficult to measure the compilation time accurately. I compile the program 1000 times and measure its time in a script:

   $ cat run.sh
   run() {
   while [[ $i -le 1000 ]]; do
     ./$1 -cc1 -emit-llvm tmp.cl
  time -p run $1

Even so, I found large variations in the measured compilation time. I ran the script 10 times for clang before my change and I got the real time

  real 8.96
  real 9.01
  real 8.99
  real 9.07
  real 9.03
  real 8.99
  real 9.03
  real 9.01
  real 8.99
  real 9.01

and the average time is 9.009s.

For clang after my change, I got

  real 9.06
  real 9.09
  real 9.10
  real 9.03
  real 9.05
  real 9.17
  real 9.08
  real 9.08
  real 9.07
  real 9.08

And the average time is 9.081s.

The increase of compilation time is 0.8%. Considering this program consists mostly of function declarations, which emphasized the cost of evaluating disabled function declarations unrealistically. In real programs this increment in compilation time should be even smaller.

Since the increment of compilation time is less than 1% even for exaggerated cases, I think it is reasonable to accept the cost for the improved diagnostics for extensions.

If there are concerns that the newly added diagnostics may break applications which use builtin functions associated with an extension without enabling it, we can make the diagnostic msg a warning which can be turned off.


More information about the cfe-commits mailing list