Is there a way to manually control the optimizations, like we have flags in clang?

427 views
Skip to first unread message

Gaurav Verma

unread,
Apr 30, 2020, 3:44:13 PM4/30/20
to XLA development

I am trying to explore various optimization available in the XLA and MLIR. Is there a way, I can use certain flags like -o in clang and other compilers, or say LLVM optimizer manager? In the XLA documentation, I could find a few flags but that doesn’t provide means to play with the optimizations individually.


I highly appreciate any leads provided.

George Karpenkov

unread,
May 1, 2020, 7:29:16 PM5/1/20
to Gaurav Verma, XLA development
Hi Gaurav,

Are you concerned with the compile time? For those there is `env XLA_FLAGS=--xla_backend_optimization_level=0/1/2/3` for LLVM optimizations, as those are usually the costliest.
There is also `--xla_gpu_disable_gpuasm_optimizations` for ptxas.
In general, flags are passed using the environment variable XLA_FLAGS, and you can see all flags at xla.proto: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/compiler/xla/xla.proto?q=file:xla.proto

George

On Thu, Apr 30, 2020 at 12:44 PM Gaurav Verma <gaurav...@stonybrook.edu> wrote:

I am trying to explore various optimization available in the XLA and MLIR. Is there a way, I can use certain flags like -o in clang and other compilers, or say LLVM optimizer manager? In the XLA documentation, I could find a few flags but that doesn’t provide means to play with the optimizations individually.


I highly appreciate any leads provided.

--
You received this message because you are subscribed to the Google Groups "XLA development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xla-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xla-dev/320d508a-2efa-4c38-9e65-b71d44f3a7d9%40googlegroups.com.
Message has been deleted

Gaurav Verma

unread,
May 2, 2020, 1:43:14 AM5/2/20
to XLA development
Hi George,

That was a great help. Thank you so much.

Best,
Gaurav

On Friday, May 1, 2020 at 7:29:16 PM UTC-4, George Karpenkov wrote:
Hi Gaurav,

Are you concerned with the compile time? For those there is `env XLA_FLAGS=--xla_backend_optimization_level=0/1/2/3` for LLVM optimizations, as those are usually the costliest.
There is also `--xla_gpu_disable_gpuasm_optimizations` for ptxas.
In general, flags are passed using the environment variable XLA_FLAGS, and you can see all flags at xla.proto: https://cs.opensource.google/tensorflow/tensorflow/+/master:tensorflow/compiler/xla/xla.proto?q=file:xla.proto

George

On Thu, Apr 30, 2020 at 12:44 PM Gaurav Verma <gaura...@stonybrook.edu> wrote:

I am trying to explore various optimization available in the XLA and MLIR. Is there a way, I can use certain flags like -o in clang and other compilers, or say LLVM optimizer manager? In the XLA documentation, I could find a few flags but that doesn’t provide means to play with the optimizations individually.


I highly appreciate any leads provided.

--
You received this message because you are subscribed to the Google Groups "XLA development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xla...@googlegroups.com.

Gaurav Verma

unread,
May 20, 2020, 2:12:24 AM5/20/20
to XLA development
Hi George,

I have a doubt with the supported LLVM Optimization levels.


      

int32 opt_level = hlo_module_config.debug_options().xla_backend_optimization_level();
 
if (opt_level < 2) {
 LOG
(ERROR) << std::string(80, '*');
 LOG
(ERROR) << "The XLA GPU backend doesn't support unoptimized code "
 
"generation but ";
 LOG
(ERROR) << "--xla_backend_optimization_level is set to " << opt_level
 
<< "!";
 LOG
(ERROR) << "(Supported configuration is "
 
"--xla_backend_optimization_level >= 2.)";
 LOG
(ERROR) << std::string(80, '*');
 
}


Is there any specific reason that optimization level below 2 is not supported? But in a switch statement in the same file, it is taking values 1,2,3, and others. I am confused why is this contradictory.
 
Kind Regards,
Gaurav

 
     
       



Gaurav Verma

unread,
May 20, 2020, 3:35:59 AM5/20/20
to XLA development
I understand that 0 and 1 will have a hit on the performance. But was just curious to know. I wanted to visualize how XLA will perform the fusion under those conditions.

Sanjoy Das

unread,
May 20, 2020, 3:48:36 AM5/20/20
to Gaurav Verma, XLA development
On Wed, May 20, 2020 at 12:36 AM Gaurav Verma <gaurav...@stonybrook.edu> wrote:
I understand that 0 and 1 will have a hit on the performance. But was just curious to know. I wanted to visualize how XLA will perform the fusion under those conditions.

xla_backend_optimization_level should not influence fusion decisions.  It only affects how hard we optimize the generated LLVM IR.

-- Sanjoy
 
To unsubscribe from this group and stop receiving emails from it, send an email to xla-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xla-dev/21346fbe-a788-45ef-919c-f633464caca0%40googlegroups.com.

Gaurav Verma

unread,
May 20, 2020, 4:49:23 AM5/20/20
to XLA development
Seconded. I could see the fusion is independent of the xla_backend_optimization_level after experimenting it for various levels.

Thanks,
Gaurav



On Wednesday, May 20, 2020 at 3:48:36 AM UTC-4, Sanjoy Das wrote:


Reply all
Reply to author
Forward
0 new messages