gcc/0316-Use-ai-ability-to-guide-optimization.patch

742 lines
38 KiB
Diff
Raw Permalink Normal View History

From 0b85ab4639e2d25314175962a6e41a841649b028 Mon Sep 17 00:00:00 2001
From: zhenyu zhao <zhaozhenyu17@huawei.com>
Date: Sun, 24 Nov 2024 17:29:13 +0800
Subject: [PATCH 3/5] Use ai ability to guide optimization.
---
gcc/Makefile.in | 8 +-
gcc/ai4c-infer.cc | 457 ++++++++++++++++++++++++++++++++++
gcc/ai4c-infer.h | 29 +++
gcc/config/aarch64/aarch64.cc | 14 +-
gcc/gcc.cc | 32 +++
gcc/gcc.h | 1 +
gcc/ipa-hardware-detection.cc | 6 +-
gcc/onnx.fdata | 1 +
gcc/opts-global.cc | 10 +
9 files changed, 550 insertions(+), 8 deletions(-)
create mode 100644 gcc/ai4c-infer.cc
create mode 100644 gcc/ai4c-infer.h
create mode 100644 gcc/onnx.fdata
diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index bb6197a8e..6315462aa 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1734,13 +1734,13 @@ OBJS-libcommon = diagnostic-spec.o diagnostic.o diagnostic-color.o \
pretty-print.o intl.o \
sbitmap.o \
vec.o input.o hash-table.o ggc-none.o memory-block.o \
- selftest.o selftest-diagnostic.o sort.o
+ ai4c-infer.o selftest.o selftest-diagnostic.o sort.o
# Objects in libcommon-target.a, used by drivers and by the core
# compiler and containing target-dependent code.
OBJS-libcommon-target = $(common_out_object_file) prefix.o \
opts.o opts-common.o options.o vec.o hooks.o common/common-targhooks.o \
- hash-table.o file-find.o spellcheck.o selftest.o opt-suggestions.o
+ hash-table.o file-find.o spellcheck.o ai4c-infer.o selftest.o opt-suggestions.o
# This lists all host objects for the front ends.
ALL_HOST_FRONTEND_OBJS = $(foreach v,$(CONFIG_LANGUAGES),$($(v)_OBJS))
@@ -2256,7 +2256,7 @@ gcc-nm.cc: gcc-ar.cc
cp $^ $@
COLLECT2_OBJS = collect2.o collect2-aix.o vec.o ggc-none.o \
- collect-utils.o file-find.o hash-table.o selftest.o
+ collect-utils.o file-find.o hash-table.o ai4c-infer.o selftest.o
COLLECT2_LIBS = @COLLECT2_LIBS@
collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
# Don't try modifying collect2 (aka ld) in place--it might be linking this.
@@ -3720,6 +3720,8 @@ install-plugin: installdirs lang.install-plugin s-header-vars install-gengtype
# Install the compiler executables built during cross compilation.
install-common: native lang.install-common installdirs
+ rm -f $(DESTDIR)$(libexecdir)/onnx.fdata
+ cp $(srcdir)/onnx.fdata $(DESTDIR)$(libexecsubdir)/onnx.fdata
for file in $(COMPILERS); do \
if [ -f $$file ] ; then \
rm -f $(DESTDIR)$(libexecsubdir)/$$file; \
diff --git a/gcc/ai4c-infer.cc b/gcc/ai4c-infer.cc
new file mode 100644
index 000000000..99f7a6b45
--- /dev/null
+++ b/gcc/ai4c-infer.cc
@@ -0,0 +1,457 @@
+/* Lightweight AI Inference Framework.
+ Copyright (C) 2024-2024 Free Software Foundation, Inc.
+This file is part of GCC.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include <unistd.h>
+#include <math.h>
+#include <cstring>
+#include <cstdio>
+#include <cstdlib>
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "ai4c-infer.h"
+#include "config.h"
+#include "system.h"
+
+#define M_MODE_SIZE 6
+#define NATIVE_TUNE_SIZE 128
+#define CATS_STRINGS_ROW 12
+#define CATS_STRINGS_COL 65
+#define OFFSET_ROW 6
+#define SCALE_ROW 6
+#define UNITY_ROW 1
+#define COEFFICIENT_ROW 18
+#define COEFFICIENT_COL 100
+#define COEFFICIENT1_ROW 100
+#define COEFFICIENT1_COL 1
+#define INTERCEPTS_ROW 100
+#define INTERCEPTS1_ROW 1
+
+/* Model info. */
+static int64_t argv_hw1[M_MODE_SIZE];
+static char native_tune[NATIVE_TUNE_SIZE];
+
+/* Intermediate computation results from the ONNX model. */
+static char cats_strings[CATS_STRINGS_ROW][CATS_STRINGS_COL];
+static float offset[OFFSET_ROW];
+static float scale[SCALE_ROW];
+static float unity[UNITY_ROW];
+static float coefficient[COEFFICIENT_ROW][COEFFICIENT_COL];
+static float coefficient1[COEFFICIENT1_ROW][COEFFICIENT1_COL];
+static float intercepts[INTERCEPTS_ROW];
+static float intercepts1[INTERCEPTS1_ROW];
+
+/* Model result. */
+static int64_t initialized;
+static int64_t optimize_result;
+
+void
+prepare_native_tune_str (const char *info)
+{
+ gcc_assert (strlen (info) < NATIVE_TUNE_SIZE);
+ if (info)
+ strcpy (native_tune, info);
+ return;
+}
+
+void
+set_cache_info (int prefetches, int l1_cache_size,
+ int l1_cache_line_size, int l2_cache_size,
+ int prefetch_latency, int prefetch_distance_factor)
+{
+ gcc_assert (5 < M_MODE_SIZE);
+ argv_hw1[0] = prefetches;
+ argv_hw1[1] = l1_cache_size;
+ argv_hw1[2] = l1_cache_line_size;
+ argv_hw1[3] = l2_cache_size;
+ argv_hw1[4] = prefetch_latency;
+ argv_hw1[5] = prefetch_distance_factor;
+}
+
+/* Read float from onnx.fdata. */
+
+float static
+read_float_from_file (FILE* file)
+{
+ char hex_float[8];
+ float result;
+
+ if (!file)
+ {
+ perror ("Can not open file.");
+ return result;
+ }
+
+ if (fscanf (file, "%8s", hex_float) != 1)
+ {
+ perror ("Can not read hex from onnx.fdata.");
+ return result;
+ }
+
+ unsigned char bytes[4];
+ for (int i = 0; i < 4; i++)
+ {
+ sscanf(hex_float + 2 * i, "%2hhx", &bytes[i]);
+ }
+
+ memcpy(&result, bytes, sizeof(float));
+ return result;
+}
+
+/* To read model parameter information from onnx.fdata and store it into the
+ appropriate arrays. */
+
+static void
+fill_node (const char *file_name)
+{
+ FILE *file = fopen (file_name, "rb");
+
+ if (!file)
+ {
+ perror ("Can not open file.");
+ return;
+ }
+
+ /* Read cats_strings from onnx.fdata. */
+ char hex_string[2];
+ for (int i = 0; i < CATS_STRINGS_ROW; i++)
+ {
+ for (int j = 0; j < CATS_STRINGS_COL - 1; j++)
+ {
+ if (fscanf(file, "%2s", hex_string) != 1)
+ {
+ perror ("Can not read cats_strings from onnx.fdata.");
+ return;
+ }
+ cats_strings[i][j] = (unsigned char)strtol(hex_string, NULL, 16);
+ }
+ cats_strings[i][CATS_STRINGS_COL - 1] = '\0';
+ }
+
+ /* Read offset from onnx.fdata. */
+ for (int i = 0; i < OFFSET_ROW; i++)
+ {
+ float result = read_float_from_file (file);
+ offset[i] = result;
+ }
+
+ /* Read scale from onnx.fdata. */
+ for (int i = 0; i < SCALE_ROW; i++)
+ {
+ float result = read_float_from_file (file);
+ scale[i] = result;
+ }
+
+ /* Read coefficient from onnx.fdata. */
+ for (int i = 0; i < COEFFICIENT_ROW; i++)
+ for (int j = 0; j < COEFFICIENT_COL; j++)
+ {
+ float result = read_float_from_file (file);
+ coefficient[i][j] = result;
+ }
+
+ /* Read coefficient1 from onnx.fdata. */
+ for (int i = 0; i < COEFFICIENT1_ROW; i++)
+ for (int j = 0; j < COEFFICIENT1_COL; j++)
+ {
+ float result = read_float_from_file (file);
+ coefficient1[i][j] = result;
+ }
+
+ /* Read intercepts from onnx.fdata. */
+ for (int i = 0; i < INTERCEPTS_ROW; i++)
+ {
+ float result = read_float_from_file (file);
+ intercepts[i] = result;
+ }
+
+ /* Read intercepts1 from onnx.fdata. */
+ for (int i = 0; i < INTERCEPTS1_ROW; i++)
+ {
+ float result = read_float_from_file (file);
+ intercepts1[i] = result;
+ }
+
+ /* Read unity from onnx.fdata. */
+ for (int i = 0; i < UNITY_ROW; i++)
+ {
+ float result = read_float_from_file (file);
+ unity[i] = result;
+ }
+
+ fclose (file);
+ return;
+}
+
+static void
+matmul (const float *lhs, const float *rhs, int m, int k, int n, float *out)
+{
+ for (int i = 0; i < m; i++)
+ {
+ for (int j = 0; j < n; j++)
+ {
+ out[i * n + j] = 0.0f;
+ for (int p = 0; p < k; p++)
+ {
+ out[i * n + j] += lhs[i * k + p] * rhs[p * n + j];
+ }
+ }
+ }
+}
+
+static void
+add (const float *lhs, const float *rhs, int length, float *out)
+{
+ for (int i = 0; i < length; i++)
+ {
+ out[i] = lhs[i] + rhs[i];
+ }
+}
+
+static void
+sub (const float *lhs, const float *rhs, int length, float *out)
+{
+ for (int i = 0; i < length; i++)
+ {
+ out[i] = lhs[i] - rhs[i];
+ }
+}
+
+static void
+sigmoid (const float *in, int length, float *out)
+{
+ for (int i = 0; i < length; i++)
+ {
+ out[i] = 1.0f / (1.0f + expf (-in[i]));
+ }
+}
+
+static void
+relu (const float *data, int length, float *out)
+{
+ for (int i = 0; i < length; i++)
+ {
+ if (data[i] < 0)
+ {
+ out[i] = 0;
+ }
+ else
+ {
+ out[i] = data[i];
+ }
+ }
+}
+
+static void
+line_concat (const float *in, int in_size, float *out, int out_size)
+{
+ for (int i = 0; i < in_size; i++)
+ out[out_size + i] = in[i];
+}
+
+static void
+one_hot_encoder (const char *in, const char (*cats)[65], float *out,
+ int out_size)
+{
+ for (int i = 0; i < out_size; i++)
+ {
+ if (i < out_size && strcmp (cats[i], in) == 0)
+ {
+ out[i] = 1.0f;
+ }
+ else
+ {
+ out[i] = 0.0f;
+ }
+ }
+}
+
+static void
+imputer (const int64_t *in, int size, float *out)
+{
+ for (int i = 0; i < size; i++)
+ out[i] = in[i] * 1.0f;
+}
+
+static void
+scaler (const float *in, const float *offset, const float *scale, int size,
+ float *out)
+{
+ for (int i = 0; i < size; i++)
+ out[i] = (in[i] - offset[i]) * scale[i];
+}
+
+static int
+argmax (const float *in, int in_size)
+{
+ int out_idx = 0;
+ for (int i = 0; i < in_size; i++)
+ {
+ if (in[i] > in[out_idx])
+ out_idx = i;
+ }
+ return out_idx;
+}
+
+static void
+preprocess (int argc, int64_t *argv, int64_t *in_modes)
+{
+ int default_int_val= 0;
+ for (int i = 0; i < argc && i < M_MODE_SIZE; i++)
+ {
+ if (i < argc)
+ {
+ in_modes[i] = argv[i];
+ }
+ else
+ {
+ in_modes[i] = default_int_val;
+ }
+ }
+}
+
+/* The process of model inference. */
+static int
+graph_infer (int argc, const char *argv, int argc2, int64_t *argv2)
+{
+ const char *file_name = getenv ("GCC_AI4C_ONNX_FDATA");
+
+ if (access (file_name, F_OK) == 0)
+ {
+ fill_node (file_name);
+ }
+ else
+ {
+ return 0;
+ }
+
+ int64_t in_modes[M_MODE_SIZE];
+
+ preprocess (argc2, argv2, in_modes);
+
+ /* concat_result and encoder_out are intermediate computation results from
+ the ONNX model. concat_result is a 1 × 18 matrix, and encoder_out is a
+ 1 × 12 matrix. */
+
+ const int concat_out_size = 18;
+ float concat_result[concat_out_size];
+ const int encoder_out_size = 12;
+ float encoder_out[encoder_out_size];
+
+ one_hot_encoder (argv, cats_strings, encoder_out, encoder_out_size);
+
+ line_concat (encoder_out, encoder_out_size, concat_result, 0);
+
+ float variable[M_MODE_SIZE];
+ imputer (in_modes, M_MODE_SIZE, variable);
+
+ float variable1[M_MODE_SIZE];
+ scaler (variable, offset, scale, M_MODE_SIZE, variable1);
+ float transformed_column[concat_out_size + M_MODE_SIZE];
+ line_concat (variable1, M_MODE_SIZE, transformed_column, 0);
+ line_concat (concat_result, concat_out_size, transformed_column, 6);
+
+ /* This requires performing matrix multiplication between a 1 × 18 matrix
+ and an 18 × 100 matrix */
+
+ const int m = 1, k = 18, n = 100;
+ float mul_result[n];
+ matmul (transformed_column, coefficient[0], m, k, n, mul_result);
+
+ float add_result[n];
+ add (mul_result, intercepts, n, add_result);
+
+ float next_activations[n];
+ relu (add_result, n, next_activations);
+
+ /* This requires performing matrix multiplication between a 1 × 100 matrix
+ and an 100 × 1 matrix */
+
+ const int m2 = 1, k2 = 100, n2 = 1;
+ float mul_result1[n2];
+ matmul (next_activations, coefficient1[0], m2, k2, n2, mul_result1);
+
+ float add_result1[n2];
+ add (mul_result1, intercepts1, n2, add_result1);
+
+ float out_activations_result[n2];
+ sigmoid (add_result1, n2, out_activations_result);
+
+ float negative_class_proba[n2];
+ sub (unity, out_activations_result, n2, negative_class_proba);
+ const int prob_size = n2 + n2;
+ float probabilities[prob_size];
+ line_concat (negative_class_proba, n2, probabilities, 0);
+ line_concat (out_activations_result, n2, probabilities, n2);
+
+ int argmax_output = argmax (probabilities, prob_size);
+ return argmax_output;
+}
+
+void execute_sha256 (const char *input, char *output, size_t output_size)
+{
+ char command[256];
+ snprintf (command, sizeof (command), "echo -n \"%s\" | sha256sum", input);
+
+ FILE *pipe = popen (command, "r");
+ if (pipe == NULL)
+ {
+ perror ("Failed to run command.");
+ return;
+ }
+
+ fgets (output, output_size, pipe);
+ pclose (pipe);
+}
+
+int
+get_optimize_decision_from_ai4c ()
+{
+ if (initialized== 1)
+ {
+ return optimize_result;
+ }
+ if (native_tune && (strchr (native_tune, '+') != NULL))
+ {
+ char hash[65];
+ char input[64];
+ const char prefix = '=';
+ const char *start = strchr (native_tune, prefix);
+ if (start)
+ {
+ start += 1;
+ const char *end = strchr (start, '+');
+ if (!end)
+ {
+ end = native_tune + strlen (native_tune);
+ }
+ size_t len = end - start;
+ if (len >= sizeof (input))
+ len = sizeof (input) - 1;
+ strncpy (input, start, len);
+ input[len] = '\0';
+ }
+ else
+ input[0] = '\0';
+
+ execute_sha256 (input, hash, sizeof (hash));
+ optimize_result = graph_infer (1, hash, M_MODE_SIZE, argv_hw1);
+ initialized = 1;
+ if (optimize_result == 1)
+ setenv ("AI_GUIDED", "1", 1);
+ }
+ return optimize_result;
+}
diff --git a/gcc/ai4c-infer.h b/gcc/ai4c-infer.h
new file mode 100644
index 000000000..7fb75900b
--- /dev/null
+++ b/gcc/ai4c-infer.h
@@ -0,0 +1,29 @@
+/* Lightweight AI Inference Framework.
+
+ Copyright (C) 2024-2024 Free Software Foundation, Inc.
+
+ This file is part of GCC.
+
+ GCC is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 3, or (at your option) any later
+ version.
+
+ GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GCC; see the file COPYING3. If not see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef AI4C_INFER_H
+#define AI4C_INFER_H
+
+extern int get_optimize_decision_from_ai4c ();
+extern void set_cache_info (int prefetches, int l1_cache_size,
+ int l1_cache_line_size, int l2_cache_size,
+ int prefetch_latency, int prefetch_distance_factor);
+extern void prepare_native_tune_str (const char *info);
+#endif /* AI4C_INFER_H */
\ No newline at end of file
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 08a43541e..1d479f270 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18764,12 +18764,14 @@ override_C_optimize_options (struct gcc_options *opts)
opts->x_flag_ipa_struct_reorg = 6;
opts->x_struct_layout_optimize_level = 6;
opts->x_flag_gnu89_inline = 1;
- opts->x_flag_ccmp2 = 1;
- opts->x_flag_array_widen_compare = 1;
opts->x_flag_convert_minmax = 1;
opts->x_flag_tree_slp_transpose_vectorize = 1;
opts->x_param_max_inline_insns_auto = 64;
opts->x_param_inline_unit_growth = 96;
+ opts->x_param_pointer_compression_size = 16;
+ opts->x_semi_relayout_level = 14;
+ opts->x_flag_ipa_prefetch = 1;
+ opts->x_flag_ipa_ic = 1;
}
/* Check whether in CPP language or LTO with only CPP language. */
@@ -18826,6 +18828,8 @@ override_optimize_options_1 (struct gcc_options *opts)
opts->x_param_ifcvt_allow_register_renaming = 2;
opts->x_param_max_rtl_if_conversion_unpredictable_cost = 48;
opts->x_param_max_rtl_if_conversion_predictable_cost = 48;
+ opts->x_flag_ccmp2 = 1;
+ opts->x_flag_array_widen_compare = 1;
}
static void
@@ -18848,6 +18852,8 @@ override_Fortran_optimize_options (struct gcc_options *opts)
opts->x_flag_reorder_blocks = 1;
opts->x_flag_crypto_accel_aes = 1;
opts->x_param_flexible_seg_len = 1;
+ opts->x_flag_alias_analysis_expand_ssa = 1;
+ opts->x_flag_chrec_mul_fold_strict_overflow = 1;
}
/* Reset the optimize option.
@@ -18857,7 +18863,9 @@ static void
reset_machine_option (struct gcc_options *opts)
{
if (!(opts->x_optimize_maximum)
- || strstr (opts->x_aarch64_tune_string, "hip09") == NULL)
+ || opts->x_aarch64_cpu_string == NULL
+ || (strstr (opts->x_aarch64_cpu_string, "tsv110") == NULL
+ && strstr (opts->x_aarch64_cpu_string, "hip09") == NULL))
{
return;
}
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 32e45adc2..4592a4ec8 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -5798,6 +5798,9 @@ do_self_spec (const char *spec)
do_spec_2 (spec, NULL);
do_spec_1 (" ", 0, NULL);
+ const char* tune_native = eval_spec_function ("local_cpu_detect", "cpu", "");
+ setenv ("GCC_AI4C_TUNE_INFO", tune_native, 1);
+
/* Mark %<S switches processed by do_self_spec to be ignored permanently.
do_self_specs adds the replacements to switches array, so it shouldn't
be processed afterwards. */
@@ -8121,6 +8124,7 @@ driver::main (int argc, char **argv)
putenv_COLLECT_AS_OPTIONS (assembler_options);
putenv_COLLECT_GCC (argv[0]);
maybe_putenv_COLLECT_LTO_WRAPPER ();
+ putenv_ONNX_FDATA ();
maybe_putenv_OFFLOAD_TARGETS ();
handle_unrecognized_options ();
@@ -8551,6 +8555,34 @@ driver::putenv_COLLECT_GCC (const char *argv0) const
xputenv (XOBFINISH (&collect_obstack, char *));
}
+/* Set up to remember the pathname of the onnx.fdata. */
+
+void
+driver::putenv_ONNX_FDATA () const
+{
+ char *lto_wrapper_file;
+ lto_wrapper_file = find_a_program ("lto-wrapper");
+
+ if (lto_wrapper_file)
+ {
+ lto_wrapper_file = convert_white_space (lto_wrapper_file);
+ char native_file[512];
+ const char *onnx_fdata = "onnx.fdata";
+ strncpy (native_file, lto_wrapper_file, sizeof (native_file) - 1);
+ native_file[sizeof (native_file) - 1] = '\0';
+ char *last_slash = strrchr (native_file, '/');
+ if (last_slash)
+ strcpy (last_slash + 1, onnx_fdata);
+ obstack_init (&collect_obstack);
+ obstack_grow (&collect_obstack, "GCC_AI4C_ONNX_FDATA=",
+ sizeof ("GCC_AI4C_ONNX_FDATA=") - 1);
+ obstack_grow (&collect_obstack, native_file,
+ strlen ( native_file) + 1);
+ xputenv (XOBFINISH (&collect_obstack, char *));
+ }
+
+}
+
/* Set up to remember the pathname of the lto wrapper. */
void
diff --git a/gcc/gcc.h b/gcc/gcc.h
index 63231ddb3..ff3ae8bed 100644
--- a/gcc/gcc.h
+++ b/gcc/gcc.h
@@ -44,6 +44,7 @@ class driver
void set_up_specs () const;
void putenv_COLLECT_GCC (const char *argv0) const;
void maybe_putenv_COLLECT_LTO_WRAPPER () const;
+ void putenv_ONNX_FDATA () const;
void maybe_putenv_OFFLOAD_TARGETS () const;
void handle_unrecognized_options ();
int maybe_print_and_exit () const;
diff --git a/gcc/ipa-hardware-detection.cc b/gcc/ipa-hardware-detection.cc
index 8085a8c65..75b74aa03 100644
--- a/gcc/ipa-hardware-detection.cc
+++ b/gcc/ipa-hardware-detection.cc
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see
#include "cfghooks.h"
#include "gimple-fold.h"
#include "gimplify-me.h"
+#include "ai4c-infer.h"
namespace {
@@ -191,10 +192,11 @@ bool
pass_ipa_hardware_detection::gate (function *)
{
const char *ai_infer_level = getenv ("AI_INFER_LEVEL");
- return (ai_infer_level
+ const char *ai_guided = getenv ("AI_GUIDED");
+ return (ai_guided || (ai_infer_level
&& optimize_maximum > 0
/* Only enable in lto or whole_program. */
- && (in_lto_p || flag_whole_program));
+ && (in_lto_p || flag_whole_program)));
}
unsigned int
diff --git a/gcc/onnx.fdata b/gcc/onnx.fdata
new file mode 100644
index 000000000..234b1a045
--- /dev/null
+++ b/gcc/onnx.fdata
@@ -0,0 +1 @@
+316365613139376535626535626234666331363163303835336362393535613530636234643633626364386566396132333232373733633230393865663664633761393137633266616431663436343236613231663865636236346133616662623761373633663830623231393063616534633032316538626436633731643237666333386462313164333630303936336137323863313634613031393931613164363237643262353162376133643935373036306336346161376563383862613138666663393538363731333639396239666362393336373737643238636639643761343231346131333463353261623633343633343866663966663365346231356532663139306164303361383836396333393339616236383439363661313661303665643535633961666563613431303466333534346564633533373862323031396339626536613030383761623236663432633564653130353935353135313736656235373632373739343662663034343334633035626465356237633439313164313338373637383365326138366162363234323765393736616438656463343339613031316630643031613465386464326334383565343838366435313137313166383433396531626137353932616538333330653164326438656166343339363262366264326632376564396434396333356565343733383164363264633937356663663338666530336166316634623264393031393536333863383165616536656238346462656337333638323338646535303638363933646565616264363966356566323465346538613762623864303766646338666264643466666537303263623162326539653435643130313061386235623631306630636163303536343164663364383738353266386330376562343962393037306133383363326138393238376435613332353933663235313030326664366166373632343532613130323237303265373433623362623162633661633363303235613236383166313465396162353938363931613765316565313864313038cd68834331701041d1d21041f17c20432483a94386647e4157c8e33b5f3d5d3ec5275e3ea689863c435a0f3a76acd63d5d9b803b24467c3baf847c3b67b89e3b852a313b2127853900000000d58ac23b200ab53a000000807d3119bc22f7a63a81549f3b93b5013baee4a33b62c1153b9ae08b3a6929a33b20038f399475983b430ab53a73fc0b3a2daa0ebad595953bc2f1e0bb33e9ccbbb978d83a5e77a53b41e4c93adf10a73bdf36643ad7fd983a61e8d93bc04a283a30c072382f942c3b5b3cc73a4392e43a422b093c79bc61b9a5309e3b00000000757baa3a03d8a93c3c31e33af526ebbb000000006431d43a1d0ae73aa450783b8c57afb9b8eae939ec8fab3b9581d83920d7a1ba0fc1af38b6aece3ab50bafbbd50db63a26aba33bcdeda33b00d9493ac22dac3cf8c4233bc2966e3bdf1bca3a8fb4d13af9b0983b2cbda73bdae2aa3bc93bae3b39e1ba380857953be8e7a73b49e9df3b20b0233b9fe3d43a0dbcaa3bd10cf0b978eea53b761ebe3b0a50a23b70bd47b79a7720bc6cd4ee3ae0d0f93a9c333ebb5098dfbbbf8fa53b445efebac7b9993b6182b93aef267c3a4aa09e3b46d9a83b9f95983a379e913c6516123a1b2ebd3aaf943c3a0b90803becba92bce68f673be723253c5d7f813ad779613800000080af3c65ba6999743900000080957a003d82f2fe39baab4d3b7f348c39b8d3323b3c1e253ace952dbbc9d364bc3aafaf373d0a633be8fdee3968b0fa39eb70a83a7cba4e3bdf2407bc40f50f3d94f4c3b9a828573b3f2bc3b99a5763bcccb838bb24f011bae3400dbdc3074fba30a829bb3dde6e3ad7c2caba2b2aa7b8d479a7bbebe2603a7025583b00000000017414ba680386bc9b365e3aaacb03bc000000006afd90b9a64e263980eb223c80a48ebcca9703392310573b1fd419bbf7368abc17a2083a3ceafab95eb11cbcf29995b9a64264bc8bae403bc1dc6139631c88bc12e3373c07cf0c3cdc93a6b97edbc0b917754d3b5cdc143c61ef393b40a809baf3861dbbafce623be550513b828382bc359d513afa4a25ba31394c3bb013da3a9835553bf3d9553bec2b65bcee09bab9f6343e3c03a59f39fb11053a078e7cbc5bd006bcfe23363b08d12cbb3cfb533bb98a8fbadcb99139cbd1573b24725e3b01014fb6dcbc45ba6ee024bb318db1baf39ce9b952d625bc41afddb91d7dffbbc0ba163b0387b93b2594623b00000000f60cf9ba483c983b0000008015e6c6bcbd45983b77d62ebcfbb69f3b7b5752bcc334ab3b4f9806bc9d89063cc0675a3b807426bca81a9f3b7ef56f3b6a96a13a045937bcd4a2f33cb92173bc40af783b26ac40bc5fef6b3beba6fe3b8c7207bc5e25443bfd99a33be7e7403b4c2508bc0c87bb3bb95dcd3abe228b3bac03deb91a2ab03add753bbc000000002e04703be98f1fbccef2af3b17ebe93c0000000020e37a3b46ba913b1fd7003b1f3f133df85d423bacc843bc5fada7bbc8680d3d8423503b2afc6c3b4e43033dcfcc7c3bcece053cdbb44ebc4151823ba14426bc6e942c3b3bdc4d3a34967f3b7687783bd0cd3ebcfc75053ade324ebcd10c32bc9ff9fbbb0b7430bcf60e4abcd6b6e03b295db43b25c75d3b88334fbc8d95883ac9c73ebcddf941bc2b18083c43044c3b405414bd7617963b9910a03bd5e70c3d9356f23c3a2750bc472107bce47d47bc0125243b3c41953b0f6134bc8c403bbc8fb3873ba5e218bcae5d06bc2dfe103b758a493b43cef63cd7438d3c2bf1eb3b2d4a833cf13a43bc5d14c4bd000000002932a7
\ No newline at end of file
diff --git a/gcc/opts-global.cc b/gcc/opts-global.cc
index a18c76940..e684bc5e3 100644
--- a/gcc/opts-global.cc
+++ b/gcc/opts-global.cc
@@ -39,6 +39,7 @@ along with GCC; see the file COPYING3. If not see
#include "attribs.h"
#include "asan.h"
#include "file-prefix-map.h" /* add_*_prefix_map() */
+#include "ai4c-infer.h"
typedef const char *const_char_p; /* For DEF_VEC_P. */
@@ -304,6 +305,15 @@ decode_options (struct gcc_options *opts, struct gcc_options *opts_set,
location_t loc, diagnostic_context *dc,
void (*target_option_override_hook) (void))
{
+ set_cache_info (global_options.x_param_simultaneous_prefetches,
+ global_options.x_param_l1_cache_size,
+ global_options.x_param_l1_cache_line_size,
+ global_options.x_param_l2_cache_size,
+ global_options.x_param_prefetch_latency,
+ global_options.x_param_ipa_prefetch_distance_factor);
+ const char *tune_native = getenv ("GCC_AI4C_TUNE_INFO");
+ prepare_native_tune_str (tune_native);
+
struct cl_option_handlers handlers;
unsigned int lang_mask;
--
2.33.0