diff --git a/include/NeuraDialect/Architecture/Architecture.h b/include/NeuraDialect/Architecture/Architecture.h index ca7a4951..0ba944dc 100644 --- a/include/NeuraDialect/Architecture/Architecture.h +++ b/include/NeuraDialect/Architecture/Architecture.h @@ -260,9 +260,11 @@ class Link : public BasicResource { class Register : public BasicResource { public: - Register(int id); + Register(int global_id, int per_tile_id); int getId() const override; + + int getPerTileId() const; std::string getType() const override { return "register"; } @@ -279,7 +281,8 @@ class Register : public BasicResource { RegisterFile *getRegisterFile() const; private: - int id; + int global_id; + int per_tile_id; RegisterFile *register_file; }; @@ -406,8 +409,7 @@ class Architecture { void applyTileOverrides(const std::vector& tile_overrides); void createLinks(const LinkDefaults& link_defaults, BaseTopology base_topology); void applyLinkOverrides(const std::vector& link_overrides); - void createRegisterFileCluster(Tile *tile, int num_registers, int ®_id); - void recreateRegisterFileCluster(Tile *tile, int num_registers); + void createRegisterFileCluster(Tile *tile, int num_registers, int &num_already_assigned_global_registers, int global_id_start = -1); bool linkExists(Tile *src_tile, Tile *dst_tile); // Helper methods for creating different topology links. diff --git a/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp b/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp index 1195565d..8b6fcf82 100644 --- a/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp +++ b/lib/Conversion/LlvmToNeura/LlvmToNeuraPass.cpp @@ -501,6 +501,7 @@ struct LlvmReturnToNeuraReturn : public OpRewritePattern { } }; + struct FuncReturnToNeuraReturn : public OpRewritePattern { using OpRewritePattern::OpRewritePattern; diff --git a/lib/NeuraDialect/Architecture/Architecture.cpp b/lib/NeuraDialect/Architecture/Architecture.cpp index 26c5ebd1..0ce5a6ad 100644 --- a/lib/NeuraDialect/Architecture/Architecture.cpp +++ b/lib/NeuraDialect/Architecture/Architecture.cpp @@ -252,9 +252,11 @@ Tile *FunctionUnit::getTile() const { return this->tile; } // Register //===----------------------------------------------------------------------===// -Register::Register(int id) { this->id = id; } +Register::Register(int global_id, int per_tile_id) : global_id(global_id), per_tile_id(per_tile_id) {} -int Register::getId() const { return id; } +int Register::getId() const { return global_id; } + +int Register::getPerTileId() const { return per_tile_id; } Tile *Register::getTile() const { return this->register_file ? register_file->getTile() : nullptr; @@ -337,18 +339,22 @@ void Architecture::initializeTiles(int per_cgra_rows, int per_cgra_columns) { } // Creates register file cluster for a tile. -void Architecture::createRegisterFileCluster(Tile *tile, int num_registers, int ®_id) { +void Architecture::createRegisterFileCluster(Tile *tile, int num_registers, int &num_already_assigned_global_registers, int global_id_start) { const int k_num_regs_per_regfile = 8; // Keep this fixed for now. const int k_num_regfiles_per_cluster = num_registers / k_num_regs_per_regfile; + // Ensures global register IDs are monotonically increasing. + num_already_assigned_global_registers = std::max(num_already_assigned_global_registers, global_id_start); + RegisterFileCluster *register_file_cluster = new RegisterFileCluster(tile->getId()); // Creates registers as a register file. + int local_reg_id = 0; for (int file_idx = 0; file_idx < k_num_regfiles_per_cluster; ++file_idx) { RegisterFile *register_file = new RegisterFile(file_idx); - for (int reg_idx = 0; reg_idx < k_num_regs_per_regfile; ++reg_idx) { - Register *reg = new Register(reg_id++); - register_file->addRegister(reg); + for (int reg = 0; reg < k_num_regs_per_regfile; ++reg) { + Register *new_register = new Register(num_already_assigned_global_registers++, local_reg_id++); + register_file->addRegister(new_register); } register_file_cluster->addRegisterFile(register_file); } @@ -358,13 +364,13 @@ void Architecture::createRegisterFileCluster(Tile *tile, int num_registers, int // Configures default tile settings. void Architecture::configureDefaultTileSettings(const TileDefaults& tile_defaults) { - int reg_id = 0; + int num_already_assigned_global_registers = 0; for (int y = 0; y < getPerCgraRows(); ++y) { for (int x = 0; x < getPerCgraColumns(); ++x) { Tile *tile = getTile(x, y); // Creates register file cluster with default capacity. - createRegisterFileCluster(tile, tile_defaults.num_registers, reg_id); + createRegisterFileCluster(tile, tile_defaults.num_registers, num_already_assigned_global_registers); // Configures function units based on tile_defaults.operations. configureTileFunctionUnits(tile, tile_defaults.operations); @@ -372,34 +378,6 @@ void Architecture::configureDefaultTileSettings(const TileDefaults& tile_default } } -// Recreates register file cluster with new capacity. -void Architecture::recreateRegisterFileCluster(Tile *tile, int num_registers) { - constexpr int kNumRegsPerRegfile = 8; // Keep this fixed for now. - const int kNumRegfilesPerCluster = num_registers / kNumRegsPerRegfile; - - // Removes existing register file cluster. - if (tile->getRegisterFileCluster()) { - delete tile->getRegisterFileCluster(); - } - - // Creates new register file cluster with override capacity. - RegisterFileCluster *new_register_file_cluster = - new RegisterFileCluster(tile->getId()); - - // Creates registers with new capacity. - int reg_id = tile->getId() * 1000; // Use tile ID as base to avoid conflicts. - for (int file_idx = 0; file_idx < kNumRegfilesPerCluster; ++file_idx) { - RegisterFile *register_file = new RegisterFile(file_idx); - for (int reg_idx = 0; reg_idx < kNumRegsPerRegfile; ++reg_idx) { - Register *reg = new Register(reg_id++); - register_file->addRegister(reg); - } - new_register_file_cluster->addRegisterFile(register_file); - } - - // Adds new register file cluster to the tile. - tile->addRegisterFileCluster(new_register_file_cluster); -} // Applies tile overrides to modify specific tiles. void Architecture::applyTileOverrides(const std::vector& tile_overrides) { @@ -417,7 +395,15 @@ void Architecture::applyTileOverrides(const std::vector& tile_over // Overrides num_registers if specified. if (override.num_registers > 0) { - recreateRegisterFileCluster(tile, override.num_registers); + // Removes existing register file cluster. + if (tile->getRegisterFileCluster()) { + delete tile->getRegisterFileCluster(); + } + + // Creates new register file cluster with override capacity. + // Uses tile ID as base to avoid conflicts with existing registers. + int dummy_ref = 0; // Not used when global_id_start is specified. + createRegisterFileCluster(tile, override.num_registers, dummy_ref, tile->getId() * 1000); } } } diff --git a/lib/NeuraDialect/Mapping/MappingState.cpp b/lib/NeuraDialect/Mapping/MappingState.cpp index 4177fa27..cfb946da 100644 --- a/lib/NeuraDialect/Mapping/MappingState.cpp +++ b/lib/NeuraDialect/Mapping/MappingState.cpp @@ -263,13 +263,21 @@ void MappingState::encodeMappingState() { mapping_entries.push_back(dict); } else if (loc.resource->getKind() == ResourceKind::Register) { kind_str = "register"; + Register *reg = static_cast(loc.resource); + int global_id = loc.resource->getId(); + int per_tile_register_id = reg->getPerTileId(); + auto dict = mlir::DictionaryAttr::get( ctx, {mlir::NamedAttribute(mlir::StringAttr::get(ctx, "resource"), mlir::StringAttr::get(ctx, kind_str)), mlir::NamedAttribute( mlir::StringAttr::get(ctx, "id"), mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 32), - loc.resource->getId())), + global_id)), + mlir::NamedAttribute( + mlir::StringAttr::get(ctx, "per_tile_register_id"), + mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 32), + per_tile_register_id)), mlir::NamedAttribute( mlir::StringAttr::get(ctx, "time_step"), mlir::IntegerAttr::get(mlir::IntegerType::get(ctx, 32), diff --git a/lib/NeuraDialect/Transforms/GenerateCodePass.cpp b/lib/NeuraDialect/Transforms/GenerateCodePass.cpp index f0a5e8bd..0a322eeb 100644 --- a/lib/NeuraDialect/Transforms/GenerateCodePass.cpp +++ b/lib/NeuraDialect/Transforms/GenerateCodePass.cpp @@ -60,6 +60,7 @@ struct Tile { struct ArrayConfig { int columns; int rows; + int compiled_ii = -1; std::vector cores; }; @@ -109,8 +110,9 @@ static std::optional getMappedRegId(Operation *op) { auto resource_attr = dyn_cast_or_null(location_dict.get("resource")); if (!resource_attr) continue; if (resource_attr.getValue() == "register" || resource_attr.getValue() == "reg") { - if (auto register_id = dyn_cast_or_null(location_dict.get("id"))) - return register_id.getInt(); + if (auto per_tile_register_id = dyn_cast_or_null(location_dict.get("per_tile_register_id"))) { + return per_tile_register_id.getInt(); + } } } } @@ -248,10 +250,10 @@ static SmallVector collectRegSteps(Operation *op) { auto resource_attr = dyn_cast_or_null(location_dict.get("resource")); if (!resource_attr) continue; if (resource_attr.getValue() == "register" || resource_attr.getValue() == "reg") { - auto register_id = dyn_cast_or_null(location_dict.get("id")); + auto per_tile_register_id = dyn_cast_or_null(location_dict.get("per_tile_register_id")); auto time_step = dyn_cast_or_null(location_dict.get("time_step")); - if (!register_id || !time_step) continue; - steps.push_back({(int)register_id.getInt(), (int)time_step.getInt()}); + if (!per_tile_register_id || !time_step) continue; + steps.push_back({(int)per_tile_register_id.getInt(), (int)time_step.getInt()}); } } } @@ -317,6 +319,15 @@ struct GenerateCodePass return {columns, rows}; } + int getCompiledII(func::FuncOp function) { + if (auto mapping_info = function->getAttrOfType("mapping_info")) { + if (auto compiled_ii = dyn_cast_or_null(mapping_info.get("compiled_ii"))) { + return compiled_ii.getInt(); + } + } + return -1; + } + // ---------- Single-walk indexing ----------. // Do everything that needs walks in a single pass:. // - record operation_placements. @@ -571,8 +582,8 @@ struct GenerateCodePass } } - ArrayConfig buildArrayConfig(int columns, int rows) { - ArrayConfig config{columns, rows, {}}; + ArrayConfig buildArrayConfig(int columns, int rows, int compiled_ii = -1) { + ArrayConfig config{columns, rows, compiled_ii, {}}; std::map, std::vector> tile_insts; // Flattens and sorts by timesteps. @@ -600,7 +611,11 @@ struct GenerateCodePass llvm::raw_fd_ostream yaml_out("tmp-generated-instructions.yaml", ec); if (ec) return; - yaml_out << "array_config:\n columns: " << config.columns << "\n rows: " << config.rows << "\n cores:\n"; + yaml_out << "array_config:\n columns: " << config.columns << "\n rows: " << config.rows; + if (config.compiled_ii >= 0) { + yaml_out << "\n compiled_ii: " << config.compiled_ii; + } + yaml_out << "\n cores:\n"; for (const Tile &core : config.cores) { yaml_out << " - column: " << core.col_idx << "\n row: " << core.row_idx << "\n core_id: \"" << core.core_id << "\"\n entries:\n"; @@ -657,6 +672,10 @@ struct GenerateCodePass llvm::raw_fd_ostream asm_out("tmp-generated-instructions.asm", ec); if (ec) return; + if (config.compiled_ii >= 0) { + asm_out << "# Compiled II: " << config.compiled_ii << "\n\n"; + } + for (const Tile &core : config.cores) { asm_out << "PE(" << core.col_idx << "," << core.row_idx << "):\n"; @@ -765,7 +784,8 @@ struct GenerateCodePass expandMovImpl(op, topo, reserve_to_phi_map); logUnresolvedOperands(); - ArrayConfig config = buildArrayConfig(columns, rows); + int compiled_ii = getCompiledII(func); + ArrayConfig config = buildArrayConfig(columns, rows, compiled_ii); writeYAMLOutput(config); writeASMOutput(config); } diff --git a/test/e2e/fir/fir_kernel.mlir b/test/e2e/fir/fir_kernel.mlir index caf1e4a4..59b140d9 100644 --- a/test/e2e/fir/fir_kernel.mlir +++ b/test/e2e/fir/fir_kernel.mlir @@ -33,41 +33,41 @@ // MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data // MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0 : i32}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 1 : i32}]} : () -> !neura.data // MAPPING-NEXT: %2 = neura.reserve : !neura.data -// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 128 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %5 = neura.reserve : !neura.data -// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 37 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %9 = "neura.gep"(%8) <{operandSegmentSizes = array}> {lhs_value = "%arg0", mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 480 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 480 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %11 = "neura.load"(%10) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %12 = "neura.data_mov"(%7) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %13 = "neura.gep"(%12) <{operandSegmentSizes = array}> {lhs_value = "%arg2", mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %15 = "neura.load"(%14) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 3 : i32}, {id = 34 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 448 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %18 = "neura.mul"(%16, %17) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %19 = "neura.data_mov"(%18) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 5 : i32}, {id = 42 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %20 = "neura.data_mov"(%4) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}, {id = 288 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %20 = "neura.data_mov"(%4) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}, {id = 288 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %21 = "neura.add"(%19, %20) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %22 = "neura.data_mov"(%7) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %22 = "neura.data_mov"(%7) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %23 = "neura.add"(%22) {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 2 : i32}], rhs_value = 1 : i64} : (!neura.data) -> !neura.data // MAPPING-NEXT: %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %25 = "neura.icmp"(%24) <{cmpType = "eq"}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}], rhs_value = 32 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %26 = "neura.data_mov"(%25) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %26 = "neura.data_mov"(%25) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %27 = "neura.not"(%26) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %28 = "neura.data_mov"(%23) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 2 : i32}, {id = 35 : i32, resource = "link", time_step = 3 : i32}, {id = 320 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %29 = "neura.data_mov"(%27) {mapping_locs = [{id = 321 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %28 = "neura.data_mov"(%23) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}, {id = 35 : i32, resource = "link", time_step = 3 : i32}, {id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %29 = "neura.data_mov"(%27) {mapping_locs = [{id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %30 = neura.grant_predicate %28, %29 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data // MAPPING-NEXT: neura.ctrl_mov %30 -> %5 {mapping_locs = [{id = 32 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data // MAPPING-NEXT: %31 = "neura.data_mov"(%21) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %32 = "neura.data_mov"(%27) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 256 : i32, resource = "register", time_step = 6 : i32}, {id = 256 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %32 = "neura.data_mov"(%27) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 256 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}, {id = 256 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %33 = neura.grant_predicate %31, %32 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 8 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data // MAPPING-NEXT: neura.ctrl_mov %33 -> %2 {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 8 : i32}]} : !neura.data !neura.data // MAPPING-NEXT: %34 = "neura.data_mov"(%21) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %35 = "neura.data_mov"(%25) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 29 : i32, resource = "link", time_step = 4 : i32}, {id = 160 : i32, resource = "register", time_step = 5 : i32}, {id = 160 : i32, resource = "register", time_step = 6 : i32}, {id = 160 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %35 = "neura.data_mov"(%25) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 29 : i32, resource = "link", time_step = 4 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 5 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %36 = neura.grant_predicate %34, %35 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data // MAPPING-NEXT: %37 = "neura.data_mov"(%36) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: "neura.return"(%37) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 9 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data) -> () @@ -78,5 +78,5 @@ // ASM: PE(0,1): // ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0] -> [$128] +// ASM-NEXT: GRANT_ONCE, [#0] -> [$0] // ASM-NEXT: } (t=3) diff --git a/test/e2e/fir/fir_kernel_vec.mlir b/test/e2e/fir/fir_kernel_vec.mlir index ddc6f7d0..bceb67e3 100644 --- a/test/e2e/fir/fir_kernel_vec.mlir +++ b/test/e2e/fir/fir_kernel_vec.mlir @@ -33,41 +33,41 @@ // MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data // MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = dense<0> : vector<4xi32>}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 1 : i32}]} : () -> !neura.data, i1> // MAPPING-NEXT: %2 = neura.reserve : !neura.data, i1> -// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 128 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %5 = neura.reserve : !neura.data -// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 37 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %9 = "neura.gep"(%8) <{operandSegmentSizes = array}> {lhs_value = "%arg0", mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 480 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 480 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %11 = "neura.load"(%10) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data, i1> // MAPPING-NEXT: %12 = "neura.data_mov"(%7) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %13 = "neura.gep"(%12) <{operandSegmentSizes = array}> {lhs_value = "%arg2", mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %15 = "neura.load"(%14) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data, i1> // MAPPING-NEXT: %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 3 : i32}, {id = 34 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 448 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %18 = "neura.vmul"(%16, %17) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %19 = "neura.data_mov"(%18) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 5 : i32}, {id = 42 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %20 = "neura.data_mov"(%4) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}, {id = 288 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %20 = "neura.data_mov"(%4) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}, {id = 288 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %21 = "neura.vadd"(%19, %20) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %22 = "neura.data_mov"(%7) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %22 = "neura.data_mov"(%7) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %23 = "neura.add"(%22) {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 2 : i32}], rhs_value = 4 : i64} : (!neura.data) -> !neura.data // MAPPING-NEXT: %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %25 = "neura.icmp"(%24) <{cmpType = "eq"}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}], rhs_value = 32 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %26 = "neura.data_mov"(%25) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %26 = "neura.data_mov"(%25) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %27 = "neura.not"(%26) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %28 = "neura.data_mov"(%23) {mapping_locs = [{id = 352 : i32, resource = "register", time_step = 2 : i32}, {id = 35 : i32, resource = "link", time_step = 3 : i32}, {id = 320 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %29 = "neura.data_mov"(%27) {mapping_locs = [{id = 321 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %28 = "neura.data_mov"(%23) {mapping_locs = [{id = 352 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}, {id = 35 : i32, resource = "link", time_step = 3 : i32}, {id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %29 = "neura.data_mov"(%27) {mapping_locs = [{id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %30 = neura.grant_predicate %28, %29 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data // MAPPING-NEXT: neura.ctrl_mov %30 -> %5 {mapping_locs = [{id = 32 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data // MAPPING-NEXT: %31 = "neura.data_mov"(%21) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %32 = "neura.data_mov"(%27) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 256 : i32, resource = "register", time_step = 6 : i32}, {id = 256 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %32 = "neura.data_mov"(%27) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 256 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}, {id = 256 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %33 = neura.grant_predicate %31, %32 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 8 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> // MAPPING-NEXT: neura.ctrl_mov %33 -> %2 {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 8 : i32}]} : !neura.data, i1> !neura.data, i1> // MAPPING-NEXT: %34 = "neura.data_mov"(%21) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %35 = "neura.data_mov"(%25) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 29 : i32, resource = "link", time_step = 4 : i32}, {id = 160 : i32, resource = "register", time_step = 5 : i32}, {id = 160 : i32, resource = "register", time_step = 6 : i32}, {id = 160 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %35 = "neura.data_mov"(%25) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 29 : i32, resource = "link", time_step = 4 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 5 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}, {id = 160 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %36 = neura.grant_predicate %34, %35 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> // MAPPING-NEXT: %37 = "neura.data_mov"(%36) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> // MAPPING-NEXT: %38 = "neura.vector.reduce.add"(%37) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 9 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, i1>) -> !neura.data @@ -80,6 +80,6 @@ // ASM: PE(0,1): // ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [] -> [$128] +// ASM-NEXT: GRANT_ONCE, [] -> [$0] // ASM-NEXT: } (t=3) diff --git a/test/e2e/histogram/histogram_kernel.mlir b/test/e2e/histogram/histogram_kernel.mlir index 4d546124..eed15247 100644 --- a/test/e2e/histogram/histogram_kernel.mlir +++ b/test/e2e/histogram/histogram_kernel.mlir @@ -15,7 +15,7 @@ // RUN: --transform-ctrl-to-data-flow \ // RUN: --fold-constant \ // RUN: --insert-data-mov \ -// RUN: --map-to-accelerator="mapping-strategy=heuristic" \ +// RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" \ // RUN: --architecture-spec=%S/../../arch_spec/architecture.yaml \ // RUN: --generate-code -o %t-mapping.mlir // RUN: FileCheck %s --input-file=%t-mapping.mlir -check-prefix=MAPPING @@ -39,20 +39,20 @@ // MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %5 = neura.reserve : !neura.data -// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data // MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %9 = "neura.gep"(%8) <{operandSegmentSizes = array}> {lhs_value = "%arg0", mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 448 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %11 = "neura.load"(%10) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 448 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %13 = "neura.fadd"(%12) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 3 : i32}], rhs_value = -1.000000e+00 : f32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 448 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %15 = "neura.fmul"(%14) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 3 : i32}], rhs_value = 5.000000e+00 : f32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 448 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %16 = "neura.data_mov"(%15) {mapping_locs = [{id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %17 = "neura.data_mov"(%4) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %18 = "neura.fdiv"(%16, %17) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %19 = "neura.data_mov"(%18) {mapping_locs = [{id = 448 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %19 = "neura.data_mov"(%18) {mapping_locs = [{id = 448 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %20 = "neura.cast"(%19) <{cast_type = "fptosi"}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %21 = "neura.data_mov"(%20) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %22 = neura.sext %21 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data -> !neura.data @@ -62,21 +62,21 @@ // MAPPING-NEXT: %26 = "neura.load"(%25) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 10 : i32, x = 0 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %27 = "neura.data_mov"(%26) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 10 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %28 = "neura.add"(%27) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 11 : i32, x = 1 : i32, y = 2 : i32}], rhs_value = 1 : i32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %29 = "neura.data_mov"(%28) {mapping_locs = [{id = 288 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %30 = "neura.data_mov"(%24) {mapping_locs = [{id = 38 : i32, resource = "link", time_step = 9 : i32}, {id = 42 : i32, resource = "link", time_step = 10 : i32}, {id = 289 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %29 = "neura.data_mov"(%28) {mapping_locs = [{id = 288 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %30 = "neura.data_mov"(%24) {mapping_locs = [{id = 38 : i32, resource = "link", time_step = 9 : i32}, {id = 42 : i32, resource = "link", time_step = 10 : i32}, {id = 289 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: "neura.store"(%29, %30) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 12 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> () -// MAPPING-NEXT: %31 = "neura.data_mov"(%7) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %31 = "neura.data_mov"(%7) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %32 = "neura.add"(%31) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 2 : i32}], rhs_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %33 = "neura.data_mov"(%32) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %33 = "neura.data_mov"(%32) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %34 = "neura.icmp"(%33) <{cmpType = "eq"}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}], rhs_value = 20 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %35 = "neura.data_mov"(%34) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %35 = "neura.data_mov"(%34) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %36 = "neura.not"(%35) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %37 = "neura.data_mov"(%32) {mapping_locs = [{id = 321 : i32, resource = "register", time_step = 2 : i32}, {id = 321 : i32, resource = "register", time_step = 3 : i32}, {id = 321 : i32, resource = "register", time_step = 4 : i32}, {id = 321 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %38 = "neura.data_mov"(%36) {mapping_locs = [{id = 320 : i32, resource = "register", time_step = 4 : i32}, {id = 320 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %37 = "neura.data_mov"(%32) {mapping_locs = [{id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 2 : i32}, {id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 3 : i32}, {id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 4 : i32}, {id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %38 = "neura.data_mov"(%36) {mapping_locs = [{id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 4 : i32}, {id = 320 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %39 = neura.grant_predicate %37, %38 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %39 -> %5 {mapping_locs = [{id = 321 : i32, resource = "register", time_step = 6 : i32}, {id = 321 : i32, resource = "register", time_step = 7 : i32}, {id = 321 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %40 = "neura.data_mov"(%4) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 5 : i32}, {id = 192 : i32, resource = "register", time_step = 6 : i32}, {id = 192 : i32, resource = "register", time_step = 7 : i32}, {id = 192 : i32, resource = "register", time_step = 8 : i32}, {id = 192 : i32, resource = "register", time_step = 9 : i32}, {id = 192 : i32, resource = "register", time_step = 10 : i32}, {id = 192 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %41 = "neura.data_mov"(%36) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 4 : i32}, {id = 193 : i32, resource = "register", time_step = 5 : i32}, {id = 193 : i32, resource = "register", time_step = 6 : i32}, {id = 193 : i32, resource = "register", time_step = 7 : i32}, {id = 193 : i32, resource = "register", time_step = 8 : i32}, {id = 193 : i32, resource = "register", time_step = 9 : i32}, {id = 193 : i32, resource = "register", time_step = 10 : i32}, {id = 193 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %39 -> %5 {mapping_locs = [{id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 6 : i32}, {id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 7 : i32}, {id = 321 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %40 = "neura.data_mov"(%4) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 5 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 6 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 7 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 8 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 9 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 10 : i32}, {id = 192 : i32, per_tile_register_id = 0 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %41 = "neura.data_mov"(%36) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 4 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 5 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 6 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 7 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 8 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 9 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 10 : i32}, {id = 193 : i32, per_tile_register_id = 1 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: %42 = neura.grant_predicate %40, %41 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 12 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data // MAPPING-NEXT: neura.ctrl_mov %42 -> %2 {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 12 : i32}]} : !neura.data !neura.data // MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 12 : i32, x = 3 : i32, y = 3 : i32}]} : () -> () @@ -88,5 +88,5 @@ // ASM: PE(2,2): // ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0] -> [$320] +// ASM-NEXT: GRANT_ONCE, [#0] -> [$0] // ASM-NEXT: } (t=0) diff --git a/test/mapping_quality/branch_for.mlir b/test/mapping_quality/branch_for.mlir index 05349589..a73107ec 100644 --- a/test/mapping_quality/branch_for.mlir +++ b/test/mapping_quality/branch_for.mlir @@ -196,6 +196,7 @@ func.func @loop_test() -> f32 { // YAML: array_config: // YAML-NEXT: columns: 4 // YAML-NEXT: rows: 4 +// YAML-NEXT: compiled_ii: 5 // YAML-NEXT: cores: // YAML-NEXT: - column: 0 // YAML-NEXT: row: 1 diff --git a/test/neura/ctrl/branch_for.mlir b/test/neura/ctrl/branch_for.mlir index 40837e08..6e5da358 100644 --- a/test/neura/ctrl/branch_for.mlir +++ b/test/neura/ctrl/branch_for.mlir @@ -200,6 +200,7 @@ func.func @loop_test() -> f32 { // YAML: array_config: // YAML-NEXT: columns: 4 // YAML-NEXT: rows: 4 +// YAML-NEXT: compiled_ii: 4 // YAML-NEXT: cores: // YAML-NEXT: - column: 0 // YAML-NEXT: row: 0