!540 [SPEC&CSPGO] Fix SPEC and update the gate of cspgo
From: @li-yancheng Reviewed-by: @huang-xiaoquan Signed-off-by: @huang-xiaoquan
This commit is contained in:
commit
18dffd876c
@ -67,401 +67,401 @@ index 000000000..c3d99dd85
|
||||
--- /dev/null
|
||||
+++ b/gcc/ai-optimizer.cc
|
||||
@@ -0,0 +1,395 @@
|
||||
+/* 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 <cassert>
|
||||
+#include "config.h"
|
||||
+#include "system.h"
|
||||
+#include "ai4c-infer.h"
|
||||
+
|
||||
+#define M_OPTION_SIZE 11
|
||||
+#define M_MODE_SIZE 6
|
||||
+#define NATIVE_TUNE_SIZE 128
|
||||
+#define CATS_STRINGS_ROW 34
|
||||
+#define CATS_STRINGS_COL 65
|
||||
+#define CATS_STRINGS1_ROW 10
|
||||
+#define CATS_STRINGS1_COL 65
|
||||
+#define OFFSET_ROW 6
|
||||
+#define SCALE_ROW 6
|
||||
+#define UNITY_ROW 1
|
||||
+#define COEFFICIENT_ROW 356
|
||||
+#define COEFFICIENT_COL 10
|
||||
+#define COEFFICIENT1_ROW 10
|
||||
+#define COEFFICIENT1_COL 1
|
||||
+#define INTERCEPTS_ROW 10
|
||||
+#define INTERCEPTS1_ROW 1
|
||||
+
|
||||
+/* Intermediate computation results from the ONNX model. */
|
||||
+static char cats_strings[CATS_STRINGS_ROW][CATS_STRINGS_COL];
|
||||
+static char cats_strings1[CATS_STRINGS1_ROW][CATS_STRINGS1_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];
|
||||
+
|
||||
+/* Return an integer that represents the comparison result of the
|
||||
+ two strings. */
|
||||
+
|
||||
+static int
|
||||
+compare_strings (const void *a, const void *b)
|
||||
+{
|
||||
+ const char *str_a = *(const char **)a;
|
||||
+ const char *str_b = *(const char **)b;
|
||||
+
|
||||
+ int len = strlen (str_a) < strlen (str_b) ? strlen (str_a) : strlen (str_b);
|
||||
+ for (int i = 0; i < len; i++)
|
||||
+ {
|
||||
+ char c1 = str_a[i];
|
||||
+ char c2 = str_b[i];
|
||||
+ if (ISUPPER (c1) && !ISUPPER (c2))
|
||||
+ return 0;
|
||||
+ else if (!ISUPPER (c1) && ISUPPER (c2))
|
||||
+ return 1;
|
||||
+ else if (c1 != c2)
|
||||
+ return c1 < c2;
|
||||
+ }
|
||||
+ return strlen (str_a) > strlen (str_b);
|
||||
+}
|
||||
+
|
||||
+/* Return the substring before the first underscore ('_') in the input
|
||||
+ string. */
|
||||
+
|
||||
+static void
|
||||
+truncate_prefix (const char *str, char *result)
|
||||
+{
|
||||
+ const char *underscore_pos = strchr (str, '_');
|
||||
+ if (underscore_pos == NULL)
|
||||
+ {
|
||||
+ strcpy (result, str);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ size_t len = underscore_pos - str;
|
||||
+ strncpy (result, str, len + 1);
|
||||
+ result[len + 1] = '\0';
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+preprocess (int argc1, const char **argv1, const char *mops,
|
||||
+ int argc2, int64_t *argv2, char (*in_options)[1024],
|
||||
+ int64_t *in_modes)
|
||||
+{
|
||||
+ strcpy (in_options[0], mops);
|
||||
+
|
||||
+ const char *output_option = "-o";
|
||||
+ const char *marco_prefix = "-D";
|
||||
+ const char *needle = "--param";
|
||||
+ const char *flag_prefix = "-";
|
||||
+ const char *default_option = "-default-option";
|
||||
+ const int default_int_val = 0;
|
||||
+ int m_size = 0;
|
||||
+ for (int i = 0; i < argc1; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) == 0)
|
||||
+ m_size ++;
|
||||
+ }
|
||||
+
|
||||
+ char *m_options[m_size];
|
||||
+ char output_file[1024];
|
||||
+ int m_index = 0;
|
||||
+ for (int i = 0; i < argc1; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) == 0)
|
||||
+ {
|
||||
+ m_options[m_index] = (char *)argv1[i];
|
||||
+ m_index ++;
|
||||
+ }
|
||||
+ if (strcmp (argv1[i], output_option) == 0)
|
||||
+ truncate_prefix (argv1[i + 1], output_file);
|
||||
+ }
|
||||
+
|
||||
+ strcpy (in_options[1], output_file);
|
||||
+ int in_options_size = 2;
|
||||
+ qsort (m_options, m_size, sizeof (m_options[0]), compare_strings);
|
||||
+ for (int i = 0; i < m_size && in_options_size < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], m_options[i]);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < argc1 && in_options_size < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) != 0
|
||||
+ && strcmp (argv1[i], output_option) != 0
|
||||
+ && strncmp (argv1[i], needle, 7) != 0
|
||||
+ && strncmp (argv1[i], flag_prefix, 1) == 0)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], argv1[i]);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ while (in_options_size < M_OPTION_SIZE)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], default_option);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+
|
||||
+ /* Use sha256 to encrypt the input. */
|
||||
+ char hash[65];
|
||||
+ char input[64];
|
||||
+ for (int i = 0; i < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ execute_sha256 (in_options[i], hash, sizeof (hash));
|
||||
+ strcpy (in_options[i], hash);
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < argc2 && i < M_MODE_SIZE; i++)
|
||||
+ {
|
||||
+ if (i < argc2)
|
||||
+ in_modes[i] = argv2[i];
|
||||
+ else
|
||||
+ in_modes[i] = default_int_val;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* To read model parameter information from optimizer.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 optimizer.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 optimizer.fdata.");
|
||||
+ return;
|
||||
+ }
|
||||
+ cats_strings[i][j] = (unsigned char) strtol(hex_string, NULL, 16);
|
||||
+ }
|
||||
+ cats_strings[i][CATS_STRINGS_COL - 1] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* Read cats_strings1 from optimizer.fdata. */
|
||||
+ for (int i = 0; i < CATS_STRINGS1_ROW; i++)
|
||||
+ {
|
||||
+ for (int j = 0; j < CATS_STRINGS1_COL - 1; j++)
|
||||
+ {
|
||||
+ if (fscanf (file, "%2s", hex_string) != 1)
|
||||
+ {
|
||||
+ perror ("Can not read cats_strings1 from optimizer.fdata.");
|
||||
+ return;
|
||||
+ }
|
||||
+ cats_strings1[i][j] = (unsigned char) strtol(hex_string, NULL, 16);
|
||||
+ }
|
||||
+ cats_strings1[i][CATS_STRINGS1_COL - 1] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* Read offset from optimizer.fdata. */
|
||||
+ for (int i = 0; i < OFFSET_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ offset[i] = result;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /* Read scale from optimizer.fdata. */
|
||||
+ for (int i = 0; i < SCALE_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ scale[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read unity from optimizer.fdata. */
|
||||
+ for (int i = 0; i < UNITY_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ unity[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read coefficient from optimizer.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 optimizer.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 optimizer.fdata. */
|
||||
+ for (int i = 0; i < INTERCEPTS_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ intercepts[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read intercepts1 from optimizer.fdata. */
|
||||
+ for (int i = 0; i < INTERCEPTS1_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ intercepts1[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ fclose (file);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+/* The process of model inference. */
|
||||
+
|
||||
+static int
|
||||
+graph_infer (int argc1, const char **argv1, const char *mops,
|
||||
+ int argc2, int64_t *argv2)
|
||||
+{
|
||||
+ char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
+ if (gcc_exec_prefix == NULL)
|
||||
+ return 0;
|
||||
+ char native_file[512];
|
||||
+
|
||||
+ if (gcc_exec_prefix)
|
||||
+ {
|
||||
+ const char *onnx_fdata = "optimizer.fdata";
|
||||
+ strncpy (native_file, gcc_exec_prefix, 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);
|
||||
+ }
|
||||
+
|
||||
+ if (access (native_file, F_OK) == 0)
|
||||
+ fill_node (native_file);
|
||||
+ else
|
||||
+ return 0;
|
||||
+
|
||||
+ static int64_t in_modes[M_MODE_SIZE];
|
||||
+ static char in_options[M_OPTION_SIZE][1024];
|
||||
+
|
||||
+ preprocess (argc1, argv1, mops, argc2, argv2, in_options, 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 = 350;
|
||||
+ float concat_result[concat_out_size];
|
||||
+ const int encoder_out_size = 34;
|
||||
+ const int encoder_last_size = 10;
|
||||
+ int concat_size = 0;
|
||||
+ const int size = encoder_out_size;
|
||||
+
|
||||
+ for (int i = 1; i < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ float encoder_out[size];
|
||||
+ one_hot_encoder (in_options[i], cats_strings, encoder_out, size);
|
||||
+ line_concat (encoder_out, size, concat_result, concat_size);
|
||||
+ concat_size += size;
|
||||
+ }
|
||||
+
|
||||
+ float encoder_out2[encoder_last_size];
|
||||
+ one_hot_encoder (in_options[0], cats_strings1, encoder_out2,
|
||||
+ encoder_last_size);
|
||||
+ line_concat (encoder_out2, encoder_last_size, concat_result, concat_size);
|
||||
+ concat_size += encoder_last_size;
|
||||
+
|
||||
+ 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 is used to stro*/
|
||||
+ 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 × 356 matrix
|
||||
+ and an 356 × 10 matrix */
|
||||
+
|
||||
+ const int m = 1, k = 356, n = 10;
|
||||
+ 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 × 10 matrix
|
||||
+ and an 10 × 1 matrix */
|
||||
+
|
||||
+ const int m2 = 1, k2 = 10, 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;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+get_optimize_decision_from_optimizer (int argc, const char **argv,
|
||||
+ const char *mops, int argc2,
|
||||
+ int64_t *argv2)
|
||||
+{
|
||||
+ int model_pred = graph_infer (argc, argv, mops, argc2, argv2);
|
||||
+ if (model_pred == 1)
|
||||
+ {
|
||||
+ putenv ("AI_INFER_LEVEL=1");
|
||||
+ }
|
||||
+ return model_pred;
|
||||
+}
|
||||
+/* 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 <cassert>
|
||||
+#include "config.h"
|
||||
+#include "system.h"
|
||||
+#include "ai4c-infer.h"
|
||||
+
|
||||
+#define M_OPTION_SIZE 11
|
||||
+#define M_MODE_SIZE 6
|
||||
+#define NATIVE_TUNE_SIZE 128
|
||||
+#define CATS_STRINGS_ROW 34
|
||||
+#define CATS_STRINGS_COL 65
|
||||
+#define CATS_STRINGS1_ROW 10
|
||||
+#define CATS_STRINGS1_COL 65
|
||||
+#define OFFSET_ROW 6
|
||||
+#define SCALE_ROW 6
|
||||
+#define UNITY_ROW 1
|
||||
+#define COEFFICIENT_ROW 356
|
||||
+#define COEFFICIENT_COL 10
|
||||
+#define COEFFICIENT1_ROW 10
|
||||
+#define COEFFICIENT1_COL 1
|
||||
+#define INTERCEPTS_ROW 10
|
||||
+#define INTERCEPTS1_ROW 1
|
||||
+
|
||||
+/* Intermediate computation results from the ONNX model. */
|
||||
+static char cats_strings[CATS_STRINGS_ROW][CATS_STRINGS_COL];
|
||||
+static char cats_strings1[CATS_STRINGS1_ROW][CATS_STRINGS1_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];
|
||||
+
|
||||
+/* Return an integer that represents the comparison result of the
|
||||
+ two strings. */
|
||||
+
|
||||
+static int
|
||||
+compare_strings (const void *a, const void *b)
|
||||
+{
|
||||
+ const char *str_a = *(const char **)a;
|
||||
+ const char *str_b = *(const char **)b;
|
||||
+
|
||||
+ int len = strlen (str_a) < strlen (str_b) ? strlen (str_a) : strlen (str_b);
|
||||
+ for (int i = 0; i < len; i++)
|
||||
+ {
|
||||
+ char c1 = str_a[i];
|
||||
+ char c2 = str_b[i];
|
||||
+ if (ISUPPER (c1) && !ISUPPER (c2))
|
||||
+ return 0;
|
||||
+ else if (!ISUPPER (c1) && ISUPPER (c2))
|
||||
+ return 1;
|
||||
+ else if (c1 != c2)
|
||||
+ return c1 < c2;
|
||||
+ }
|
||||
+ return strlen (str_a) > strlen (str_b);
|
||||
+}
|
||||
+
|
||||
+/* Return the substring before the first underscore ('_') in the input
|
||||
+ string. */
|
||||
+
|
||||
+static void
|
||||
+truncate_prefix (const char *str, char *result)
|
||||
+{
|
||||
+ const char *underscore_pos = strchr (str, '_');
|
||||
+ if (underscore_pos == NULL)
|
||||
+ {
|
||||
+ strcpy (result, str);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ size_t len = underscore_pos - str;
|
||||
+ strncpy (result, str, len + 1);
|
||||
+ result[len + 1] = '\0';
|
||||
+}
|
||||
+
|
||||
+
|
||||
+static void
|
||||
+preprocess (int argc1, const char **argv1, const char *mops,
|
||||
+ int argc2, int64_t *argv2, char (*in_options)[1024],
|
||||
+ int64_t *in_modes)
|
||||
+{
|
||||
+ strcpy (in_options[0], mops);
|
||||
+
|
||||
+ const char *output_option = "-o";
|
||||
+ const char *marco_prefix = "-D";
|
||||
+ const char *needle = "--param";
|
||||
+ const char *flag_prefix = "-";
|
||||
+ const char *default_option = "-default-option";
|
||||
+ const int default_int_val = 0;
|
||||
+ int m_size = 0;
|
||||
+ for (int i = 0; i < argc1; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) == 0)
|
||||
+ m_size ++;
|
||||
+ }
|
||||
+
|
||||
+ char *m_options[m_size];
|
||||
+ char output_file[1024];
|
||||
+ int m_index = 0;
|
||||
+ for (int i = 0; i < argc1; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) == 0)
|
||||
+ {
|
||||
+ m_options[m_index] = (char *)argv1[i];
|
||||
+ m_index ++;
|
||||
+ }
|
||||
+ if (strcmp (argv1[i], output_option) == 0)
|
||||
+ truncate_prefix (argv1[i + 1], output_file);
|
||||
+ }
|
||||
+
|
||||
+ strcpy (in_options[1], output_file);
|
||||
+ int in_options_size = 2;
|
||||
+ qsort (m_options, m_size, sizeof (m_options[0]), compare_strings);
|
||||
+ for (int i = 0; i < m_size && in_options_size < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], m_options[i]);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < argc1 && in_options_size < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ if (strncmp (argv1[i], marco_prefix, 2) != 0
|
||||
+ && strcmp (argv1[i], output_option) != 0
|
||||
+ && strncmp (argv1[i], needle, 7) != 0
|
||||
+ && strncmp (argv1[i], flag_prefix, 1) == 0)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], argv1[i]);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ while (in_options_size < M_OPTION_SIZE)
|
||||
+ {
|
||||
+ strcpy (in_options[in_options_size], default_option);
|
||||
+ in_options_size ++;
|
||||
+ }
|
||||
+
|
||||
+ /* Use sha256 to encrypt the input. */
|
||||
+ char hash[65];
|
||||
+ char input[64];
|
||||
+ for (int i = 0; i < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ execute_sha256 (in_options[i], hash, sizeof (hash));
|
||||
+ strcpy (in_options[i], hash);
|
||||
+ }
|
||||
+
|
||||
+ for (int i = 0; i < argc2 && i < M_MODE_SIZE; i++)
|
||||
+ {
|
||||
+ if (i < argc2)
|
||||
+ in_modes[i] = argv2[i];
|
||||
+ else
|
||||
+ in_modes[i] = default_int_val;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+/* To read model parameter information from optimizer.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 optimizer.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 optimizer.fdata.");
|
||||
+ return;
|
||||
+ }
|
||||
+ cats_strings[i][j] = (unsigned char) strtol(hex_string, NULL, 16);
|
||||
+ }
|
||||
+ cats_strings[i][CATS_STRINGS_COL - 1] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* Read cats_strings1 from optimizer.fdata. */
|
||||
+ for (int i = 0; i < CATS_STRINGS1_ROW; i++)
|
||||
+ {
|
||||
+ for (int j = 0; j < CATS_STRINGS1_COL - 1; j++)
|
||||
+ {
|
||||
+ if (fscanf (file, "%2s", hex_string) != 1)
|
||||
+ {
|
||||
+ perror ("Can not read cats_strings1 from optimizer.fdata.");
|
||||
+ return;
|
||||
+ }
|
||||
+ cats_strings1[i][j] = (unsigned char) strtol(hex_string, NULL, 16);
|
||||
+ }
|
||||
+ cats_strings1[i][CATS_STRINGS1_COL - 1] = '\0';
|
||||
+ }
|
||||
+
|
||||
+ /* Read offset from optimizer.fdata. */
|
||||
+ for (int i = 0; i < OFFSET_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ offset[i] = result;
|
||||
+ }
|
||||
+
|
||||
+
|
||||
+ /* Read scale from optimizer.fdata. */
|
||||
+ for (int i = 0; i < SCALE_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ scale[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read unity from optimizer.fdata. */
|
||||
+ for (int i = 0; i < UNITY_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ unity[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read coefficient from optimizer.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 optimizer.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 optimizer.fdata. */
|
||||
+ for (int i = 0; i < INTERCEPTS_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ intercepts[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ /* Read intercepts1 from optimizer.fdata. */
|
||||
+ for (int i = 0; i < INTERCEPTS1_ROW; i++)
|
||||
+ {
|
||||
+ float result = read_float_from_file (file);
|
||||
+ intercepts1[i] = result;
|
||||
+ }
|
||||
+
|
||||
+ fclose (file);
|
||||
+ return;
|
||||
+}
|
||||
+
|
||||
+/* The process of model inference. */
|
||||
+
|
||||
+static int
|
||||
+graph_infer (int argc1, const char **argv1, const char *mops,
|
||||
+ int argc2, int64_t *argv2)
|
||||
+{
|
||||
+ char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
+ if (gcc_exec_prefix == NULL)
|
||||
+ return 0;
|
||||
+ char native_file[512];
|
||||
+
|
||||
+ if (gcc_exec_prefix)
|
||||
+ {
|
||||
+ const char *onnx_fdata = "optimizer.fdata";
|
||||
+ strncpy (native_file, gcc_exec_prefix, 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);
|
||||
+ }
|
||||
+
|
||||
+ if (access (native_file, F_OK) == 0)
|
||||
+ fill_node (native_file);
|
||||
+ else
|
||||
+ return 0;
|
||||
+
|
||||
+ static int64_t in_modes[M_MODE_SIZE];
|
||||
+ static char in_options[M_OPTION_SIZE][1024];
|
||||
+
|
||||
+ preprocess (argc1, argv1, mops, argc2, argv2, in_options, 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 = 350;
|
||||
+ float concat_result[concat_out_size];
|
||||
+ const int encoder_out_size = 34;
|
||||
+ const int encoder_last_size = 10;
|
||||
+ int concat_size = 0;
|
||||
+ const int size = encoder_out_size;
|
||||
+
|
||||
+ for (int i = 1; i < M_OPTION_SIZE; i++)
|
||||
+ {
|
||||
+ float encoder_out[size];
|
||||
+ one_hot_encoder (in_options[i], cats_strings, encoder_out, size);
|
||||
+ line_concat (encoder_out, size, concat_result, concat_size);
|
||||
+ concat_size += size;
|
||||
+ }
|
||||
+
|
||||
+ float encoder_out2[encoder_last_size];
|
||||
+ one_hot_encoder (in_options[0], cats_strings1, encoder_out2,
|
||||
+ encoder_last_size);
|
||||
+ line_concat (encoder_out2, encoder_last_size, concat_result, concat_size);
|
||||
+ concat_size += encoder_last_size;
|
||||
+
|
||||
+ 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 is used to stro*/
|
||||
+ 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 × 356 matrix
|
||||
+ and an 356 × 10 matrix */
|
||||
+
|
||||
+ const int m = 1, k = 356, n = 10;
|
||||
+ 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 × 10 matrix
|
||||
+ and an 10 × 1 matrix */
|
||||
+
|
||||
+ const int m2 = 1, k2 = 10, 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;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+get_optimize_decision_from_optimizer (int argc, const char **argv,
|
||||
+ const char *mops, int argc2,
|
||||
+ int64_t *argv2)
|
||||
+{
|
||||
+ int model_pred = graph_infer (argc, argv, mops, argc2, argv2);
|
||||
+ if (model_pred == 1)
|
||||
+ {
|
||||
+ putenv ("AI_INFER_LEVEL=1");
|
||||
+ }
|
||||
+ return model_pred;
|
||||
+}
|
||||
diff --git a/gcc/ai4c-infer.cc b/gcc/ai4c-infer.cc
|
||||
index 99f7a6b45..42922e1ca 100644
|
||||
--- a/gcc/ai4c-infer.cc
|
||||
@ -15,65 +15,65 @@ index c3d99dd85..70ff24077 100644
|
||||
--- a/gcc/ai-optimizer.cc
|
||||
+++ b/gcc/ai-optimizer.cc
|
||||
@@ -284,19 +284,50 @@ static int
|
||||
graph_infer (int argc1, const char **argv1, const char *mops,
|
||||
int argc2, int64_t *argv2)
|
||||
{
|
||||
- char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
- if (gcc_exec_prefix == NULL)
|
||||
+ char gcc_exec_prefix[512];
|
||||
+ ssize_t len = readlink ("/proc/self/exe", gcc_exec_prefix,
|
||||
+ sizeof (gcc_exec_prefix) - 1);
|
||||
+ if (len == -1)
|
||||
return 0;
|
||||
- char native_file[512];
|
||||
|
||||
- if (gcc_exec_prefix)
|
||||
+ char native_file[512];
|
||||
+ strncpy (native_file, gcc_exec_prefix, sizeof (native_file) - 1);
|
||||
+ const char *target = "bin/gcc";
|
||||
+ const char *target_cc1 = "cc1";
|
||||
+ const char *target_gpp = "bin/g++";
|
||||
+ const char *target_cc1plus = "cc1plus";
|
||||
+ const char *target_gfortran = "bin/gfortran";
|
||||
+ const char *target_f951 = "f951";
|
||||
+ const char *replacement = "../libexec/gcc/optimizer.fdata";
|
||||
+ const char *replacement_front_end = "../../optimizer.fdata";
|
||||
+
|
||||
+ /* Replace the part of the current executable file path after the last slash
|
||||
+ to locate the model file. */
|
||||
+ if (strstr (native_file, target) != NULL ||
|
||||
+ strstr (native_file, target_gpp) != NULL ||
|
||||
+ strstr (native_file, target_gfortran) != NULL)
|
||||
{
|
||||
- const char *onnx_fdata = "optimizer.fdata";
|
||||
- strncpy (native_file, gcc_exec_prefix, 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);
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (strstr (native_file, target_cc1) != NULL ||
|
||||
+ strstr (native_file, target_cc1plus) != NULL ||
|
||||
+ strstr (native_file, target_f951) != NULL)
|
||||
+ {
|
||||
+ char *last_slash = strrchr (native_file, '/');
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement_front_end, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (access (native_file, F_OK) == 0)
|
||||
graph_infer (int argc1, const char **argv1, const char *mops,
|
||||
int argc2, int64_t *argv2)
|
||||
{
|
||||
- char *gcc_exec_prefix = getenv ("ONNX_FDATA_PATH");
|
||||
- if (gcc_exec_prefix == NULL)
|
||||
+ char gcc_exec_prefix[512];
|
||||
+ ssize_t len = readlink ("/proc/self/exe", gcc_exec_prefix,
|
||||
+ sizeof (gcc_exec_prefix) - 1);
|
||||
+ if (len == -1)
|
||||
return 0;
|
||||
- char native_file[512];
|
||||
|
||||
- if (gcc_exec_prefix)
|
||||
+ char native_file[512];
|
||||
+ strncpy (native_file, gcc_exec_prefix, sizeof (native_file) - 1);
|
||||
+ const char *target = "bin/gcc";
|
||||
+ const char *target_cc1 = "cc1";
|
||||
+ const char *target_gpp = "bin/g++";
|
||||
+ const char *target_cc1plus = "cc1plus";
|
||||
+ const char *target_gfortran = "bin/gfortran";
|
||||
+ const char *target_f951 = "f951";
|
||||
+ const char *replacement = "../libexec/gcc/optimizer.fdata";
|
||||
+ const char *replacement_front_end = "../../optimizer.fdata";
|
||||
+
|
||||
+ /* Replace the part of the current executable file path after the last slash
|
||||
+ to locate the model file. */
|
||||
+ if (strstr (native_file, target) != NULL ||
|
||||
+ strstr (native_file, target_gpp) != NULL ||
|
||||
+ strstr (native_file, target_gfortran) != NULL)
|
||||
{
|
||||
- const char *onnx_fdata = "optimizer.fdata";
|
||||
- strncpy (native_file, gcc_exec_prefix, 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);
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
+ }
|
||||
+ else if (strstr (native_file, target_cc1) != NULL ||
|
||||
+ strstr (native_file, target_cc1plus) != NULL ||
|
||||
+ strstr (native_file, target_f951) != NULL)
|
||||
+ {
|
||||
+ char *last_slash = strrchr (native_file, '/');
|
||||
+ if (last_slash != NULL)
|
||||
+ {
|
||||
+ size_t prefix_len = last_slash - native_file + 1;
|
||||
+ native_file[prefix_len] = '\0';
|
||||
+ strncat (native_file, replacement_front_end, sizeof (native_file) -
|
||||
+ strlen (native_file) - 1);
|
||||
+ }
|
||||
}
|
||||
|
||||
if (access (native_file, F_OK) == 0)
|
||||
diff --git a/gcc/ai4c-infer.cc b/gcc/ai4c-infer.cc
|
||||
index 42922e1ca..4cd4bfb00 100644
|
||||
--- a/gcc/ai4c-infer.cc
|
||||
|
||||
88
0333-CSPGO-Update-the-gate-of-cspgo.patch
Normal file
88
0333-CSPGO-Update-the-gate-of-cspgo.patch
Normal file
@ -0,0 +1,88 @@
|
||||
From 25f3b77d288e26b198c7836c3ed9b4fb0a85a48a Mon Sep 17 00:00:00 2001
|
||||
From: liyancheng <412998149@qq.com>
|
||||
Date: Mon, 16 Dec 2024 15:52:22 +0800
|
||||
Subject: [PATCH] [CSPGO] Update the gate of cspgo
|
||||
|
||||
Update gate to allow CSPGO to be enabled after PGO
|
||||
---
|
||||
gcc/tree-profile.cc | 59 +++++++++++++++++++++++++++------------------
|
||||
1 file changed, 36 insertions(+), 23 deletions(-)
|
||||
|
||||
diff --git a/gcc/tree-profile.cc b/gcc/tree-profile.cc
|
||||
index ace1fe31c..3c57a0a75 100644
|
||||
--- a/gcc/tree-profile.cc
|
||||
+++ b/gcc/tree-profile.cc
|
||||
@@ -1108,34 +1108,47 @@ public:
|
||||
/* opt_pass methods: */
|
||||
virtual bool gate (function *)
|
||||
{
|
||||
- return (flag_csprofile_generate || flag_csprofile_use);
|
||||
- }
|
||||
- /* The main process of cspgo is in csprofile_transform, execute does not need
|
||||
- to do anything. */
|
||||
- virtual unsigned int execute (function *)
|
||||
- {
|
||||
- if (!profile_data_prefix)
|
||||
- error ("profile_data_prefix must set when using cspgo.");
|
||||
+ if (flag_csprofile_generate || flag_csprofile_use)
|
||||
+ {
|
||||
+ int ret = true;
|
||||
+ if (!profile_data_prefix)
|
||||
+ {
|
||||
+ error ("pgo profile path must set when using cspgo.");
|
||||
+ ret = false;
|
||||
+ }
|
||||
|
||||
- if (!csprofile_data_prefix)
|
||||
- error ("csprofile_data_prefix must set when using cspgo.");
|
||||
+ if (!csprofile_data_prefix)
|
||||
+ {
|
||||
+ error ("cspgo profile path must set when using cspgo.");
|
||||
+ ret = false;
|
||||
+ }
|
||||
|
||||
- if (!flag_cfgo_profile_use)
|
||||
- error ("cspgo must used with cfgo-pgo.");
|
||||
+ if (!(flag_cfgo_profile_use || flag_profile_use))
|
||||
+ {
|
||||
+ error ("cspgo must used with cfgo-pgo or pgo.");
|
||||
+ ret = false;
|
||||
+ }
|
||||
|
||||
- /* Just compare canonical pathnames. */
|
||||
- char* cfgo_pgo_path = lrealpath (profile_data_prefix);
|
||||
- char* cfgo_cspgo_path = lrealpath (csprofile_data_prefix);
|
||||
- bool files_differ = filename_cmp (cfgo_pgo_path, cfgo_cspgo_path);
|
||||
- if (!files_differ)
|
||||
- {
|
||||
- error ("pgo and cspgo path must different between %s and %s",
|
||||
- cfgo_pgo_path, cfgo_cspgo_path);
|
||||
+ /* pgo and cspgo path must different. */
|
||||
+ char* cfgo_pgo_path = lrealpath (profile_data_prefix);
|
||||
+ char* cfgo_cspgo_path = lrealpath (csprofile_data_prefix);
|
||||
+ bool files_differ = filename_cmp (cfgo_pgo_path, cfgo_cspgo_path);
|
||||
+ if (!files_differ)
|
||||
+ {
|
||||
+ error ("pgo and cspgo path must different between %s and %s",
|
||||
+ cfgo_pgo_path, cfgo_cspgo_path);
|
||||
+ ret = false;
|
||||
+ }
|
||||
+ free (cfgo_pgo_path);
|
||||
+ free (cfgo_cspgo_path);
|
||||
+
|
||||
+ return ret;
|
||||
}
|
||||
- free (cfgo_pgo_path);
|
||||
- free (cfgo_cspgo_path);
|
||||
- return 0;
|
||||
+ return false;
|
||||
}
|
||||
+ /* The main process of cspgo is in csprofile_transform, execute does not need
|
||||
+ to do anything. */
|
||||
+ virtual unsigned int execute (function *) { return 0; }
|
||||
|
||||
}; // class pass_ipa_csprofile
|
||||
|
||||
--
|
||||
2.25.1
|
||||
|
||||
27
0334-Dont-use-local_detect_cpu-when-cross-build.patch
Normal file
27
0334-Dont-use-local_detect_cpu-when-cross-build.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From cd708367a6558eca37715f8068f044a55402edab Mon Sep 17 00:00:00 2001
|
||||
From: YunQiang Su <yunqiang@isrc.iscas.ac.cn>
|
||||
Date: Wed, 18 Dec 2024 14:22:03 +0800
|
||||
Subject: [PATCH] Don't use local_detect_cpu when cross build
|
||||
|
||||
-march=native makes no sense for cross build.
|
||||
---
|
||||
gcc/gcc.cc | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
|
||||
index 179d507f255..f2387e0fae2 100644
|
||||
--- a/gcc/gcc.cc
|
||||
+++ b/gcc/gcc.cc
|
||||
@@ -5800,7 +5800,7 @@ do_self_spec (const char *spec)
|
||||
do_spec_1 (" ", 0, NULL);
|
||||
|
||||
const char* tune_native = NULL;
|
||||
-#if defined (__x86_64__) || defined (__aarch64__)
|
||||
+#if !defined(CROSS_DIRECTORY_STRUCTURE) && (defined (__x86_64__) || defined (__aarch64__))
|
||||
tune_native = eval_spec_function ("local_cpu_detect", "cpu", "");
|
||||
#endif
|
||||
if (tune_native == NULL)
|
||||
--
|
||||
Gitee
|
||||
|
||||
|
||||
41
0335-fix-costs-for-hip09.patch
Normal file
41
0335-fix-costs-for-hip09.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 00cd602772e471a18b3b36abfa3bde382d239b1f Mon Sep 17 00:00:00 2001
|
||||
From: Mingchuan Wu <wumingchuan1992@foxmail.com>
|
||||
Date: Thu, 26 Dec 2024 11:11:41 +0800
|
||||
Subject: [PATCH] [bugfix] fix costs for hip09.
|
||||
|
||||
---
|
||||
gcc/config/aarch64/aarch64.cc | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
|
||||
index e487ba12bad..65b684ef60f 100644
|
||||
--- a/gcc/config/aarch64/aarch64.cc
|
||||
+++ b/gcc/config/aarch64/aarch64.cc
|
||||
@@ -749,8 +749,8 @@ static const struct cpu_regmove_cost hip09_regmove_cost =
|
||||
1, /* GP2GP */
|
||||
/* Avoid the use of slow int<->fp moves for spilling by setting
|
||||
their cost higher than memmov_cost. */
|
||||
- 2, /* GP2FP */
|
||||
- 3, /* FP2GP */
|
||||
+ 5, /* GP2FP */
|
||||
+ 5, /* FP2GP */
|
||||
2 /* FP2FP */
|
||||
};
|
||||
|
||||
@@ -1923,10 +1923,10 @@ static const struct tune_params hip09_tunings =
|
||||
4, /* load_pred. */
|
||||
4 /* store_pred. */
|
||||
}, /* memmov_cost. */
|
||||
- 4, /* issue_rate */
|
||||
+ 2, /* issue_rate */
|
||||
(AARCH64_FUSE_AES_AESMC | AARCH64_FUSE_ALU_BRANCH
|
||||
| AARCH64_FUSE_ALU_CBZ), /* fusible_ops */
|
||||
- "16", /* function_align. */
|
||||
+ "16:12", /* function_align. */
|
||||
"4", /* jump_align. */
|
||||
"8", /* loop_align. */
|
||||
2, /* int_reassoc_width. */
|
||||
--
|
||||
Gitee
|
||||
|
||||
|
||||
72
gcc.spec
72
gcc.spec
@ -2,7 +2,7 @@
|
||||
%global gcc_major 12
|
||||
# Note, gcc_release must be integer, if you want to add suffixes to
|
||||
# %%{release}, append them after %%{gcc_release} on Release: line.
|
||||
%global gcc_release 59
|
||||
%global gcc_release 66
|
||||
|
||||
%global _unpackaged_files_terminate_build 0
|
||||
%global _performance_build 1
|
||||
@ -428,16 +428,19 @@ Patch319: 0319-CSPGO-fix-bugs-when-using-cspgo.patch
|
||||
Patch320: 0320-if-split-fix-bugs.patch
|
||||
Patch321: 0321-Struct-reorg-Avoid-doing-struct-split-and-reorder_fi.patch
|
||||
Patch322: 0322-Bugfix-Create-POINTER_PLUS_EXPR-for-REFERENCE_TYPE.patch
|
||||
Patch323: 0323-fix-function-missing-return-value.patch
|
||||
Patch324: 0324-Bugfix-replace-tmp-pattern-split.patch
|
||||
Patch325: 0325-bugfix-fix-vector-costs-for-hip09.patch
|
||||
Patch326: 0326-gcc-opts-common.cc-Fix-build-with-clang.patch
|
||||
Patch327: 0327-BUGFIX-Fix-build-error-on-risv_64.patch
|
||||
Patch328: 0328-Bugfix-Adjust-the-same-gate-to-use-struct-option.patch
|
||||
Patch329: 0329-Bugfix-if-split-Added-checking-for-ssa_name.patch
|
||||
Patch330: 0330-Fixed-work-with-loops-in-process_complex_cond.patch
|
||||
Patch331: 0331-bugfix-fix-typo-error.patch
|
||||
Patch323: 0323-Bugfix-replace-tmp-pattern-split.patch
|
||||
Patch324: 0324-bugfix-fix-vector-costs-for-hip09.patch
|
||||
Patch325: 0325-gcc-opts-common.cc-Fix-build-with-clang.patch
|
||||
Patch326: 0326-BUGFIX-Fix-build-error-on-risv_64.patch
|
||||
Patch327: 0327-Bugfix-Adjust-the-same-gate-to-use-struct-option.patch
|
||||
Patch328: 0328-Bugfix-if-split-Added-checking-for-ssa_name.patch
|
||||
Patch329: 0329-Fixed-work-with-loops-in-process_complex_cond.patch
|
||||
Patch330: 0330-bugfix-fix-typo-error.patch
|
||||
Patch331: 0331-fix-function-missing-return-value.patch
|
||||
Patch332: 0332-Bugfix-Can-not-find-fdata-file.patch
|
||||
Patch333: 0333-CSPGO-Update-the-gate-of-cspgo.patch
|
||||
Patch334: 0334-Dont-use-local_detect_cpu-when-cross-build.patch
|
||||
Patch335: 0335-fix-costs-for-hip09.patch
|
||||
|
||||
# Part 1001-1999
|
||||
%ifarch sw_64
|
||||
@ -1556,6 +1559,9 @@ not stable, so plugins must be rebuilt any time GCC is updated.
|
||||
%patch -P330 -p1
|
||||
%patch -P331 -p1
|
||||
%patch -P332 -p1
|
||||
%patch -P333 -p1
|
||||
%patch -P334 -p1
|
||||
%patch -P335 -p1
|
||||
|
||||
%ifarch sw_64
|
||||
%patch -P1001 -p1
|
||||
@ -4179,18 +4185,60 @@ end
|
||||
%doc rpm.doc/changelogs/libcc1/ChangeLog*
|
||||
|
||||
%changelog
|
||||
* Mon Dec 30 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-59
|
||||
* Tue Dec 31 2024 liyancheng <412998149@qq.com> - 12.3.1-66
|
||||
- Type:Sync
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Don't use local_detect_cpu when cross build and fix hip09 costs.
|
||||
|
||||
* Mon Dec 30 2024 liyancheng <412998149@qq.com> - 12.3.1-65
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Update the gate of cspgo.
|
||||
|
||||
* Mon Dec 30 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-64
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Sync patches from openeuler/gcc.
|
||||
|
||||
* Thu Dec 26 2024 rfwang07 <wangrufeng5@huawei.com> - 12.3.1-58
|
||||
* Thu Dec 26 2024 rfwang07 <wangrufeng5@huawei.com> - 12.3.1-63
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Fix function missing return value.
|
||||
|
||||
* Wed Dec 18 2024 Mingchuan Wu <wumingchuan1992@foxmail.com> - 12.3.1-62
|
||||
- Type:Sync
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: Sync patches from openeuler/gcc.
|
||||
|
||||
* Mon Dec 16 2024 huzife <634763349@qq.com> - 12.3.1-61
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Add checking for ssa_name in if-split
|
||||
|
||||
* Mon Dec 16 2024 huang-xiaoquan <huangxiaoquan1@huawei.com> - 12.3.1-60
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC:Adjust the same gate to use struct option.
|
||||
|
||||
* Wed Dec 11 2024 Zhenyu Zhao <zhaozhenyu17@huawei.com> - 12.3.1-59
|
||||
- Type:Sync
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: Sync patches from openeuler/gcc.
|
||||
|
||||
* Tue Dec 10 2024 huzife <634763349@qq.com> - 12.3.1-58
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
- SUG:NA
|
||||
- DESC: Fix bugs in cmlt, replace tmp pattern split.
|
||||
|
||||
* Mon Dec 09 2024 liyancheng <412998149@qq.com> - 12.3.1-57
|
||||
- Type:Bugfix
|
||||
- ID:NA
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user