aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrathamesh Kulkarni <prathameshk@nvidia.com>2024-08-20 12:54:02 +0530
committerPrathamesh Kulkarni <prathameshk@nvidia.com>2024-08-20 12:58:54 +0530
commitdb2e9a2a46f64b037494e8300c46f2d90a9fa55c (patch)
tree8871353344f7cb07fa94c724503c399084f95c13
parentc1a53d9dcf9ebf0a6b4528a8c3eae48a583f272c (diff)
downloadgcc-db2e9a2a46f64b037494e8300c46f2d90a9fa55c.zip
gcc-db2e9a2a46f64b037494e8300c46f2d90a9fa55c.tar.gz
gcc-db2e9a2a46f64b037494e8300c46f2d90a9fa55c.tar.bz2
[optc-save-gen.awk] Fix streaming of command line options for offloading.
The patch modifies optc-save-gen.awk to generate if (!lto_stream_offload_p) check before streaming out target-specific opt in cl_optimization_stream_out, when offloading is enabled. Also, it modifies cl_optimization_stream_in to issue an error during build time if accelerator backend defines a target-specific Optimization option. This restriction currently is in place to maintain consistency for streaming of Optimization options between host and accelerator. A proper fix would be to merge target-specific Optimization options for host and accelerators enabled for offloading. gcc/ChangeLog: * optc-save-gen.awk: New array var_target_opt. Use it to generate if (!lto_stream_offload_p) check in cl_optimization_stream_out, and generate a diagnostic with #error if accelerator backend uses Optimization for target-specifc options in cl_optimization_stream_in. Signed-off-by: Prathamesh Kulkarni <prathameshk@nvidia.com>
-rw-r--r--gcc/optc-save-gen.awk16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index a3af88e..b1289c2 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -1307,6 +1307,11 @@ for (i = 0; i < n_opts; i++) {
var_opt_optimize_init[n_opt_val] = init;
}
+ # Mark options that are annotated with both Optimization and
+ # Target so we can avoid streaming out target-specific opts when
+ # offloading is enabled.
+ if (flag_set_p("Target", flags[i]))
+ var_target_opt[n_opt_val] = 1;
n_opt_val++;
}
}
@@ -1384,6 +1389,10 @@ for (i = 0; i < n_opt_val; i++) {
} else {
sgn = "int";
}
+ # Do not stream out target-specific opts if offloading is
+ # enabled.
+ if (var_target_opt[i])
+ print " if (!lto_stream_offload_p)"
# If applicable, encode the streamed value.
if (var_opt_optimize_init[i]) {
print " if (" var_opt_optimize_init[i] " > (" var_opt_val_type[i] ") 10)";
@@ -1408,6 +1417,11 @@ print " struct cl_optimization *ptr ATTRIBUTE_UNUSED)"
print "{";
for (i = 0; i < n_opt_val; i++) {
name = var_opt_val[i]
+ if (var_target_opt[i]) {
+ print "#ifdef ACCEL_COMPILER"
+ print "#error accel compiler cannot define Optimization attribute for target-specific option " name;
+ print "#else"
+ }
otype = var_opt_val_type[i];
if (otype ~ "^const char \\**$") {
print " ptr->" name" = bp_unpack_string (data_in, bp);";
@@ -1427,6 +1441,8 @@ for (i = 0; i < n_opt_val; i++) {
print " ptr->" name" ^= " var_opt_optimize_init[i] ";";
}
}
+ if (var_target_opt[i])
+ print "#endif"
}
print " for (size_t i = 0; i < ARRAY_SIZE (ptr->explicit_mask); i++)";
print " ptr->explicit_mask[i] = bp_unpack_value (bp, 64);";