From 3d78810d5efd43004143c48c24a4b63cf4055fe1 Mon Sep 17 00:00:00 2001 From: Philippe Tillet Date: Sun, 8 Sep 2019 21:29:40 -0400 Subject: [PATCH] more progress --- lib/codegen/analysis/grid.cc | 5 ++++- lib/codegen/selection.cc | 1 + lib/ir/instructions.cc | 2 ++ lib/runtime/function.cc | 7 +++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/codegen/analysis/grid.cc b/lib/codegen/analysis/grid.cc index bbd2940ec..29d5c3657 100644 --- a/lib/codegen/analysis/grid.cc +++ b/lib/codegen/analysis/grid.cc @@ -157,7 +157,7 @@ grids::fragment_t grids::get_fragmentation_type(node_t x, graph_t &graph){ } void grids::connected_components(node_t x, const std::vector mps, const std::vector prefixes, std::set &nodes, graph_t &graph, unsigned group_id) { -// std::cout << "connected component: " << x.first->get_name() << " " << x.second << std::endl; + std::cout << "connected component: " << x.first->get_name() << " " << x.second << std::endl; groups_[x.first].insert({x.second, group_id}); if(nodes.find(x) != nodes.end()){ nodes.erase(x); @@ -229,10 +229,13 @@ void grids::run(ir::module &mod) { create_grids(grids_, references, fn); } + unsigned num_threads = get_num_threads(); auto clamp = [&](unsigned x, unsigned lo, unsigned hi) { return std::min(std::max(x, lo), hi); }; for(ir::value *i: grids_){ + std::cout << "grid: " << i->get_name() << std::endl; + if(!i->get_type()->is_tile_ty()) continue; auto shapes = i->get_type()->get_tile_shapes(); diff --git a/lib/codegen/selection.cc b/lib/codegen/selection.cc index a2a48300b..88664bb64 100644 --- a/lib/codegen/selection.cc +++ b/lib/codegen/selection.cc @@ -1436,6 +1436,7 @@ void selection::lower_tile_instruction(ir::instruction *ins, llvm::IRBuilder<> & } void selection::lower_instruction(ir::instruction *src, IRBuilder<> &builder) { + std::cout << src->get_name() << std::endl; if(src->has_tile_result_or_op()) { lower_tile_instruction(src, builder); } diff --git a/lib/ir/instructions.cc b/lib/ir/instructions.cc index 343a59fbf..ac595079d 100644 --- a/lib/ir/instructions.cc +++ b/lib/ir/instructions.cc @@ -731,6 +731,7 @@ barrier_inst* barrier_inst::create(context &ctx, const std::string &name, instru return new barrier_inst(ctx, name, next); } + // nv_dynamic_program_idx nv_dynamic_program_idx_inst::nv_dynamic_program_idx_inst(type *ty, const std::string &name, instruction *next) : instruction(ty, 0, 1, name, next) { } @@ -754,5 +755,6 @@ nv_static_program_idx* nv_static_program_idx::get(constant_range* range) { } + } } diff --git a/lib/runtime/function.cc b/lib/runtime/function.cc index e7850e1c8..3ddcc856f 100644 --- a/lib/runtime/function.cc +++ b/lib/runtime/function.cc @@ -199,7 +199,7 @@ std::unique_ptr function::make_bin(ir::module &module, driver::c codegen::analysis::liveness shmem_liveness(&shmem_info); codegen::analysis::memalloc shmem_allocation(&shmem_liveness, &shmem_info, &grids); codegen::analysis::align alignment_info; - codegen::transform::reorder reorder(&alignment_info); + codegen::transform::reorder reorder(&alignment_info, &shmem_info); codegen::transform::membar shmem_barriers(&shmem_allocation, &shmem_info); codegen::transform::vectorize vectorize(&grids); codegen::transform::dce dce; @@ -211,7 +211,9 @@ std::unique_ptr function::make_bin(ir::module &module, driver::c dce.run(module); alignment_info.run(module); ir::print(module, std::cout); -// reorder.run(module); + if(target->is_gpu()) + shmem_info.run(module); + reorder.run(module); dce.run(module); ir::print(module, std::cout); grids.run(module); @@ -229,6 +231,7 @@ std::unique_ptr function::make_bin(ir::module &module, driver::c dce.run(module); vectorize.run(module); dce.run(module); + ir::print(module, std::cout); // generate llvm code llvm::LLVMContext ctx; std::unique_ptr llvm(new llvm::Module(module.get_name(), ctx));