Skip to content

dakkshesh07/mlgo-linux-kernel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

MLGO for Linux Kernels

Overview

This project leverages the MLGO (Machine Learning Guided Compiler Optimizations) infrastructure to train custom optimization models specifically tailored for compiling Linux kernel sources.

What is MLGO?

MLGO is a framework developed by Google for integrating ML techniques systematically in LLVM. It replaces human-crafted optimization heuristics in LLVM with machine learned models.

The MLGO framework currently supports two optimizations:

  1. Inlining-for-size (LLVM RFC)
  2. Register-allocation-for-performance (LLVM RFC)

Training from Linux Kernel Sources

You can train your own model by using our scripts.

example:

bash train_model.sh --arch=arm64 --model=regalloc

To know about all the supported arguments run the script with --help.

Pretrained Models

We provide pretrained regalloc models trained off of Linux kernel sources using our scripts. We provide our models in X86_64 and ARM64 flavours, the training compilation is done using the default defconfig for the respective archtitecture. Models are released as github releases, and are named as: [task]-linux-[linux kernel version used for training]-[arch]-[release candidate].

When building LLVM, there is a flag -DLLVM_RAEVICT_MODEL_PATH which you may set to the path to your downloaded model.

# Model is in /tmp/model, i.e. there is a file /tmp/model/saved_model.pb along
# with the rest of the tensorflow saved_model files produced from training.
-DLLVM_RAEVICT_MODEL_PATH=/tmp/model

Documentation