]> git.ipfire.org Git - thirdparty/gcc.git/commit
lto: Implement cache partitioning
authorMichal Jires <mjires@suse.cz>
Fri, 17 Nov 2023 20:17:18 +0000 (21:17 +0100)
committerMichal Jires <mjires@suse.cz>
Fri, 7 Jun 2024 11:14:32 +0000 (13:14 +0200)
commit5b6d5a886ee45bb969b4de23528311472b4ab66b
treeef3d801d5b71ae82a8cb644fcfc0ada7778a4fdd
parentb6a9deb1e2ae01ee906e78e06e3a1b073d20e023
lto: Implement cache partitioning

This patch implements new cache partitioning. It tries to keep symbols
from single source file together to minimize propagation of divergence.

It starts with symbols already grouped by source files. If reasonably
possible it only either combines several files into one final partition,
or, if a file is large, split the file into several final partitions.

Intermediate representation is partition_set which contains set of
groups of symbols (each group corresponding to original source file) and
number of final partitions this partition_set should split into.

First partition_fixed_split splits partition_set into constant number of
partition_sets with equal number of symbols groups. If for example there
are 39 source files, the resulting partition_sets will contain 10, 10,
10, and 9 source files. This splitting intentionally ignores estimated
instruction counts to minimize propagation of divergence.

Second partition_over_target_split separates too large files and splits
them into individual symbols to be combined back into several smaller
files in next step.

Third partition_binary_split splits partition_set into two halves until
it should be split into only one final partition, at which point the
remaining symbols are joined into one final partition.

Bootstrapped/regtested on x86_64-pc-linux-gnu

gcc/ChangeLog:

* common.opt: Add cache partitioning.
* flag-types.h (enum lto_partition_model): Likewise.

gcc/lto/ChangeLog:

* lto-partition.cc (new_partition): Use new_partition_no_push.
(new_partition_no_push): New.
(free_ltrans_partition): New.
(free_ltrans_partitions): Use free_ltrans_partition.
(join_partitions): New.
(split_partition_into_nodes): New.
(is_partition_reorder): New.
(class partition_set): New.
(distribute_n_partitions): New.
(partition_over_target_split): New.
(partition_binary_split): New.
(partition_fixed_split): New.
(class partitioner_base): New.
(class partitioner_default): New.
(lto_cache_map): New.
* lto-partition.h (lto_cache_map): New.
* lto.cc (do_whole_program_analysis): Use lto_cache_map.

gcc/testsuite/ChangeLog:

* gcc.dg/completion-2.c: Add -flto-partition=cache.
gcc/common.opt
gcc/flag-types.h
gcc/lto/lto-partition.cc
gcc/lto/lto-partition.h
gcc/lto/lto.cc
gcc/testsuite/gcc.dg/completion-2.c