aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-hsa.c
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2020-08-03 18:13:00 +0200
committerMartin Jambor <mjambor@suse.cz>2020-08-03 18:13:00 +0200
commitc56684fd61223abd45854270cd1e83ab2f07148c (patch)
treef1ebfbe4dfd00b87f9522b84f78f02ee512e83a8 /gcc/ipa-hsa.c
parent9623f61b142174b87760c81f78928dd14af7cbc6 (diff)
downloadgcc-c56684fd61223abd45854270cd1e83ab2f07148c.zip
gcc-c56684fd61223abd45854270cd1e83ab2f07148c.tar.gz
gcc-c56684fd61223abd45854270cd1e83ab2f07148c.tar.bz2
Removal of HSA offloading from gcc and libgomp
This patch removes the generation of HSAIL from the compiler, the HSA offloading plugin from libgomp and the associated testsuite tests and infrastructure bits from the respective testsuites. Apart from removal of the obvious files, I removed bits that I found by searching for HSA related terms and by re-tracing my steps and looking at the patches that introduced HSA in the first place. I did not remove everything these patches brought in, for example: - the mechanism to pass offload-target specific info from the application to the offloading plugin - but the same mechanism is also used to communicate number of teams and the thread limit to all offload targets. - run_func hook in gomp_device_descr stays too, although now it is not used. If some future offload target would like the ability to refuse to offload some functions, it can use it. It is easy to remove as a follow-up if it is considered clutter, though. - configure options --with-hsa-runtime=PATH, -with-hsa-runtime-include=PATH and --with-hsa-runtime-lib=PATH rmeain because GCN uses them too. - Surprisingly, GOMP_TARGET_ARG_HSA_KERNEL_ATTRIBUTES (a constant from gomp-constants.h) appears in the source of the amdgcn libgomp plugin, although I tend to think that code path is not ever used and this patch certainly removes it from the compiler. Nevertheless, it seems it has potential value beyond HSAIL and so I've kept it, it can of course always be easily removed in the future of GCN folk abandon it too. - I assume constants OFFLOAD_TARGET_TYPE_HSA and GOMP_DEVICE_HSA need to stay indefinitely too just so that no future offload target picks that number. - I have kept dg-require-effective-target offload_device_nonshared_as requirement of thests which have it. It is quite probable I missed some small HSA artifacts but those should be easy to remove later as we find them. include/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * gomp-constants.h (GOMP_VERSION_HSA): Remove. gcc/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * hsa-brig-format.h: Moved to brig/brigfrontend. * hsa-brig.c: Removed. * hsa-builtins.def: Likewise. * hsa-common.c: Likewise. * hsa-common.h: Likewise. * hsa-dump.c: Likewise. * hsa-gen.c: Likewise. * hsa-regalloc.c: Likewise. * ipa-hsa.c: Likewise. * omp-grid.c: Likewise. * omp-grid.h: Likewise. * Makefile.in (BUILTINS_DEF): Remove hsa-builtins.def. (OBJS): Remove hsa-common.o, hsa-gen.o, hsa-regalloc.o, hsa-brig.o, hsa-dump.o, ipa-hsa.c and omp-grid.o. (GTFILES): Removed hsa-common.c and omp-expand.c. * builtins.def: Remove processing of hsa-builtins.def. (DEF_HSA_BUILTIN): Remove. * common.opt (flag_disable_hsa): Remove. (-Whsa): Ignore. * config.in (ENABLE_HSA): Removed. * configure.ac: Removed handling configuration for hsa offloading. (ENABLE_HSA): Removed. * configure: Regenerated. * doc/install.texi (--enable-offload-targets): Remove hsa from the example. (--with-hsa-runtime): Reword to reference any HSA run-time, not specifically HSA offloading. * doc/invoke.texi (Option Summary): Remove -Whsa. (Warning Options): Likewise. (Optimize Options): Remove hsa-gen-debug-stores. * doc/passes.texi (Regular IPA passes): Remove section on IPA HSA pass. * gimple-low.c (lower_stmt): Remove GIMPLE_OMP_GRID_BODY case. * gimple-pretty-print.c (dump_gimple_omp_for): Likewise. (dump_gimple_omp_block): Likewise. (pp_gimple_stmt_1): Likewise. * gimple-walk.c (walk_gimple_stmt): Likewise. * gimple.c (gimple_build_omp_grid_body): Removed function. (gimple_copy): Remove GIMPLE_OMP_GRID_BODY case. * gimple.def (GIMPLE_OMP_GRID_BODY): Removed. * gimple.h (gf_mask): Removed GF_OMP_PARALLEL_GRID_PHONY, OMP_FOR_KIND_GRID_LOOP, GF_OMP_FOR_GRID_PHONY, GF_OMP_FOR_GRID_INTRA_GROUP, GF_OMP_FOR_GRID_GROUP_ITER and GF_OMP_TEAMS_GRID_PHONY. Renumbered GF_OMP_FOR_KIND_SIMD and GF_OMP_TEAMS_HOST. (gimple_build_omp_grid_body): Removed declaration. (gimple_has_substatements): Remove GIMPLE_OMP_GRID_BODY case. (gimple_omp_for_grid_phony): Removed. (gimple_omp_for_set_grid_phony): Likewise. (gimple_omp_for_grid_intra_group): Likewise. (gimple_omp_for_grid_intra_group): Likewise. (gimple_omp_for_grid_group_iter): Likewise. (gimple_omp_for_set_grid_group_iter): Likewise. (gimple_omp_parallel_grid_phony): Likewise. (gimple_omp_parallel_set_grid_phony): Likewise. (gimple_omp_teams_grid_phony): Likewise. (gimple_omp_teams_set_grid_phony): Likewise. (CASE_GIMPLE_OMP): Remove GIMPLE_OMP_GRID_BODY case. * lto-section-in.c (lto_section_name): Removed hsa. * lto-streamer.h (lto_section_type): Removed LTO_section_ipa_hsa. * lto-wrapper.c (compile_images_for_offload_targets): Remove special handling of hsa. * omp-expand.c: Do not include hsa-common.h and gt-omp-expand.h. (parallel_needs_hsa_kernel_p): Removed. (grid_launch_attributes_trees): Likewise. (grid_launch_attributes_trees): Likewise. (grid_create_kernel_launch_attr_types): Likewise. (grid_insert_store_range_dim): Likewise. (grid_get_kernel_launch_attributes): Likewise. (get_target_arguments): Remove code passing HSA grid sizes. (grid_expand_omp_for_loop): Remove. (grid_arg_decl_map): Likewise. (grid_remap_kernel_arg_accesses): Likewise. (grid_expand_target_grid_body): Likewise. (expand_omp): Remove call to grid_expand_target_grid_body. (omp_make_gimple_edges): Remove GIMPLE_OMP_GRID_BODY case. * omp-general.c: Do not include hsa-common.h. (omp_maybe_offloaded): Do not check for HSA offloading. (omp_context_selector_matches): Likewise. * omp-low.c: Do not include hsa-common.h and omp-grid.h. (build_outer_var_ref): Remove handling of GIMPLE_OMP_GRID_BODY. (scan_sharing_clauses): Remove handling of OMP_CLAUSE__GRIDDIM_. (scan_omp_parallel): Remove handling of the phoney variant. (check_omp_nesting_restrictions): Remove handling of GIMPLE_OMP_GRID_BODY and GF_OMP_FOR_KIND_GRID_LOOP. (scan_omp_1_stmt): Remove handling of GIMPLE_OMP_GRID_BODY. (lower_omp_for_lastprivate): Remove handling of gridified loops. (lower_omp_for): Remove phony loop handling. (lower_omp_taskreg): Remove phony construct handling. (lower_omp_teams): Likewise. (lower_omp_grid_body): Removed. (lower_omp_1): Remove GIMPLE_OMP_GRID_BODY case. (execute_lower_omp): Do not call omp_grid_gridify_all_targets. * opts.c (common_handle_option): Do not handle hsa when processing OPT_foffload_. * params.opt (hsa-gen-debug-stores): Remove. * passes.def: Remove pass_ipa_hsa and pass_gen_hsail. * timevar.def: Remove TV_IPA_HSA. * toplev.c: Do not include hsa-common.h. (compile_file): Do not call hsa_output_brig. * tree-core.h (enum omp_clause_code): Remove OMP_CLAUSE__GRIDDIM_. (tree_omp_clause): Remove union field dimension. * tree-nested.c (convert_nonlocal_omp_clauses): Remove the OMP_CLAUSE__GRIDDIM_ case. (convert_local_omp_clauses): Likewise. * tree-pass.h (make_pass_gen_hsail): Remove declaration. (make_pass_ipa_hsa): Likewise. * tree-pretty-print.c (dump_omp_clause): Remove GIMPLE_OMP_GRID_BODY case. * tree.c (omp_clause_num_ops): Remove the element corresponding to OMP_CLAUSE__GRIDDIM_. (omp_clause_code_name): Likewise. (walk_tree_1): Remove GIMPLE_OMP_GRID_BODY case. * tree.h (OMP_CLAUSE__GRIDDIM__DIMENSION): Remove. (OMP_CLAUSE__GRIDDIM__SIZE): Likewise. (OMP_CLAUSE__GRIDDIM__GROUP): Likewise. gcc/fortran/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * f95-lang.c (gfc_init_builtin_functions): Remove processing of hsa-builtins.def. gcc/brig/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * brigfrontend/brig-util.h (hsa_type_packed_p): Declared. * brigfrontend/brig-util.cc (hsa_type_packed_p): Moved here from removed gcc/hsa-common.c. libgomp/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * plugin/Makefrag.am: Remove configuration of HSA plugin. * aclocal.m4: Regenerated. * Makefile.in: Regenerated. * config.h.in: Regenerated. * configure: Regenerated. * plugin/configfrag.ac: Likewise. * plugin/hsa_ext_finalize.h: Removed. * plugin/plugin-hsa.c: Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/lib/libgomp.exp (offload_target_to_openacc_device_type): Remove hsa case. (check_effective_target_hsa_offloading_selected_nocache): Removed (check_effective_target_hsa_offloading_selected): Likewise. (libgomp_init): Do not add -Wno-hsa to additional_flags. * testsuite/libgomp.hsa.c/alloca-1.c: Removed test. * testsuite/libgomp.hsa.c/bitfield-1.c: Likewise. * testsuite/libgomp.hsa.c/bits-insns.c: Likewise. * testsuite/libgomp.hsa.c/builtins-1.c: Likewise. * testsuite/libgomp.hsa.c/c.exp: Likewise. * testsuite/libgomp.hsa.c/complex-1.c: Likewise. * testsuite/libgomp.hsa.c/complex-align-2.c: Likewise. * testsuite/libgomp.hsa.c/formal-actual-args-1.c: Likewise. * testsuite/libgomp.hsa.c/function-call-1.c: Likewise. * testsuite/libgomp.hsa.c/get-level-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-2.c: Likewise. * testsuite/libgomp.hsa.c/gridify-3.c: Likewise. * testsuite/libgomp.hsa.c/gridify-4.c: Likewise. * testsuite/libgomp.hsa.c/memory-operations-1.c: Likewise. * testsuite/libgomp.hsa.c/pr69568.c: Likewise. * testsuite/libgomp.hsa.c/pr82416.c: Likewise. * testsuite/libgomp.hsa.c/rotate-1.c: Likewise. * testsuite/libgomp.hsa.c/staticvar.c: Likewise. * testsuite/libgomp.hsa.c/switch-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-branch-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-sbr-2.c: Likewise. * testsuite/libgomp.hsa.c/tiling-1.c: Likewise. * testsuite/libgomp.hsa.c/tiling-2.c: Likewise. gcc/testsuite/ChangeLog: 2020-07-24 Martin Jambor <mjambor@suse.cz> * lib/target-supports.exp (check_effective_target_offload_hsa): Removed. * c-c++-common/gomp/gridify-1.c: Removed test. * c-c++-common/gomp/gridify-2.c: Likewise. * c-c++-common/gomp/gridify-3.c: Likewise. * c-c++-common/gomp/hsa-indirect-call-1.c: Likewise. * gfortran.dg/gomp/gridify-1.f90: Likewise. * gcc.dg/gomp/gomp.exp: Do not pass -Wno-hsa to tests. * g++.dg/gomp/gomp.exp: Likewise. * gfortran.dg/gomp/gomp.exp: Likewise.
Diffstat (limited to 'gcc/ipa-hsa.c')
-rw-r--r--gcc/ipa-hsa.c336
1 files changed, 0 insertions, 336 deletions
diff --git a/gcc/ipa-hsa.c b/gcc/ipa-hsa.c
deleted file mode 100644
index f2980ba..0000000
--- a/gcc/ipa-hsa.c
+++ /dev/null
@@ -1,336 +0,0 @@
-/* Callgraph based analysis of static variables.
- Copyright (C) 2015-2020 Free Software Foundation, Inc.
- Contributed by Martin Liska <mliska@suse.cz>
-
-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/>. */
-
-/* Interprocedural HSA pass is responsible for creation of HSA clones.
- For all these HSA clones, we emit HSAIL instructions and pass processing
- is terminated. */
-
-#include "config.h"
-#include "system.h"
-#include "coretypes.h"
-#include "tm.h"
-#include "is-a.h"
-#include "hash-set.h"
-#include "vec.h"
-#include "tree.h"
-#include "tree-pass.h"
-#include "function.h"
-#include "basic-block.h"
-#include "gimple.h"
-#include "dumpfile.h"
-#include "gimple-pretty-print.h"
-#include "tree-streamer.h"
-#include "stringpool.h"
-#include "cgraph.h"
-#include "print-tree.h"
-#include "alloc-pool.h"
-#include "symbol-summary.h"
-#include "hsa-common.h"
-
-namespace {
-
-/* If NODE is not versionable, warn about not emiting HSAIL and return false.
- Otherwise return true. */
-
-static bool
-check_warn_node_versionable (cgraph_node *node)
-{
- if (!node->versionable)
- {
- warning_at (EXPR_LOCATION (node->decl), OPT_Whsa,
- "could not emit HSAIL for function %s: function cannot be "
- "cloned", node->dump_name ());
- return false;
- }
- return true;
-}
-
-/* The function creates HSA clones for all functions that were either
- marked as HSA kernels or are callable HSA functions. Apart from that,
- we redirect all edges that come from an HSA clone and end in another
- HSA clone to connect these two functions. */
-
-static unsigned int
-process_hsa_functions (void)
-{
- struct cgraph_node *node;
-
- if (hsa_summaries == NULL)
- hsa_summaries = new hsa_summary_t (symtab);
-
- FOR_EACH_DEFINED_FUNCTION (node)
- {
- hsa_function_summary *s = hsa_summaries->get (node);
-
- /* A linked function is skipped. */
- if (s != NULL && s->m_bound_function != NULL)
- continue;
-
- if (s != NULL)
- {
- if (!check_warn_node_versionable (node))
- continue;
- cgraph_node *clone
- = node->create_virtual_clone (vec <cgraph_edge *> (),
- NULL, NULL, "hsa", 0);
- TREE_PUBLIC (clone->decl) = TREE_PUBLIC (node->decl);
- clone->externally_visible = node->externally_visible;
-
- clone->force_output = true;
- hsa_summaries->link_functions (clone, node, s->m_kind, false);
-
- if (dump_file)
- fprintf (dump_file, "Created a new HSA clone: %s, type: %s\n",
- clone->dump_name (),
- s->m_kind == HSA_KERNEL ? "kernel" : "function");
- }
- else if (hsa_callable_function_p (node->decl)
- /* At this point, this is enough to identify clones for
- parallel, which for HSA would need to be kernels anyway. */
- && !DECL_ARTIFICIAL (node->decl))
- {
- if (!check_warn_node_versionable (node))
- continue;
- cgraph_node *clone
- = node->create_virtual_clone (vec <cgraph_edge *> (),
- NULL, NULL, "hsa", 0);
- TREE_PUBLIC (clone->decl) = TREE_PUBLIC (node->decl);
- clone->externally_visible = node->externally_visible;
-
- if (!node->local)
- clone->force_output = true;
- hsa_summaries->link_functions (clone, node, HSA_FUNCTION, false);
-
- if (dump_file)
- fprintf (dump_file, "Created a new HSA function clone: %s\n",
- clone->dump_name ());
- }
- }
-
- /* Redirect all edges that are between HSA clones. */
- FOR_EACH_DEFINED_FUNCTION (node)
- {
- cgraph_edge *e = node->callees;
-
- while (e)
- {
- hsa_function_summary *src = hsa_summaries->get (node);
- if (src != NULL && src->m_gpu_implementation_p)
- {
- hsa_function_summary *dst = hsa_summaries->get (e->callee);
- if (dst != NULL && !dst->m_gpu_implementation_p)
- {
- e->redirect_callee (dst->m_bound_function);
- if (dump_file)
- fprintf (dump_file,
- "Redirecting edge to HSA function: %s->%s\n",
- e->caller->dump_name (),
- e->callee->dump_name ());
- }
- }
-
- e = e->next_callee;
- }
- }
-
- return 0;
-}
-
-/* Iterate all HSA functions and stream out HSA function summary. */
-
-static void
-ipa_hsa_write_summary (void)
-{
- struct bitpack_d bp;
- struct cgraph_node *node;
- struct output_block *ob;
- unsigned int count = 0;
- lto_symtab_encoder_iterator lsei;
- lto_symtab_encoder_t encoder;
-
- if (!hsa_summaries)
- return;
-
- ob = create_output_block (LTO_section_ipa_hsa);
- encoder = ob->decl_state->symtab_node_encoder;
- ob->symbol = NULL;
- for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);
- lsei_next_function_in_partition (&lsei))
- {
- node = lsei_cgraph_node (lsei);
- hsa_function_summary *s = hsa_summaries->get (node);
-
- if (s != NULL)
- count++;
- }
-
- streamer_write_uhwi (ob, count);
-
- /* Process all of the functions. */
- for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);
- lsei_next_function_in_partition (&lsei))
- {
- node = lsei_cgraph_node (lsei);
- hsa_function_summary *s = hsa_summaries->get (node);
-
- if (s != NULL)
- {
- encoder = ob->decl_state->symtab_node_encoder;
- int node_ref = lto_symtab_encoder_encode (encoder, node);
- streamer_write_uhwi (ob, node_ref);
-
- bp = bitpack_create (ob->main_stream);
- bp_pack_value (&bp, s->m_kind, 2);
- bp_pack_value (&bp, s->m_gpu_implementation_p, 1);
- bp_pack_value (&bp, s->m_bound_function != NULL, 1);
- streamer_write_bitpack (&bp);
- if (s->m_bound_function)
- stream_write_tree (ob, s->m_bound_function->decl, true);
- }
- }
-
- streamer_write_char_stream (ob->main_stream, 0);
- produce_asm (ob, NULL);
- destroy_output_block (ob);
-}
-
-/* Read section in file FILE_DATA of length LEN with data DATA. */
-
-static void
-ipa_hsa_read_section (struct lto_file_decl_data *file_data, const char *data,
- size_t len)
-{
- const struct lto_function_header *header
- = (const struct lto_function_header *) data;
- const int cfg_offset = sizeof (struct lto_function_header);
- const int main_offset = cfg_offset + header->cfg_size;
- const int string_offset = main_offset + header->main_size;
- class data_in *data_in;
- unsigned int i;
- unsigned int count;
-
- lto_input_block ib_main ((const char *) data + main_offset,
- header->main_size, file_data->mode_table);
-
- data_in
- = lto_data_in_create (file_data, (const char *) data + string_offset,
- header->string_size, vNULL);
- count = streamer_read_uhwi (&ib_main);
-
- for (i = 0; i < count; i++)
- {
- unsigned int index;
- struct cgraph_node *node;
- lto_symtab_encoder_t encoder;
-
- index = streamer_read_uhwi (&ib_main);
- encoder = file_data->symtab_node_encoder;
- node = dyn_cast<cgraph_node *> (lto_symtab_encoder_deref (encoder,
- index));
- gcc_assert (node->definition);
- hsa_function_summary *s = hsa_summaries->get_create (node);
-
- struct bitpack_d bp = streamer_read_bitpack (&ib_main);
- s->m_kind = (hsa_function_kind) bp_unpack_value (&bp, 2);
- s->m_gpu_implementation_p = bp_unpack_value (&bp, 1);
- bool has_tree = bp_unpack_value (&bp, 1);
-
- if (has_tree)
- {
- tree decl = stream_read_tree (&ib_main, data_in);
- s->m_bound_function = cgraph_node::get_create (decl);
- }
- }
- lto_free_section_data (file_data, LTO_section_ipa_hsa, NULL, data,
- len);
- lto_data_in_delete (data_in);
-}
-
-/* Load streamed HSA functions summary and assign the summary to a function. */
-
-static void
-ipa_hsa_read_summary (void)
-{
- struct lto_file_decl_data **file_data_vec = lto_get_file_decl_data ();
- struct lto_file_decl_data *file_data;
- unsigned int j = 0;
-
- if (hsa_summaries == NULL)
- hsa_summaries = new hsa_summary_t (symtab);
-
- while ((file_data = file_data_vec[j++]))
- {
- size_t len;
- const char *data
- = lto_get_summary_section_data (file_data, LTO_section_ipa_hsa, &len);
- if (data)
- ipa_hsa_read_section (file_data, data, len);
- }
-}
-
-const pass_data pass_data_ipa_hsa =
-{
- IPA_PASS, /* type */
- "hsa", /* name */
- OPTGROUP_OMP, /* optinfo_flags */
- TV_IPA_HSA, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- TODO_dump_symtab, /* todo_flags_finish */
-};
-
-class pass_ipa_hsa : public ipa_opt_pass_d
-{
-public:
- pass_ipa_hsa (gcc::context *ctxt)
- : ipa_opt_pass_d (pass_data_ipa_hsa, ctxt,
- NULL, /* generate_summary */
- ipa_hsa_write_summary, /* write_summary */
- ipa_hsa_read_summary, /* read_summary */
- ipa_hsa_write_summary, /* write_optimization_summary */
- ipa_hsa_read_summary, /* read_optimization_summary */
- NULL, /* stmt_fixup */
- 0, /* function_transform_todo_flags_start */
- NULL, /* function_transform */
- NULL) /* variable_transform */
- {}
-
- /* opt_pass methods: */
- virtual bool gate (function *);
-
- virtual unsigned int execute (function *) { return process_hsa_functions (); }
-
-}; // class pass_ipa_reference
-
-bool
-pass_ipa_hsa::gate (function *)
-{
- return hsa_gen_requested_p ();
-}
-
-} // anon namespace
-
-ipa_opt_pass_d *
-make_pass_ipa_hsa (gcc::context *ctxt)
-{
- return new pass_ipa_hsa (ctxt);
-}