separate out use_fma, and add Th24 explainer images

This commit is contained in:
Alexander Frick 2024-12-15 03:46:11 -06:00
parent e05f036b67
commit 6c7b653ec6
15 changed files with 254 additions and 22 deletions

View file

@ -624,7 +624,7 @@ config("compiler") {
}
}
if (use_avx2 || use_avx512 || current_cpu == "arm64" || is_mac) {
if (use_avx2 || use_avx512 || use_fma || current_cpu == "arm64" || is_mac) {
if (is_win) {
cflags += [ "/clang:-ffp-contract=fast" ]
} else {
@ -1284,14 +1284,19 @@ config("compiler_cpu_abi") {
"-mavx",
]
}
if (use_fma) {
cflags += [
"-mfma",
"-ffp-contract=fast",
#"-ffast-math",
]
}
if (use_avx2) {
cflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-ffp-contract=fast",
"-mtune=haswell",
]
}
@ -1335,14 +1340,18 @@ config("compiler_cpu_abi") {
"-mavx",
]
}
if (use_fma) {
ldflags += [
"-mfma",
"-Wl,-mllvm,-fp-contract=fast",
]
}
if (use_avx2) {
ldflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-Wl,-mllvm,-fp-contract=fast",
"-Wl,-mllvm,-march=haswell",
]
}
@ -2596,14 +2605,18 @@ if (is_win) {
"/clang:-mavx",
]
}
if (use_fma) {
common_optimize_on_cflags += [
"/clang:-mfma",
"/clang:-ffp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_cflags += [
"/clang:-mavx2",
"/clang:-mfma",
"/clang:-mf16c",
"/clang:-mlzcnt",
"/clang:-mbmi2",
"/clang:-ffp-contract=fast",
]
}
if (use_avx512) {
@ -2689,14 +2702,18 @@ if (is_win) {
"-mavx",
]
}
if (use_fma) {
common_optimize_on_cflags += [
"-mfma",
"-ffp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_cflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-ffp-contract=fast",
]
}
if (use_avx512) {
@ -2743,14 +2760,18 @@ if (is_win) {
"-mavx",
]
}
if (use_fma) {
common_optimize_on_ldflags += [
"-mfma",
"-Wl,-mllvm,-fp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_ldflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-Wl,-mllvm,-fp-contract=fast",
"-Wl,-mllvm,-march=haswell",
]
}

BIN
docs/imgs/cr23_button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

BIN
docs/imgs/cr23_color.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B

BIN
docs/imgs/cr23_dialog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 KiB

BIN
docs/imgs/cr23_menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
docs/imgs/cr23_toggle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

BIN
docs/imgs/th24_button.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
docs/imgs/th24_color.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

BIN
docs/imgs/th24_dialog.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 KiB

BIN
docs/imgs/th24_menu.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
docs/imgs/th24_toggle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

View file

@ -624,7 +624,7 @@ config("compiler") {
}
}
if (use_avx2 || use_avx512 || current_cpu == "arm64" || is_mac) {
if (use_avx2 || use_avx512 || use_fma || current_cpu == "arm64" || is_mac) {
if (is_win) {
cflags += [ "/clang:-ffp-contract=fast" ]
} else {
@ -1284,14 +1284,19 @@ config("compiler_cpu_abi") {
"-mavx",
]
}
if (use_fma) {
cflags += [
"-mfma",
"-ffp-contract=fast",
#"-ffast-math",
]
}
if (use_avx2) {
cflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-ffp-contract=fast",
"-mtune=haswell",
]
}
@ -1335,14 +1340,18 @@ config("compiler_cpu_abi") {
"-mavx",
]
}
if (use_fma) {
ldflags += [
"-mfma",
"-Wl,-mllvm,-fp-contract=fast",
]
}
if (use_avx2) {
ldflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-Wl,-mllvm,-fp-contract=fast",
"-Wl,-mllvm,-march=haswell",
]
}
@ -2596,14 +2605,18 @@ if (is_win) {
"/clang:-mavx",
]
}
if (use_fma) {
common_optimize_on_cflags += [
"/clang:-mfma",
"/clang:-ffp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_cflags += [
"/clang:-mavx2",
"/clang:-mfma",
"/clang:-mf16c",
"/clang:-mlzcnt",
"/clang:-mbmi2",
"/clang:-ffp-contract=fast",
]
}
if (use_avx512) {
@ -2689,14 +2702,18 @@ if (is_win) {
"-mavx",
]
}
if (use_fma) {
common_optimize_on_cflags += [
"-mfma",
"-ffp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_cflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-ffp-contract=fast",
]
}
if (use_avx512) {
@ -2743,14 +2760,18 @@ if (is_win) {
"-mavx",
]
}
if (use_fma) {
common_optimize_on_ldflags += [
"-mfma",
"-Wl,-mllvm,-fp-contract=fast",
]
}
if (use_avx2) {
common_optimize_on_ldflags += [
"-mavx2",
"-mfma",
"-mf16c",
"-mlzcnt",
"-mbmi2",
"-Wl,-mllvm,-fp-contract=fast",
"-Wl,-mllvm,-march=haswell",
]
}

View file

@ -0,0 +1,190 @@
# Copyright 2024 The Chromium Authors, RobRich999, and Alex313031
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/clang/clang.gni")
import("//build/config/compiler_opt.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/compiler/pgo/pgo.gni")
import("//build/config/features.gni")
import("//build/toolchain/toolchain.gni")
# Configuration that enables PGO instrumentation.
config("pgo_instrumentation_flags") {
visibility = [ ":default_pgo_flags" ]
# Only add flags when chrome_pgo_phase == 1, so that variables we would use
# are not required to be defined when we're not actually using PGO.
if (chrome_pgo_phase == 1 && is_clang && !is_nacl && is_a_target_toolchain) {
cflags = [ "-fprofile-generate" ]
if (temporal_pgo_profile) {
cflags += [
"-mllvm",
"-pgo-temporal-instrumentation",
]
}
if (!is_win) {
# Windows directly calls link.exe instead of the compiler driver when
# linking, and embeds the path to the profile runtime library as
# dependent library into each object file.
ldflags = [ "-fprofile-generate" ]
}
}
}
# Configuration that enables optimization using profile data.
config("pgo_optimization_flags") {
visibility = [ ":default_pgo_flags" ]
# Only add flags when chrome_pgo_phase == 2, so that variables we would use
# are not required to be defined when we're not actually using PGO.
if (chrome_pgo_phase == 2 && is_clang && !is_nacl && is_a_target_toolchain) {
_pgo_target = ""
# There are txt files used by //tools/update_pgo_profiles.py to decide which
# profiles to use, adding them as inputs so that analyzer recognizes the
# dependencies.
inputs = []
if (is_win) {
if (target_cpu == "arm64") {
_pgo_target = "win-arm64"
} else if (target_cpu == "x64") {
_pgo_target = "win64"
} else {
_pgo_target = "win32"
}
} else if (is_mac) {
if (target_cpu == "arm64") {
_pgo_target = "mac-arm"
} else {
_pgo_target = "mac"
}
} else if (is_linux) {
_pgo_target = "linux"
} else if (is_chromeos_lacros) {
if (target_cpu == "arm") {
# We don't have the arm device to train arm pgo data. So Lacros arm
# would use arm64 profile.
_pgo_target = "lacros-arm64"
} else if (target_cpu == "arm64") {
_pgo_target = "lacros-arm64"
} else {
_pgo_target = "lacros64"
}
} else if (is_android) {
# Use |current_cpu| and not |target_cpu|; for Android we may built both.
if (current_cpu == "arm64") {
_pgo_target = "android-arm64"
} else {
_pgo_target = "android-arm32"
}
} else if (is_fuchsia) {
if (target_cpu == "arm64") {
_pgo_target = "mac-arm"
} else {
_pgo_target = "mac"
}
} else if (is_ios && use_blink) {
if (target_cpu == "arm64") {
_pgo_target = "mac-arm"
} else {
_pgo_target = "mac"
}
}
if (_pgo_target == "win-arm64") {
inputs = [ "//chrome/build/win-arm64.pgo.txt" ]
} else if (_pgo_target == "win64") {
inputs = [ "//chrome/build/win64.pgo.txt" ]
} else if (_pgo_target == "win32") {
inputs = [ "//chrome/build/win32.pgo.txt" ]
} else if (_pgo_target == "mac-arm") {
inputs = [ "//chrome/build/mac-arm.pgo.txt" ]
} else if (_pgo_target == "mac") {
inputs = [ "//chrome/build/mac.pgo.txt" ]
} else if (_pgo_target == "linux") {
inputs = [ "//chrome/build/linux.pgo.txt" ]
} else if (_pgo_target == "lacros64") {
inputs = [ "//chrome/build/lacros64.pgo.txt" ]
} else if (_pgo_target == "lacros-arm") {
inputs = [ "//chrome/build/lacros-arm.pgo.txt" ]
} else if (_pgo_target == "lacros-arm64") {
inputs = [ "//chrome/build/lacros-arm64.pgo.txt" ]
} else if (_pgo_target == "android-arm32") {
inputs = [ "//chrome/build/android-arm32.pgo.txt" ]
} else if (_pgo_target == "android-arm64") {
inputs = [ "//chrome/build/android-arm64.pgo.txt" ]
}
if (_pgo_target != "" && pgo_data_path == "") {
pgo_data_path = exec_script("//tools/update_pgo_profiles.py",
[
"--target",
_pgo_target,
"get_profile_path",
],
"value")
}
assert(pgo_data_path != "",
"Please set pgo_data_path to point at the profile data")
cflags = [
"-fprofile-use=" + rebase_path(pgo_data_path, root_build_dir),
# It's possible to have some profile data legitimately missing,
# and at least some profile data always ends up being considered
# out of date, so make sure we don't error for those cases.
"-Wno-profile-instr-unprofiled",
"-Wno-profile-instr-out-of-date",
# Some hashing conflict results in a lot of warning like this when doing
# a PGO build:
# warning: foo.cc: Function control flow change detected (hash mismatch)
# [-Wbackend-plugin]
# See https://crbug.com/978401
"-Wno-backend-plugin",
]
# Enable basic block layout based on the extended TSP problem. This aims to
# improve icache utilization and reduce the binary size.
if (use_thin_lto) {
if (current_cpu == "x64" || current_cpu == "x86") {
if (is_win) {
ldflags = [ "-mllvm:-enable-ext-tsp-block-placement=1" ]
} else if (is_linux) {
ldflags = [
"-Wl,-mllvm,-enable-ext-tsp-block-placement=1",
"-Wl,-mllvm,-enable-split-machine-functions"
]
} else {
ldflags = [ "-Wl,-mllvm,-enable-ext-tsp-block-placement=1" ]
}
} else {
if (is_win) {
ldflags = [ "-mllvm:-enable-ext-tsp-block-placement=1" ]
} else {
ldflags = [ "-Wl,-mllvm,-enable-ext-tsp-block-placement=1" ]
}
}
} else {
cflags += [
"-mllvm",
"-enable-ext-tsp-block-placement=1",
]
}
}
}
# Applies flags necessary when profile-guided optimization is used.
# Flags are only added if PGO is enabled, so that this config is safe to
# include by default.
config("default_pgo_flags") {
if (chrome_pgo_phase == 0) {
# Nothing. This config should be a no-op when chrome_pgo_phase == 0.
} else if (chrome_pgo_phase == 1) {
configs = [ ":pgo_instrumentation_flags" ]
} else if (chrome_pgo_phase == 2) {
configs = [ ":pgo_optimization_flags" ]
}
}