From d32810ef72b24bf294b03a319703cf6151253e95 Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Fri, 26 Sep 2025 09:09:53 +0800 Subject: [PATCH 1/6] rewrite tryRouteDataMove --- include/NeuraDialect/NeuraOps.td | 17 + .../Architecture/Architecture.cpp | 16 +- lib/NeuraDialect/Mapping/mapping_util.cpp | 382 +++++++++++++----- .../Transforms/MapToAcceleratorPass.cpp | 2 +- 4 files changed, 302 insertions(+), 115 deletions(-) diff --git a/include/NeuraDialect/NeuraOps.td b/include/NeuraDialect/NeuraOps.td index 88513411..63fbd789 100644 --- a/include/NeuraDialect/NeuraOps.td +++ b/include/NeuraDialect/NeuraOps.td @@ -211,6 +211,23 @@ def Neura_CastOp : Op{ // let assemblyFormat = "$input type($input) `->` type($output) `,` $predicate attr-dict"; } + +// Defines an alloca operation for memory allocation. +def Neura_AllocaOp : Op { + let summary = "Memory allocation operation"; + let description = [{ + Allocates memory on the stack, similar to llvm.alloca. + Takes a predicated size value and returns a pointer to the allocated memory. + + Example: + %ptr = neura.alloca %size : !neura.data -> !llvm.ptr + }]; + + let arguments = (ins AnyType:$size); + let results = (outs AnyType:$result); + let assemblyFormat = "$size attr-dict `:` type($size) `->` type($result)"; +} + // ---------------------------------------------------- // Defines vector operations. diff --git a/lib/NeuraDialect/Architecture/Architecture.cpp b/lib/NeuraDialect/Architecture/Architecture.cpp index 933cc209..1bd23073 100644 --- a/lib/NeuraDialect/Architecture/Architecture.cpp +++ b/lib/NeuraDialect/Architecture/Architecture.cpp @@ -215,16 +215,24 @@ Architecture::Architecture(int width, int height) { // cannot distinguish between different register files.. Register *register_0 = new Register(reg_id++); Register *register_1 = new Register(reg_id++); + Register *register_2 = new Register(reg_id++); + Register *register_3 = new Register(reg_id++); RegisterFile *register_file_0 = new RegisterFile(0); register_file_0->addRegister(register_0); register_file_0->addRegister(register_1); + register_file_0->addRegister(register_2); + register_file_0->addRegister(register_3); // Creates registers as a register file. - Register *register_2 = new Register(reg_id++); - Register *register_3 = new Register(reg_id++); + Register *register_4 = new Register(reg_id++); + Register *register_5 = new Register(reg_id++); + Register *register_6 = new Register(reg_id++); + Register *register_7 = new Register(reg_id++); RegisterFile *register_file_1 = new RegisterFile(1); - register_file_1->addRegister(register_2); - register_file_1->addRegister(register_3); + register_file_1->addRegister(register_4); + register_file_1->addRegister(register_5); + register_file_1->addRegister(register_6); + register_file_1->addRegister(register_7); // Assembles register files into a cluster. RegisterFileCluster *register_file_cluster = diff --git a/lib/NeuraDialect/Mapping/mapping_util.cpp b/lib/NeuraDialect/Mapping/mapping_util.cpp index 2e998c93..4abf9bf0 100644 --- a/lib/NeuraDialect/Mapping/mapping_util.cpp +++ b/lib/NeuraDialect/Mapping/mapping_util.cpp @@ -7,6 +7,7 @@ #include "mlir/IR/Operation.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" #include @@ -412,147 +413,308 @@ Register *mlir::neura::getAvailableRegister(const MappingState &state, return nullptr; } +// bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, +// MappingLoc dst_loc, bool is_backward_move, +// const MappingState &state, +// std::vector &path_out) { +// // Specially handles the case where src and dst are the same tile. +// if (src_loc.resource == dst_loc.resource) { +// // When the source and destination are on the same tile, we still need to +// // allocate registers for data movement. +// Tile *tile = dyn_cast(src_loc.resource); +// if (!tile) { +// llvm::errs() << "[tryRouteDataMove] Source is not a tile\n"; +// return false; +// } + +// // Defines the time window for the register allocation. +// int start_time = src_loc.time_step; +// int exclusive_end_time = dst_loc.time_step; + +// // For backward moves, we need to adjust the end time. +// if (is_backward_move) { +// exclusive_end_time += state.getII(); +// } + +// // Finds a register that is available during start_time to +// // exclusive_end_time. +// Register *reg = +// getAvailableRegister(state, tile, start_time, exclusive_end_time); +// if (!reg) { +// llvm::errs() << "[tryRouteDataMove] No available register found for " +// << "tile: " << tile->getId() +// << " from time step: " << start_time +// << " to time step: " << exclusive_end_time << "\n"; +// return false; +// } + +// // Adds the register locations to the path. +// for (int t = start_time; t < exclusive_end_time; ++t) { +// MappingLoc reg_loc{reg, t}; +// path_out.push_back(reg_loc); +// } + +// llvm::errs() << "[tryRouteDataMove] Allocated register " << reg->getId() +// << " for same-tile data movement from t=" << start_time +// << " to t=" << exclusive_end_time << "\n"; +// return true; +// } +// struct QueueEntry { +// Tile *tile; +// int time; +// std::vector path; +// }; + +// Tile *src_tile = dyn_cast(src_loc.resource); +// Tile *dst_tile = dyn_cast(dst_loc.resource); + +// std::queue queue; +// std::set visited; + +// queue.push({src_tile, src_loc.time_step, {}}); +// visited.insert(src_tile); + +// // Tolerates the deadline step by II for backward moves (as the data should +// // arrive at the next iteration). +// const int deadline_step = +// dst_loc.time_step + (is_backward_move ? state.getII() : 0); + +// // BFS-style search for a path from src_tile to dst_tile. +// while (!queue.empty()) { +// auto [current_tile, current_step, current_path] = queue.front(); +// queue.pop(); + +// if (current_tile == dst_tile) { +// // Confirms path reaches the target tile no later than deadline step. +// if (current_step <= deadline_step) { +// // Either arrives exactly right before the dst starts computation. +// // So the current_step on the target tile is the same as +// deadlinestep. if (current_step == deadline_step) { +// path_out = current_path; +// return true; +// } + +// assert(!current_path.empty() && +// "Path should not be empty when checking last link"); + +// Register *available_register = +// getAvailableRegister(state, dst_tile, current_step, +// deadline_step); +// if (!available_register) { +// llvm::errs() << "[tryRouteDataMove] No available register found +// for" +// << "dst_tile: " << dst_tile->getId() +// << " from time step: " << current_step +// << " till deadline step: " << deadline_step << "\n"; +// // None of the register is available, skip this route and try +// // others. +// continue; +// } +// // llvm::errs() << "[tryRouteDataMove] Found available register: " +// // << available_register->getId() +// // << " in register_file: " +// // << available_register->getRegisterFile()->getId() +// // << " at tile: " << dst_tile->getId() +// // << " from time step: " << current_step +// // << " till deadline step: " << deadline_step << "\n"; +// // Register is available, so we can occupy the specific register +// // across remaining time steps. +// std::vector register_occupyings; +// for (int t = current_step; t < deadline_step; ++t) { +// MappingLoc register_loc{available_register, t}; +// register_occupyings.push_back(register_loc); +// // Double-checks if the register is available across the time +// steps. assert(state.isAvailableAcrossTime(register_loc)); +// } + +// path_out = current_path; +// path_out.insert(path_out.end(), register_occupyings.begin(), +// register_occupyings.end()); +// return true; + +// } else { +// // Arrives too late, not schedulable. +// continue; +// } +// } + +// for (MappingLoc current_step_next_link : +// state.getCurrentStepLinks({current_tile, current_step})) { +// if (!state.isAvailableAcrossTime(current_step_next_link)) { +// continue; +// } +// Link *next_link = dyn_cast(current_step_next_link.resource); +// Tile *next_tile = next_link->getDstTile(); +// int next_step = current_step + 1; + +// if (!visited.insert(next_tile).second) { +// continue; +// } + +// std::vector extended_path = current_path; +// extended_path.push_back(current_step_next_link); +// queue.push({next_tile, next_step, std::move(extended_path)}); +// } +// } + +// return false; +// } + bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, MappingLoc dst_loc, bool is_backward_move, const MappingState &state, std::vector &path_out) { - // Specially handles the case where src and dst are the same tile. - if (src_loc.resource == dst_loc.resource) { - // When the source and destination are on the same tile, we still need to - // allocate registers for data movement. - Tile *tile = dyn_cast(src_loc.resource); - if (!tile) { - llvm::errs() << "[tryRouteDataMove] Source is not a tile\n"; - return false; - } + // Clears the output path. + path_out.clear(); + + // Gets the source tile and destination tile. + Tile *src_tile = dyn_cast(src_loc.resource); + Tile *dst_tile = dyn_cast(dst_loc.resource); - // Defines the time window for the register allocation. + if (!src_tile || !dst_tile) { + llvm::outs() << "[tryRouteDataMove] Source or destination is not a tile\n "; + return false; + } + + // Calculates the deadline time step (adds II for backward moves). + int deadline_step = dst_loc.time_step; + if (is_backward_move) { + deadline_step += state.getII(); + } + + llvm::outs() << "[tryRouteDataMove] Routing from Tile#" << src_tile->getId() + << " @t=" << src_loc.time_step << " to Tile#" + << dst_tile->getId() << " @t=" << deadline_step << "\n"; + + // Special case: source tile and destination tile are the same. + if (src_tile == dst_tile) { + // Uses register as routing resource within the same tile. int start_time = src_loc.time_step; - int exclusive_end_time = dst_loc.time_step; - - // For backward moves, we need to adjust the end time. - if (is_backward_move) { - exclusive_end_time += state.getII(); - } - - // Finds a register that is available during start_time to - // exclusive_end_time. - Register *reg = - getAvailableRegister(state, tile, start_time, exclusive_end_time); - if (!reg) { - llvm::errs() << "[tryRouteDataMove] No available register found for " - << "tile: " << tile->getId() - << " from time step: " << start_time - << " to time step: " << exclusive_end_time << "\n"; + int end_time = deadline_step; + + // Finds an available register to store the data. + Register *available_reg = + getAvailableRegister(state, src_tile, start_time, end_time); + if (!available_reg) { + llvm::outs() + << "[tryRouteDataMove] Cannot find available register on Tile#" + << src_tile->getId() << " for time range: t=" << start_time + << " to t=" << end_time << "\n"; return false; } - // Adds the register locations to the path. - for (int t = start_time; t < exclusive_end_time; ++t) { - MappingLoc reg_loc{reg, t}; - path_out.push_back(reg_loc); + // Builds path: uses register to store data for the specified time period. + for (int t = start_time; t < end_time; ++t) { + path_out.push_back({available_reg, t}); } - llvm::errs() << "[tryRouteDataMove] Allocated register " << reg->getId() - << " for same-tile data movement from t=" << start_time - << " to t=" << exclusive_end_time << "\n"; + llvm::outs() << "[tryRouteDataMove] Successfully routed on same tile using " + "Register #" + << available_reg->getId() << "\n"; return true; } - struct QueueEntry { - Tile *tile; - int time; - std::vector path; - }; - - Tile *src_tile = dyn_cast(src_loc.resource); - Tile *dst_tile = dyn_cast(dst_loc.resource); - - std::queue queue; - std::set visited; - queue.push({src_tile, src_loc.time_step, {}}); - visited.insert(src_tile); - - // Tolerates the deadline step by II for backward moves (as the data should - // arrive at the next iteration). - const int deadline_step = - dst_loc.time_step + (is_backward_move ? state.getII() : 0); - - // BFS-style search for a path from src_tile to dst_tile. - while (!queue.empty()) { - auto [current_tile, current_step, current_path] = queue.front(); - queue.pop(); + // Search state: records current tile, time step, and path to reach this + // state. + struct SearchState { + Tile *current_tile; // Current tile location. + int current_time; // Current time step. + std::vector + path; // Routing resource path to reach current state. + }; - if (current_tile == dst_tile) { - // Confirms path reaches the target tile no later than deadline step. - if (current_step <= deadline_step) { - // Either arrives exactly right before the dst starts computation. - // So the current_step on the target tile is the same as deadline step. - if (current_step == deadline_step) { - path_out = current_path; + // BFS search. + std::queue search_queue; + std::set> + visited; // Records visited (tile, time) combinations. + + // Initial state: starts from source tile. + search_queue.push({src_tile, src_loc.time_step, {}}); + visited.insert({src_tile, src_loc.time_step}); + + while (!search_queue.empty()) { + SearchState current_state = search_queue.front(); + search_queue.pop(); + + // Checks if destination tile is reached with appropriate timing. + if (current_state.current_tile == dst_tile) { + if (current_state.current_time <= deadline_step) { + if (current_state.current_time == deadline_step) { + // Arrives exactly at deadline, no additional register needed. + path_out = current_state.path; return true; - } + } else { + // Arrives early, needs register on destination tile to wait. + Register *wait_reg = getAvailableRegister( + state, dst_tile, current_state.current_time, deadline_step); + if (!wait_reg) { + llvm::outs() << "[tryRouteDataMove] Cannot find available waiting" + "register on destination Tile#" + << dst_tile->getId() << "\n"; + continue; // Tries other paths. + } - assert(!current_path.empty() && - "Path should not be empty when checking last link"); - - Register *available_register = - getAvailableRegister(state, dst_tile, current_step, deadline_step); - if (!available_register) { - llvm::errs() << "[tryRouteDataMove] No available register found for " - << "dst_tile: " << dst_tile->getId() - << " from time step: " << current_step - << " till deadline step: " << deadline_step << "\n"; - // None of the register is available, skip this route and try others. - continue; - } - // llvm::errs() << "[tryRouteDataMove] Found available register: " - // << available_register->getId() - // << " in register_file: " - // << available_register->getRegisterFile()->getId() - // << " at tile: " << dst_tile->getId() - // << " from time step: " << current_step - // << " till deadline step: " << deadline_step << "\n"; - // Register is available, so we can occupy the specific register across - // remaining time steps. - std::vector register_occupyings; - for (int t = current_step; t < deadline_step; ++t) { - MappingLoc register_loc{available_register, t}; - register_occupyings.push_back(register_loc); - // Double-checks if the register is available across the time steps. - assert(state.isAvailableAcrossTime(register_loc)); + // Builds complete path. + path_out = current_state.path; + for (int t = current_state.current_time; t < deadline_step; ++t) { + path_out.push_back({wait_reg, t}); + } + return true; } - - path_out = current_path; - path_out.insert(path_out.end(), register_occupyings.begin(), - register_occupyings.end()); - return true; - } else { - // Arrives too late, not schedulable. + // Arrives too late, skips this path. continue; } } - for (MappingLoc current_step_next_link : - state.getCurrentStepLinks({current_tile, current_step})) { - if (!state.isAvailableAcrossTime(current_step_next_link)) { - continue; + // Skips if current time already exceeds deadline. + if (current_state.current_time >= deadline_step) { + continue; + } + + // Explores two routing options from current tile: + + // Option 1: Uses register on current tile to wait one time step. + Register *wait_register = getAvailableRegister( + state, current_state.current_tile, current_state.current_time, + current_state.current_time + 1); + if (wait_register) { + int next_time = current_state.current_time + 1; + if (visited.insert({current_state.current_tile, next_time}).second) { + std::vector new_path = current_state.path; + new_path.push_back({wait_register, current_state.current_time}); + + search_queue.push({current_state.current_tile, next_time, new_path}); } - Link *next_link = dyn_cast(current_step_next_link.resource); - Tile *next_tile = next_link->getDstTile(); - int next_step = current_step + 1; + } - if (!visited.insert(next_tile).second) { + // Option 2: Moves to adjacent tile through link. + for (Link *out_link : current_state.current_tile->getOutLinks()) { + MappingLoc link_loc = {out_link, current_state.current_time}; + + // Checks if link is available at current time step. + if (!state.isAvailableAcrossTime(link_loc)) { continue; } - std::vector extended_path = current_path; - extended_path.push_back(current_step_next_link); - queue.push({next_tile, next_step, std::move(extended_path)}); + Tile *next_tile = out_link->getDstTile(); + int next_time = current_state.current_time + 1; + + // Checks if this (tile, time) combination has been visited. + if (visited.insert({next_tile, next_time}).second) { + std::vector new_path = current_state.path; + new_path.push_back(link_loc); + + search_queue.push({next_tile, next_time, new_path}); + } } } + // Search failed. + llvm::outs() << "[tryRouteDataMove] Cannot find routing path from Tile#" + << src_tile->getId() << " @t=" << src_loc.time_step + << " to Tile#" << dst_tile->getId() << " @t=" << deadline_step + << "\n"; return false; } diff --git a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp index eda7f7ff..2931614a 100644 --- a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp +++ b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp @@ -169,7 +169,7 @@ struct MapToAcceleratorPass } // AcceleratorConfig config{/*numTiles=*/8}; // Example - Architecture architecture(4, 4); + Architecture architecture(6, 6); int res_mii = calculateResMii(func, architecture); const int possibleMinII = std::max(rec_mii, res_mii); From 32c969c4fd214f7dc669f63d6d4488c8ea9f915b Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Fri, 26 Sep 2025 14:26:38 +0800 Subject: [PATCH 2/6] support nested loop mapping --- .../Architecture/Architecture.cpp | 40 +- lib/NeuraDialect/Mapping/mapping_util.cpp | 147 ---- .../Transforms/MapToAcceleratorPass.cpp | 2 +- test/code_gen/test_code_generate.mlir | 730 +++++++++--------- .../simple_loop/simple_loop.mlir | 104 +-- .../simple_loop_reduction.mlir | 60 +- test/mapping_quality/branch_for.mlir | 350 ++++----- test/mapping_quality/tiny_loop.mlir | 110 +-- test/neura/ctrl/branch_for.mlir | 109 +-- 9 files changed, 702 insertions(+), 950 deletions(-) diff --git a/lib/NeuraDialect/Architecture/Architecture.cpp b/lib/NeuraDialect/Architecture/Architecture.cpp index 1bd23073..37961ae5 100644 --- a/lib/NeuraDialect/Architecture/Architecture.cpp +++ b/lib/NeuraDialect/Architecture/Architecture.cpp @@ -209,36 +209,24 @@ Architecture::Architecture(int width, int height) { for (int x = 0; x < width; ++x) { // Gets the tile by coordinates. Tile *tile = getTile(x, y); - - // Creates registers as a register file. - // FIXME: We have to assign different IDs due to the hash function - // cannot distinguish between different register files.. - Register *register_0 = new Register(reg_id++); - Register *register_1 = new Register(reg_id++); - Register *register_2 = new Register(reg_id++); - Register *register_3 = new Register(reg_id++); - RegisterFile *register_file_0 = new RegisterFile(0); - register_file_0->addRegister(register_0); - register_file_0->addRegister(register_1); - register_file_0->addRegister(register_2); - register_file_0->addRegister(register_3); - - // Creates registers as a register file. - Register *register_4 = new Register(reg_id++); - Register *register_5 = new Register(reg_id++); - Register *register_6 = new Register(reg_id++); - Register *register_7 = new Register(reg_id++); - RegisterFile *register_file_1 = new RegisterFile(1); - register_file_1->addRegister(register_4); - register_file_1->addRegister(register_5); - register_file_1->addRegister(register_6); - register_file_1->addRegister(register_7); + const int kNUM_REGS_PER_REGFILE = 4; + const int kNUM_REGFILES_PER_CLUSTER = 2; // Assembles register files into a cluster. RegisterFileCluster *register_file_cluster = new RegisterFileCluster(y * width + x); - register_file_cluster->addRegisterFile(register_file_0); - register_file_cluster->addRegisterFile(register_file_1); + + // Creates registers as a register file. + // FIXME: We have to assign different IDs due to the hash function + // cannot distinguish between different register files.. + for (int file_idx = 0; file_idx < kNUM_REGFILES_PER_CLUSTER; ++file_idx) { + RegisterFile *register_file = new RegisterFile(file_idx); + for (int reg_idx = 0; reg_idx < kNUM_REGS_PER_REGFILE; ++reg_idx) { + Register *reg = new Register(reg_id++); + register_file->addRegister(reg); + } + register_file_cluster->addRegisterFile(register_file); + } // Adds register file cluster to the tile. tile->addRegisterFileCluster(register_file_cluster); diff --git a/lib/NeuraDialect/Mapping/mapping_util.cpp b/lib/NeuraDialect/Mapping/mapping_util.cpp index 4abf9bf0..32747e6f 100644 --- a/lib/NeuraDialect/Mapping/mapping_util.cpp +++ b/lib/NeuraDialect/Mapping/mapping_util.cpp @@ -413,153 +413,6 @@ Register *mlir::neura::getAvailableRegister(const MappingState &state, return nullptr; } -// bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, -// MappingLoc dst_loc, bool is_backward_move, -// const MappingState &state, -// std::vector &path_out) { -// // Specially handles the case where src and dst are the same tile. -// if (src_loc.resource == dst_loc.resource) { -// // When the source and destination are on the same tile, we still need to -// // allocate registers for data movement. -// Tile *tile = dyn_cast(src_loc.resource); -// if (!tile) { -// llvm::errs() << "[tryRouteDataMove] Source is not a tile\n"; -// return false; -// } - -// // Defines the time window for the register allocation. -// int start_time = src_loc.time_step; -// int exclusive_end_time = dst_loc.time_step; - -// // For backward moves, we need to adjust the end time. -// if (is_backward_move) { -// exclusive_end_time += state.getII(); -// } - -// // Finds a register that is available during start_time to -// // exclusive_end_time. -// Register *reg = -// getAvailableRegister(state, tile, start_time, exclusive_end_time); -// if (!reg) { -// llvm::errs() << "[tryRouteDataMove] No available register found for " -// << "tile: " << tile->getId() -// << " from time step: " << start_time -// << " to time step: " << exclusive_end_time << "\n"; -// return false; -// } - -// // Adds the register locations to the path. -// for (int t = start_time; t < exclusive_end_time; ++t) { -// MappingLoc reg_loc{reg, t}; -// path_out.push_back(reg_loc); -// } - -// llvm::errs() << "[tryRouteDataMove] Allocated register " << reg->getId() -// << " for same-tile data movement from t=" << start_time -// << " to t=" << exclusive_end_time << "\n"; -// return true; -// } -// struct QueueEntry { -// Tile *tile; -// int time; -// std::vector path; -// }; - -// Tile *src_tile = dyn_cast(src_loc.resource); -// Tile *dst_tile = dyn_cast(dst_loc.resource); - -// std::queue queue; -// std::set visited; - -// queue.push({src_tile, src_loc.time_step, {}}); -// visited.insert(src_tile); - -// // Tolerates the deadline step by II for backward moves (as the data should -// // arrive at the next iteration). -// const int deadline_step = -// dst_loc.time_step + (is_backward_move ? state.getII() : 0); - -// // BFS-style search for a path from src_tile to dst_tile. -// while (!queue.empty()) { -// auto [current_tile, current_step, current_path] = queue.front(); -// queue.pop(); - -// if (current_tile == dst_tile) { -// // Confirms path reaches the target tile no later than deadline step. -// if (current_step <= deadline_step) { -// // Either arrives exactly right before the dst starts computation. -// // So the current_step on the target tile is the same as -// deadlinestep. if (current_step == deadline_step) { -// path_out = current_path; -// return true; -// } - -// assert(!current_path.empty() && -// "Path should not be empty when checking last link"); - -// Register *available_register = -// getAvailableRegister(state, dst_tile, current_step, -// deadline_step); -// if (!available_register) { -// llvm::errs() << "[tryRouteDataMove] No available register found -// for" -// << "dst_tile: " << dst_tile->getId() -// << " from time step: " << current_step -// << " till deadline step: " << deadline_step << "\n"; -// // None of the register is available, skip this route and try -// // others. -// continue; -// } -// // llvm::errs() << "[tryRouteDataMove] Found available register: " -// // << available_register->getId() -// // << " in register_file: " -// // << available_register->getRegisterFile()->getId() -// // << " at tile: " << dst_tile->getId() -// // << " from time step: " << current_step -// // << " till deadline step: " << deadline_step << "\n"; -// // Register is available, so we can occupy the specific register -// // across remaining time steps. -// std::vector register_occupyings; -// for (int t = current_step; t < deadline_step; ++t) { -// MappingLoc register_loc{available_register, t}; -// register_occupyings.push_back(register_loc); -// // Double-checks if the register is available across the time -// steps. assert(state.isAvailableAcrossTime(register_loc)); -// } - -// path_out = current_path; -// path_out.insert(path_out.end(), register_occupyings.begin(), -// register_occupyings.end()); -// return true; - -// } else { -// // Arrives too late, not schedulable. -// continue; -// } -// } - -// for (MappingLoc current_step_next_link : -// state.getCurrentStepLinks({current_tile, current_step})) { -// if (!state.isAvailableAcrossTime(current_step_next_link)) { -// continue; -// } -// Link *next_link = dyn_cast(current_step_next_link.resource); -// Tile *next_tile = next_link->getDstTile(); -// int next_step = current_step + 1; - -// if (!visited.insert(next_tile).second) { -// continue; -// } - -// std::vector extended_path = current_path; -// extended_path.push_back(current_step_next_link); -// queue.push({next_tile, next_step, std::move(extended_path)}); -// } -// } - -// return false; -// } - bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, MappingLoc dst_loc, bool is_backward_move, const MappingState &state, diff --git a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp index 2931614a..f07f9465 100644 --- a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp +++ b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp @@ -173,7 +173,7 @@ struct MapToAcceleratorPass int res_mii = calculateResMii(func, architecture); const int possibleMinII = std::max(rec_mii, res_mii); - constexpr int maxII = 10; + constexpr int maxII = 15; std::vector topologically_sorted_ops = getTopologicallySortedOps(func); if (topologically_sorted_ops.empty()) { diff --git a/test/code_gen/test_code_generate.mlir b/test/code_gen/test_code_generate.mlir index da04009f..c3ad2928 100644 --- a/test/code_gen/test_code_generate.mlir +++ b/test/code_gen/test_code_generate.mlir @@ -31,74 +31,74 @@ func.func @loop_test() -> f32 { return %result : f32 } - // MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 2 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { - // MAPPING-NEXT: %0 = "neura.constant"() <{predicate = true, value = 10 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data - // MAPPING-NEXT: %1 = "neura.data_mov"(%0) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %2 = "neura.grant_once"(%1) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %3 = "neura.constant"() <{predicate = true, value = 0 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data - // MAPPING-NEXT: %4 = "neura.data_mov"(%3) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %5 = "neura.grant_once"(%4) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %6 = "neura.constant"() <{predicate = true, value = 1 : i64}> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 0 : i32}]} : () -> !neura.data - // MAPPING-NEXT: %7 = "neura.data_mov"(%6) {mapping_locs = [{id = 8 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %8 = "neura.grant_once"(%7) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %9 = "neura.constant"() <{predicate = true, value = 3.000000e+00 : f32}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 3 : i32}]} : () -> !neura.data - // MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %11 = "neura.grant_once"(%10) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %12 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data - // MAPPING-NEXT: %13 = "neura.data_mov"(%12) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %14 = "neura.grant_once"(%13) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %15 = neura.reserve : !neura.data - // MAPPING-NEXT: %16 = "neura.data_mov"(%2) {mapping_locs = [{id = 4 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %18 = neura.reserve : !neura.data - // MAPPING-NEXT: %19 = "neura.data_mov"(%8) {mapping_locs = [{id = 8 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %21 = neura.reserve : !neura.data - // MAPPING-NEXT: %22 = "neura.data_mov"(%11) {mapping_locs = [{id = 40 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %24 = neura.reserve : !neura.data - // MAPPING-NEXT: %25 = "neura.data_mov"(%14) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %26 = "neura.phi"(%24, %25) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %27 = neura.reserve : !neura.data - // MAPPING-NEXT: %28 = "neura.data_mov"(%5) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %29 = "neura.phi"(%27, %28) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %30 = "neura.data_mov"(%26) {mapping_locs = [{id = 24 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %31 = "neura.data_mov"(%23) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %32 = "neura.fadd"(%30, %31) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %33 = "neura.data_mov"(%29) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %34 = "neura.data_mov"(%20) {mapping_locs = [{id = 7 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %35 = "neura.add"(%33, %34) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %36 = "neura.data_mov"(%35) {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %37 = "neura.data_mov"(%17) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %38 = "neura.icmp"(%36, %37) <{cmpType = "slt"}> {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data - // MAPPING-NEXT: %39 = "neura.data_mov"(%35) {mapping_locs = [{id = 25 : i32, resource = "register", time_step = 3 : i32}, {id = 25 : i32, resource = "register", time_step = 4 : i32}, {id = 25 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %40 = "neura.data_mov"(%38) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 4 : i32}, {id = 24 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %41 = neura.grant_predicate %39, %40 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: neura.ctrl_mov %41 -> %27 {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 6 : i32}, {id = 20 : i32, resource = "register", time_step = 7 : i32}]} : !neura.data !neura.data - // MAPPING-NEXT: %42 = "neura.data_mov"(%32) {mapping_locs = [{id = 26 : i32, resource = "register", time_step = 5 : i32}, {id = 26 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %43 = "neura.data_mov"(%38) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 4 : i32}, {id = 28 : i32, resource = "link", time_step = 5 : i32}, {id = 33 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %44 = neura.grant_predicate %42, %43 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: neura.ctrl_mov %44 -> %24 {mapping_locs = [{id = 24 : i32, resource = "register", time_step = 7 : i32}, {id = 24 : i32, resource = "register", time_step = 8 : i32}, {id = 24 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data - // MAPPING-NEXT: %45 = "neura.data_mov"(%23) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 29 : i32, resource = "link", time_step = 5 : i32}, {id = 20 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %46 = "neura.data_mov"(%38) {mapping_locs = [{id = 22 : i32, resource = "register", time_step = 4 : i32}, {id = 22 : i32, resource = "register", time_step = 5 : i32}, {id = 22 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %47 = neura.grant_predicate %45, %46 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: neura.ctrl_mov %47 -> %21 {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 7 : i32}, {id = 20 : i32, resource = "link", time_step = 8 : i32}, {id = 41 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data - // MAPPING-NEXT: %48 = "neura.data_mov"(%20) {mapping_locs = [{id = 5 : i32, resource = "link", time_step = 2 : i32}, {id = 2 : i32, resource = "link", time_step = 3 : i32}, {id = 1 : i32, resource = "link", time_step = 4 : i32}, {id = 10 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %49 = "neura.data_mov"(%38) {mapping_locs = [{id = 21 : i32, resource = "register", time_step = 4 : i32}, {id = 21 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %50 = neura.grant_predicate %48, %49 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: neura.ctrl_mov %50 -> %18 {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 6 : i32}, {id = 19 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data - // MAPPING-NEXT: %51 = "neura.data_mov"(%17) {mapping_locs = [{id = 4 : i32, resource = "register", time_step = 3 : i32}, {id = 4 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %52 = "neura.data_mov"(%38) {mapping_locs = [{id = 15 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %53 = neura.grant_predicate %51, %52 {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 0 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: neura.ctrl_mov %53 -> %15 {mapping_locs = [{id = 5 : i32, resource = "register", time_step = 5 : i32}, {id = 5 : i32, resource = "register", time_step = 6 : i32}, {id = 5 : i32, resource = "register", time_step = 7 : i32}, {id = 5 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data - // MAPPING-NEXT: %54 = "neura.data_mov"(%38) {mapping_locs = [{id = 20 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %55 = "neura.not"(%54) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %56 = "neura.data_mov"(%32) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 5 : i32}, {id = 28 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %57 = "neura.data_mov"(%55) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 5 : i32}, {id = 18 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: %58 = neura.grant_predicate %56, %57 {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data - // MAPPING-NEXT: %59 = "neura.data_mov"(%58) {mapping_locs = [{id = 22 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data - // MAPPING-NEXT: "neura.return"(%59) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 8 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data) -> () - // MAPPING-NEXT: } +// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING-NEXT: %0 = "neura.constant"() <{predicate = true, value = 10 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %1 = "neura.data_mov"(%0) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %2 = "neura.grant_once"(%1) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %3 = "neura.constant"() <{predicate = true, value = 0 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %4 = "neura.data_mov"(%3) {mapping_locs = [{id = 19 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %5 = "neura.grant_once"(%4) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %6 = "neura.constant"() <{predicate = true, value = 1 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %7 = "neura.data_mov"(%6) {mapping_locs = [{id = 62 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %8 = "neura.grant_once"(%7) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %9 = "neura.constant"() <{predicate = true, value = 3.000000e+00 : f32}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 152 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %11 = "neura.grant_once"(%10) {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %12 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %13 = "neura.data_mov"(%12) {mapping_locs = [{id = 144 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %14 = "neura.grant_once"(%13) {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %15 = neura.reserve : !neura.data +// MAPPING-NEXT: %16 = "neura.data_mov"(%2) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %18 = neura.reserve : !neura.data +// MAPPING-NEXT: %19 = "neura.data_mov"(%8) {mapping_locs = [{id = 192 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %21 = neura.reserve : !neura.data +// MAPPING-NEXT: %22 = "neura.data_mov"(%11) {mapping_locs = [{id = 152 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %24 = neura.reserve : !neura.data +// MAPPING-NEXT: %25 = "neura.data_mov"(%14) {mapping_locs = [{id = 62 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %26 = "neura.phi"(%24, %25) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %27 = neura.reserve : !neura.data +// MAPPING-NEXT: %28 = "neura.data_mov"(%5) {mapping_locs = [{id = 48 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %29 = "neura.phi"(%27, %28) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %30 = "neura.data_mov"(%26) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %31 = "neura.data_mov"(%23) {mapping_locs = [{id = 66 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %32 = "neura.fadd"(%30, %31) {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %33 = "neura.data_mov"(%29) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 2 : i32}, {id = 40 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %34 = "neura.data_mov"(%20) {mapping_locs = [{id = 83 : i32, resource = "link", time_step = 2 : i32}, {id = 144 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %35 = "neura.add"(%33, %34) {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %36 = "neura.data_mov"(%35) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %37 = "neura.data_mov"(%17) {mapping_locs = [{id = 22 : i32, resource = "link", time_step = 3 : i32}, {id = 44 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %38 = "neura.icmp"(%36, %37) <{cmpType = "slt"}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %39 = "neura.data_mov"(%35) {mapping_locs = [{id = 61 : i32, resource = "link", time_step = 4 : i32}, {id = 96 : i32, resource = "register", time_step = 5 : i32}, {id = 96 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %40 = "neura.data_mov"(%38) {mapping_locs = [{id = 63 : i32, resource = "link", time_step = 5 : i32}, {id = 61 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %41 = neura.grant_predicate %39, %40 {mapping_locs = [{id = 12 : i32, resource = "tile", time_step = 7 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %41 -> %27 {mapping_locs = [{id = 39 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %42 = "neura.data_mov"(%32) {mapping_locs = [{id = 200 : i32, resource = "register", time_step = 5 : i32}, {id = 200 : i32, resource = "register", time_step = 6 : i32}, {id = 200 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %43 = "neura.data_mov"(%38) {mapping_locs = [{id = 155 : i32, resource = "register", time_step = 5 : i32}, {id = 66 : i32, resource = "link", time_step = 6 : i32}, {id = 201 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %44 = neura.grant_predicate %42, %43 {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 4 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %44 -> %24 {mapping_locs = [{id = 85 : i32, resource = "link", time_step = 8 : i32}, {id = 192 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %45 = "neura.data_mov"(%23) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 4 : i32}, {id = 105 : i32, resource = "register", time_step = 5 : i32}, {id = 105 : i32, resource = "register", time_step = 6 : i32}, {id = 105 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %46 = "neura.data_mov"(%38) {mapping_locs = [{id = 154 : i32, resource = "register", time_step = 5 : i32}, {id = 65 : i32, resource = "link", time_step = 6 : i32}, {id = 104 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %47 = neura.grant_predicate %45, %46 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %47 -> %21 {mapping_locs = [{id = 44 : i32, resource = "link", time_step = 8 : i32}, {id = 153 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %48 = "neura.data_mov"(%20) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 2 : i32}, {id = 87 : i32, resource = "link", time_step = 3 : i32}, {id = 152 : i32, resource = "register", time_step = 4 : i32}, {id = 152 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %49 = "neura.data_mov"(%38) {mapping_locs = [{id = 153 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %50 = neura.grant_predicate %48, %49 {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %50 -> %18 {mapping_locs = [{id = 63 : i32, resource = "link", time_step = 6 : i32}, {id = 62 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %51 = "neura.data_mov"(%17) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 3 : i32}, {id = 22 : i32, resource = "link", time_step = 4 : i32}, {id = 104 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %52 = "neura.data_mov"(%38) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %53 = neura.grant_predicate %51, %52 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %53 -> %15 {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 6 : i32}, {id = 57 : i32, resource = "register", time_step = 7 : i32}, {id = 57 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %54 = "neura.data_mov"(%38) {mapping_locs = [{id = 66 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %55 = "neura.not"(%54) {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %56 = "neura.data_mov"(%32) {mapping_locs = [{id = 87 : i32, resource = "link", time_step = 5 : i32}, {id = 152 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %57 = "neura.data_mov"(%55) {mapping_locs = [{id = 87 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %58 = neura.grant_predicate %56, %57 {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %59 = "neura.data_mov"(%58) {mapping_locs = [{id = 64 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: "neura.return"(%59) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 8 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> () +// MAPPING-NEXT: } // Each core represents a processing element in the CGRA array // Example: column: 1, row: 1 represents the core at position (1,1) in the 4x4 grid @@ -135,603 +135,603 @@ func.func @loop_test() -> f32 { // written into local register $20. // -// YAML: array_config: -// YAML-NEXT: columns: 4 -// YAML-NEXT: rows: 4 +// YAML: array_config: +// YAML-NEXT: columns: 6 +// YAML-NEXT: rows: 6 // YAML-NEXT: cores: // YAML-NEXT: - column: 0 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "0" +// YAML-NEXT: row: 1 +// YAML-NEXT: core_id: "6" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 1 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" +// YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#10" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$48" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 +// YAML-NEXT: - timestep: 2 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$48" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: - column: 1 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "1" +// YAML-NEXT: row: 1 +// YAML-NEXT: core_id: "7" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 1 +// YAML-NEXT: - timestep: 0 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: - opcode: "CONSTANT" // YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "#0" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 1 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "CONSTANT" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "#10" +// YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: - operand: "$56" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 2 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "$56" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$4" +// YAML-NEXT: - operand: "$56" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 3 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$5" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$4" +// YAML-NEXT: - operand: "$56" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$4" +// YAML-NEXT: - timestep: 7 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$57" // YAML-NEXT: color: "RED" +// YAML-NEXT: - column: 0 +// YAML-NEXT: row: 2 +// YAML-NEXT: core_id: "12" +// YAML-NEXT: entries: +// YAML-NEXT: - entry_id: "entry0" +// YAML-NEXT: instructions: +// YAML-NEXT: - timestep: 3 +// YAML-NEXT: operations: // YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 5 // YAML-NEXT: operations: +// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$96" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 7 +// YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_PREDICATE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$4" +// YAML-NEXT: - operand: "$96" // YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$5" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "2" +// YAML-NEXT: - column: 1 +// YAML-NEXT: row: 2 +// YAML-NEXT: core_id: "13" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 +// YAML-NEXT: - timestep: 3 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#1" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$8" +// YAML-NEXT: - operand: "$104" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 1 +// YAML-NEXT: - timestep: 4 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$8" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$8" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 2 +// YAML-NEXT: - timestep: 5 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$8" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$105" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$104" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 6 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_PREDICATE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$104" +// YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 3 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "3" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: // YAML-NEXT: - timestep: 8 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "RETURN" +// YAML-NEXT: - opcode: "GRANT_PREDICATE" // YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$105" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$104" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: - column: 0 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "4" +// YAML-NEXT: row: 3 +// YAML-NEXT: core_id: "18" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 5 +// YAML-NEXT: - timestep: 0 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: - opcode: "CONSTANT" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "#1" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "5" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: // YAML-NEXT: - timestep: 2 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: - opcode: "CONSTANT" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "#0.000000" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$144" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 +// YAML-NEXT: - timestep: 3 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ICMP" +// YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "$144" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$22" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$21" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "NOT" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$20" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$144" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 +// YAML-NEXT: - timestep: 4 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" +// YAML-NEXT: - opcode: "ADD" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$21" +// YAML-NEXT: - operand: "$144" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 +// YAML-NEXT: - timestep: 6 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$22" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 7 +// YAML-NEXT: operations: // YAML-NEXT: - opcode: "CTRL_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$20" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "6" +// YAML-NEXT: - column: 1 +// YAML-NEXT: row: 3 +// YAML-NEXT: core_id: "19" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 +// YAML-NEXT: - timestep: 2 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ADD" +// YAML-NEXT: - opcode: "CONSTANT" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "#3.000000" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "$152" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 3 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$25" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 4 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$152" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 5 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "FADD" +// YAML-NEXT: - opcode: "ICMP" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$26" +// YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "$153" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 6 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_PREDICATE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$25" +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "$153" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" // YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 7 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_PREDICATE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$26" +// YAML-NEXT: - operand: "$152" // YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 9 +// YAML-NEXT: operations: // YAML-NEXT: - opcode: "CTRL_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "$153" // YAML-NEXT: color: "RED" +// YAML-NEXT: - column: 2 +// YAML-NEXT: row: 3 +// YAML-NEXT: core_id: "20" +// YAML-NEXT: entries: +// YAML-NEXT: - entry_id: "entry0" +// YAML-NEXT: instructions: // YAML-NEXT: - timestep: 8 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: - opcode: "RETURN" // YAML-NEXT: src_operands: // YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 3 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "7" +// YAML-NEXT: - column: 0 +// YAML-NEXT: row: 4 +// YAML-NEXT: core_id: "24" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 +// YAML-NEXT: - timestep: 1 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$28" +// YAML-NEXT: - operand: "$192" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 +// YAML-NEXT: - timestep: 2 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" +// YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$28" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "$192" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "9" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 5 +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 4 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: - timestep: 9 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "CTRL_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "$192" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "10" +// YAML-NEXT: - column: 1 +// YAML-NEXT: row: 4 +// YAML-NEXT: core_id: "25" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: // YAML-NEXT: - timestep: 3 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$40" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$40" +// YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 +// YAML-NEXT: - timestep: 5 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: - opcode: "FADD" // YAML-NEXT: src_operands: // YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$200" +// YAML-NEXT: color: "RED" // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 9 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: // YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$41" +// YAML-NEXT: - operand: "$201" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 3 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "11" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 2 +// YAML-NEXT: - timestep: 6 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" +// YAML-NEXT: - opcode: "NOT" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0.000000" +// YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "SOUTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 3 -// YAML-NEXT: core_id: "14" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 2 +// YAML-NEXT: - timestep: 8 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" +// YAML-NEXT: - opcode: "GRANT_PREDICATE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#3.000000" +// YAML-NEXT: - operand: "$200" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$201" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" +// YAML-NEXT: - operand: "WEST" // YAML-NEXT: color: "RED" -// ASM-LABEL: PE(0,0): -// ASM: { -// ASM: CONSTANT, [#0] -> [EAST, RED] -// ASM: } (t=0) -// ASM: { -// ASM: CONSTANT, [#10] -> [EAST, RED] -// ASM: } (t=1) -// ASM: { -// ASM: DATA_MOV, [EAST, RED] -> [NORTH, RED] -// ASM: } (t=4) -// ASM-LABEL: PE(1,0): +// ASM-LABEL: PE(0,1): // ASM: { -// ASM: GRANT_ONCE, [WEST, RED] -> [NORTH, RED] +// ASM: GRANT_ONCE, [EAST, RED] -> [$48] // ASM: } (t=1) // ASM: { -// ASM: GRANT_ONCE, [WEST, RED] -> [$4] +// ASM: PHI, [NORTH, RED], [$48] -> [NORTH, RED] // ASM: } (t=2) -// ASM: { -// ASM: PHI, [$5], [$4] -> [NORTH, RED], [$4] -// ASM: DATA_MOV, [EAST, RED] -> [WEST, RED] -// ASM: } (t=3) -// ASM: { -// ASM: GRANT_PREDICATE, [$4], [NORTH, RED] -> [$5] -// ASM: } (t=5) -// ASM-LABEL: PE(2,0): +// ASM-LABEL: PE(1,1): // ASM: { -// ASM: CONSTANT, [#1] -> [$8] +// ASM: CONSTANT, [#0] -> [WEST, RED] // ASM: } (t=0) // ASM: { -// ASM: GRANT_ONCE, [$8] -> [$8] +// ASM: CONSTANT, [#10] -> [$56] // ASM: } (t=1) // ASM: { -// ASM: PHI, [NORTH, RED], [$8] -> [NORTH, RED], [WEST, RED] +// ASM: GRANT_ONCE, [$56] -> [$56] // ASM: } (t=2) - -// ASM-LABEL: PE(3,0): // ASM: { -// ASM: RETURN, [NORTH, RED] -// ASM: } (t=8) - -// ASM-LABEL: PE(0,1): +// ASM: PHI, [NORTH, RED], [$56] -> [NORTH, RED] +// ASM: } (t=3) // ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [EAST, RED] -// ASM: } (t=5) +// ASM: CTRL_MOV, [SOUTH, RED] -> [$57] +// ASM: } (t=7) -// ASM-LABEL: PE(1,1): -// ASM: { -// ASM: PHI, [EAST, RED], [SOUTH, RED] -> [EAST, RED] -// ASM: } (t=2) +// ASM-LABEL: PE(0,2): // ASM: { -// ASM: ICMP, [EAST, RED], [SOUTH, RED] -> [EAST, RED], [NORTH, RED], [$22], [$21], [SOUTH, RED], [$20] -// ASM: } (t=4) +// ASM: DATA_MOV, [SOUTH, RED] -> [NORTH, RED] +// ASM: } (t=3) // ASM: { -// ASM: NOT, [$20] -> [EAST, RED] +// ASM: DATA_MOV, [SOUTH, RED] -> [$96] // ASM: } (t=5) // ASM: { -// ASM: GRANT_PREDICATE, [WEST, RED], [$21] -> [EAST, RED] -// ASM: DATA_MOV, [SOUTH, RED] -> [$20] -// ASM: } (t=6) -// ASM: { -// ASM: GRANT_PREDICATE, [$20], [$22] -> [EAST, RED] -// ASM: CTRL_MOV, [WEST, RED] -> [$20] +// ASM: GRANT_PREDICATE, [$96], [NORTH, RED] -> [SOUTH, RED] // ASM: } (t=7) -// ASM-LABEL: PE(2,1): +// ASM-LABEL: PE(1,2): // ASM: { -// ASM: ADD, [WEST, RED], [SOUTH, RED] -> [WEST, RED], [$25] +// ASM: DATA_MOV, [NORTH, RED] -> [$104] // ASM: } (t=3) // ASM: { -// ASM: PHI, [$24], [EAST, RED] -> [$24] +// ASM: DATA_MOV, [SOUTH, RED] -> [NORTH, RED] // ASM: } (t=4) // ASM: { -// ASM: FADD, [$24], [NORTH, RED] -> [$26], [EAST, RED] -// ASM: DATA_MOV, [EAST, RED] -> [$24] +// ASM: DATA_MOV, [SOUTH, RED] -> [$105] +// ASM: DATA_MOV, [SOUTH, RED] -> [$104] // ASM: } (t=5) // ASM: { -// ASM: GRANT_PREDICATE, [$25], [$24] -> [WEST, RED] -// ASM: DATA_MOV, [WEST, RED] -> [EAST, RED] +// ASM: GRANT_PREDICATE, [$104], [NORTH, RED] -> [SOUTH, RED] // ASM: } (t=6) // ASM: { -// ASM: GRANT_PREDICATE, [$26], [NORTH, RED] -> [$24] -// ASM: CTRL_MOV, [WEST, RED] -> [SOUTH, RED] -// ASM: } (t=7) -// ASM: { -// ASM: CTRL_MOV, [WEST, RED] -> [NORTH, RED] +// ASM: GRANT_PREDICATE, [$105], [$104] -> [NORTH, RED] // ASM: } (t=8) -// ASM-LABEL: PE(3,1): +// ASM-LABEL: PE(0,3): +// ASM: { +// ASM: CONSTANT, [#1] -> [NORTH, RED] +// ASM: } (t=0) // ASM: { -// ASM: GRANT_ONCE, [NORTH, RED] -> [WEST, RED] +// ASM: CONSTANT, [#0.000000] -> [$144] +// ASM: } (t=2) +// ASM: { +// ASM: GRANT_ONCE, [$144] -> [NORTH, RED] +// ASM: DATA_MOV, [SOUTH, RED] -> [$144] // ASM: } (t=3) // ASM: { -// ASM: DATA_MOV, [EAST, RED] -> [$28] +// ASM: ADD, [SOUTH, RED], [$144] -> [EAST, RED], [SOUTH, RED] +// ASM: } (t=4) +// ASM: { +// ASM: DATA_MOV, [EAST, RED] -> [SOUTH, RED] // ASM: } (t=6) // ASM: { -// ASM: GRANT_PREDICATE, [$28], [WEST, RED] -> [SOUTH, RED] +// ASM: CTRL_MOV, [EAST, RED] -> [NORTH, RED] // ASM: } (t=7) -// ASM-LABEL: PE(1,2): +// ASM-LABEL: PE(1,3): // ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [EAST, RED] -// ASM: DATA_MOV, [EAST, RED] -> [SOUTH, RED] -// ASM: } (t=5) - -// ASM-LABEL: PE(2,2): +// ASM: CONSTANT, [#3.000000] -> [$152] +// ASM: } (t=2) // ASM: { -// ASM: GRANT_ONCE, [NORTH, RED] -> [$40] +// ASM: GRANT_ONCE, [$152] -> [$152] // ASM: } (t=3) // ASM: { -// ASM: PHI, [SOUTH, RED], [$40] -> [SOUTH, RED], [WEST, RED] +// ASM: PHI, [SOUTH, RED], [$152] -> [NORTH, RED], [SOUTH, RED] +// ASM: DATA_MOV, [SOUTH, RED] -> [$152] // ASM: } (t=4) // ASM: { -// ASM: DATA_MOV, [WEST, RED] -> [SOUTH, RED] +// ASM: ICMP, [WEST, RED], [SOUTH, RED] -> [WEST, RED], [NORTH, RED], [SOUTH, RED], [$153] +// ASM: } (t=5) +// ASM: { +// ASM: GRANT_PREDICATE, [$152], [$153] -> [WEST, RED] +// ASM: DATA_MOV, [SOUTH, RED] -> [$152] // ASM: } (t=6) // ASM: { -// ASM: CTRL_MOV, [NORTH, RED] -> [$41] +// ASM: GRANT_PREDICATE, [$152], [NORTH, RED] -> [EAST, RED] +// ASM: } (t=7) +// ASM: { +// ASM: CTRL_MOV, [NORTH, RED] -> [$153] // ASM: } (t=9) -// ASM-LABEL: PE(3,2): +// ASM-LABEL: PE(2,3): // ASM: { -// ASM: CONSTANT, [#0.000000] -> [SOUTH, RED] -// ASM: } (t=2) +// ASM: RETURN, [WEST, RED] +// ASM: } (t=8) -// ASM-LABEL: PE(2,3): +// ASM-LABEL: PE(0,4): // ASM: { -// ASM: CONSTANT, [#3.000000] -> [SOUTH, RED] +// ASM: GRANT_ONCE, [SOUTH, RED] -> [$192] +// ASM: } (t=1) +// ASM: { +// ASM: PHI, [SOUTH, RED], [$192] -> [SOUTH, RED], [EAST, RED] // ASM: } (t=2) +// ASM: { +// ASM: PHI, [EAST, RED], [SOUTH, RED] -> [EAST, RED] +// ASM: } (t=4) +// ASM: { +// ASM: CTRL_MOV, [WEST, RED] -> [$192] +// ASM: } (t=9) - - +// ASM-LABEL: PE(1,4): +// ASM: { +// ASM: DATA_MOV, [WEST, RED] -> [SOUTH, RED] +// ASM: } (t=3) +// ASM: { +// ASM: FADD, [WEST, RED], [SOUTH, RED] -> [$200], [SOUTH, RED] +// ASM: DATA_MOV, [NORTH, RED] -> [$201] +// ASM: } (t=5) +// ASM: { +// ASM: NOT, [SOUTH, RED] -> [SOUTH, RED] +// ASM: } (t=6) +// ASM: { +// ASM: GRANT_PREDICATE, [$200], [$201] -> [WEST, RED] +// ASM: } (t=8) diff --git a/test/controflow_fuse/simple_loop/simple_loop.mlir b/test/controflow_fuse/simple_loop/simple_loop.mlir index 7a686758..cbcdd22d 100644 --- a/test/controflow_fuse/simple_loop/simple_loop.mlir +++ b/test/controflow_fuse/simple_loop/simple_loop.mlir @@ -208,60 +208,60 @@ module attributes {} { // FUSE-NEXT: "neura.return"() : () -> () // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 2 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// FUSE-MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %2 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %3 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %4 = "neura.grant_once"() <{constant_value = 1 : i32}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %5 = "neura.grant_once"() <{constant_value = 2 : i32}> {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %6 = "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 -// FUSE-MAPPING-NEXT: %7 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 36 : i32, resource = "register", time_step = 0 : i32}, {id = 36 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%6) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 0 : i32}, {id = 31 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %10 = "neura.data_mov"(%3) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 0 : i32}, {id = 37 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %11 = "neura.data_mov"(%2) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 0 : i32}, {id = 38 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %8, start = %9, end = %10, step = %11) {iterationType = "increment", mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data +// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// FUSE-MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 3 : i32}]} : () -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 1 : i32}]} : () -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %2 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 3 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %3 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 0 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %4 = "neura.grant_once"() <{constant_value = 1 : i32}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 1 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %5 = "neura.grant_once"() <{constant_value = 2 : i32}> {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 4 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %6 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %7 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 1 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 0 : i32}, {id = 26 : i32, resource = "link", time_step = 1 : i32}, {id = 112 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%6) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 0 : i32}, {id = 64 : i32, resource = "link", time_step = 1 : i32}, {id = 69 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %10 = "neura.data_mov"(%3) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 0 : i32}, {id = 49 : i32, resource = "link", time_step = 1 : i32}, {id = 113 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %11 = "neura.data_mov"(%2) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 0 : i32}, {id = 114 : i32, resource = "register", time_step = 1 : i32}, {id = 114 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %8, start = %9, end = %10, step = %11) {iterationType = "increment", mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data // FUSE-MAPPING-NEXT: %12 = neura.reserve : !neura.data, i1> -// FUSE-MAPPING-NEXT: %13 = "neura.data_mov"(%1) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %14 = "neura.phi"(%12, %13) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %13 = "neura.data_mov"(%1) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %14 = "neura.phi"(%12, %13) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> // FUSE-MAPPING-NEXT: %15 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %16 = "neura.data_mov"(%4) {mapping_locs = [{id = 40 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %16 = "neura.data_mov"(%4) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data // FUSE-MAPPING-NEXT: %18 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %19 = "neura.data_mov"(%5) {mapping_locs = [{id = 44 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %19 = "neura.data_mov"(%5) {mapping_locs = [{id = 208 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data // FUSE-MAPPING-NEXT: %21 = neura.reserve : !neura.data, i1> -// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%0) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 1 : i32}, {id = 20 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%valid) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %26 = neura.grant_predicate %24, %25 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %27 = "neura.data_mov"(%20) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 2 : i32}, {id = 40 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %28 = "neura.data_mov"(%valid) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 2 : i32}, {id = 41 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %29 = neura.grant_predicate %27, %28 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %30 = "neura.data_mov"(%17) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 37 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %31 = "neura.data_mov"(%valid) {mapping_locs = [{id = 38 : i32, resource = "register", time_step = 2 : i32}, {id = 38 : i32, resource = "register", time_step = 3 : i32}, {id = 38 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %32 = neura.grant_predicate %30, %31 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %33 = "neura.data_mov"(%14) {mapping_locs = [{id = 3 : i32, resource = "link", time_step = 4 : i32}, {id = 8 : i32, resource = "register", time_step = 5 : i32}, {id = 8 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %34 = "neura.data_mov"(%valid) {mapping_locs = [{id = 30 : i32, resource = "link", time_step = 2 : i32}, {id = 41 : i32, resource = "link", time_step = 3 : i32}, {id = 45 : i32, resource = "link", time_step = 4 : i32}, {id = 33 : i32, resource = "link", time_step = 5 : i32}, {id = 19 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %35 = neura.grant_predicate %33, %34 {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %36 = "neura.data_mov"(%26) {mapping_locs = [{id = 13 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %37 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 2 : i32}, {id = 25 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %38 = neura.load_indexed %36[%37 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : !neura.data -// FUSE-MAPPING-NEXT: %39 = "neura.data_mov"(%38) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}, {id = 20 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %40 = "neura.data_mov"(%29) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 29 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %41 = "neura.mul"(%39, %40) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %42 = "neura.data_mov"(%41) {mapping_locs = [{id = 14 : i32, resource = "link", time_step = 6 : i32}, {id = 20 : i32, resource = "link", time_step = 7 : i32}, {id = 34 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %43 = "neura.data_mov"(%32) {mapping_locs = [{id = 30 : i32, resource = "link", time_step = 5 : i32}, {id = 41 : i32, resource = "link", time_step = 6 : i32}, {id = 56 : i32, resource = "register", time_step = 7 : i32}, {id = 56 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %44 = "neura.add"(%42, %43) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 9 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %45 = "neura.data_mov"(%44) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 9 : i32}, {id = 42 : i32, resource = "link", time_step = 10 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %46 = "neura.data_mov"(%35) {mapping_locs = [{id = 7 : i32, resource = "link", time_step = 7 : i32}, {id = 17 : i32, resource = "link", time_step = 8 : i32}, {id = 16 : i32, resource = "link", time_step = 9 : i32}, {id = 36 : i32, resource = "register", time_step = 10 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %47 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 39 : i32, resource = "register", time_step = 2 : i32}, {id = 39 : i32, resource = "register", time_step = 3 : i32}, {id = 39 : i32, resource = "register", time_step = 4 : i32}, {id = 39 : i32, resource = "register", time_step = 5 : i32}, {id = 39 : i32, resource = "register", time_step = 6 : i32}, {id = 39 : i32, resource = "register", time_step = 7 : i32}, {id = 39 : i32, resource = "register", time_step = 8 : i32}, {id = 39 : i32, resource = "register", time_step = 9 : i32}, {id = 39 : i32, resource = "register", time_step = 10 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: neura.store_indexed %45 to %46[%47 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 11 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %26 -> %21 {mapping_locs = [{id = 15 : i32, resource = "link", time_step = 3 : i32}, {id = 4 : i32, resource = "register", time_step = 4 : i32}]} : !neura.data, i1> !neura.data, i1> -// FUSE-MAPPING-NEXT: neura.ctrl_mov %29 -> %18 {mapping_locs = [{id = 32 : i32, resource = "link", time_step = 4 : i32}, {id = 45 : i32, resource = "register", time_step = 5 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %32 -> %15 {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 5 : i32}, {id = 41 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %35 -> %12 {mapping_locs = [{id = 5 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data, i1> !neura.data, i1> -// FUSE-MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 3 : i32}]} : () -> () +// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%0) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 1 : i32}, {id = 120 : i32, resource = "register", time_step = 2 : i32}, {id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%valid) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %26 = neura.grant_predicate %24, %25 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %27 = "neura.data_mov"(%20) {mapping_locs = [{id = 91 : i32, resource = "link", time_step = 2 : i32}, {id = 69 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %28 = "neura.data_mov"(%valid) {mapping_locs = [{id = 112 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %29 = neura.grant_predicate %27, %28 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// FUSE-MAPPING-NEXT: %30 = "neura.data_mov"(%17) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 72 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %31 = "neura.data_mov"(%valid) {mapping_locs = [{id = 47 : i32, resource = "link", time_step = 3 : i32}, {id = 24 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %32 = neura.grant_predicate %30, %31 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// FUSE-MAPPING-NEXT: %33 = "neura.data_mov"(%14) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 4 : i32}, {id = 64 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %34 = "neura.data_mov"(%valid) {mapping_locs = [{id = 114 : i32, resource = "register", time_step = 3 : i32}, {id = 47 : i32, resource = "link", time_step = 4 : i32}, {id = 65 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %35 = neura.grant_predicate %33, %34 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %36 = "neura.data_mov"(%26) {mapping_locs = [{id = 49 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %37 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 113 : i32, resource = "register", time_step = 3 : i32}, {id = 113 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %38 = neura.load_indexed %36[%37 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data +// FUSE-MAPPING-NEXT: %39 = "neura.data_mov"(%38) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %40 = "neura.data_mov"(%29) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 4 : i32}, {id = 104 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %41 = "neura.mul"(%39, %40) {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %42 = "neura.data_mov"(%41) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %43 = "neura.data_mov"(%32) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 23 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %44 = "neura.add"(%42, %43) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %45 = "neura.data_mov"(%44) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %46 = "neura.data_mov"(%35) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 6 : i32}, {id = 5 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// FUSE-MAPPING-NEXT: %47 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 3 : i32}, {id = 43 : i32, resource = "link", time_step = 4 : i32}, {id = 21 : i32, resource = "link", time_step = 5 : i32}, {id = 8 : i32, resource = "register", time_step = 6 : i32}, {id = 8 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: neura.store_indexed %45 to %46[%47 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 0 : i32}]} : !neura.data +// FUSE-MAPPING-NEXT: neura.ctrl_mov %26 -> %21 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data, i1> !neura.data, i1> +// FUSE-MAPPING-NEXT: neura.ctrl_mov %29 -> %18 {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 4 : i32}, {id = 70 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data +// FUSE-MAPPING-NEXT: neura.ctrl_mov %32 -> %15 {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 5 : i32}, {id = 81 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data +// FUSE-MAPPING-NEXT: neura.ctrl_mov %35 -> %12 {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 6 : i32}, {id = 64 : i32, resource = "register", time_step = 7 : i32}]} : !neura.data, i1> !neura.data, i1> +// FUSE-MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : () -> () // FUSE-MAPPING-NEXT: } \ No newline at end of file diff --git a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir index c7a11ee2..f738e641 100644 --- a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir +++ b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir @@ -59,7 +59,7 @@ // RUN: --fuse-loop-control \ // RUN: --fold-constant \ // RUN: --insert-data-mov \ -// RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized=4,5" | FileCheck %s -check-prefix=FUSE-MAPPING +// RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" | FileCheck %s -check-prefix=FUSE-MAPPING module attributes {} { func.func @_Z10simpleloopv() -> i32 attributes {llvm.linkage = #llvm.linkage} { @@ -166,34 +166,34 @@ module attributes {} { // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// FUSE-MAPPING-NEXT: %0 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 1 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %1 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 12 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %2 = "neura.grant_once"() <{constant_value = 0 : i32}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 0 : i32}, {id = 32 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 1 : i32, resource = "link", time_step = 0 : i32}, {id = 12 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %7 = "neura.data_mov"(%1) {mapping_locs = [{id = 39 : i32, resource = "link", time_step = 0 : i32}, {id = 33 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%0) {mapping_locs = [{id = 12 : i32, resource = "link", time_step = 0 : i32}, {id = 34 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 32 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 5 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// FUSE-MAPPING-NEXT: %0 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %1 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %2 = "neura.grant_once"() <{constant_value = 0 : i32}> {mapping_locs = [{id = 17 : i32, resource = "tile", time_step = 1 : i32, x = 5 : i32, y = 2 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 32 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 5 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data +// FUSE-MAPPING-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 0 : i32}, {id = 160 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 111 : i32, resource = "link", time_step = 0 : i32}, {id = 91 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %7 = "neura.data_mov"(%1) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 0 : i32}, {id = 64 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%0) {mapping_locs = [{id = 64 : i32, resource = "link", time_step = 0 : i32}, {id = 161 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 3 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data +// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 160 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data // FUSE-MAPPING-NEXT: %11 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 1 : i32}, {id = 4 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 2 : i32}, {id = 29 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 2 : i32, resource = "link", time_step = 3 : i32}, {id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 3 : i32}, {id = 11 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 5 : i32, x = 0 : i32, y = 0 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %20 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 2 : i32}, {id = 16 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %21 = "neura.cast"(%20) <{cast_type = "i64_to_i32"}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%16) {mapping_locs = [{id = 20 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %24 = "neura.add"(%22, %23) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %24 -> %11 {mapping_locs = [{id = 15 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%19) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 5 : i32}, {id = 4 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data) -> () +// FUSE-MAPPING-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 57 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 2 : i32}, {id = 52 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 68 : i32, resource = "link", time_step = 2 : i32}, {id = 168 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// FUSE-MAPPING-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 2 : i32}, {id = 176 : i32, resource = "register", time_step = 3 : i32}, {id = 176 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 68 : i32, resource = "link", time_step = 3 : i32}, {id = 72 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// FUSE-MAPPING-NEXT: %20 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %21 = "neura.cast"(%20) <{cast_type = "i64_to_i32"}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%16) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 120 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: %24 = "neura.add"(%22, %23) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: neura.ctrl_mov %24 -> %11 {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 5 : i32}, {id = 128 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data +// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%19) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// FUSE-MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data) -> () // FUSE-MAPPING-NEXT: } \ No newline at end of file diff --git a/test/mapping_quality/branch_for.mlir b/test/mapping_quality/branch_for.mlir index e4eb55bf..e63517e6 100644 --- a/test/mapping_quality/branch_for.mlir +++ b/test/mapping_quality/branch_for.mlir @@ -7,12 +7,14 @@ // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ // RUN: --lower-llvm-to-neura \ +// RUN: --fold-constant \ // RUN: --canonicalize-live-in \ // RUN: | FileCheck %s -check-prefix=CANONICALIZE // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ // RUN: --lower-llvm-to-neura \ +// RUN: --fold-constant \ // RUN: --canonicalize-live-in \ // RUN: --leverage-predicated-value \ // RUN: --transform-ctrl-to-data-flow \ @@ -21,6 +23,7 @@ // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ // RUN: --lower-llvm-to-neura \ +// RUN: --fold-constant \ // RUN: --canonicalize-live-in \ // RUN: --leverage-predicated-value \ // RUN: --transform-ctrl-to-data-flow \ @@ -30,6 +33,7 @@ // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ // RUN: --lower-llvm-to-neura \ +// RUN: --fold-constant \ // RUN: --canonicalize-live-in \ // RUN: --leverage-predicated-value \ // RUN: --transform-ctrl-to-data-flow \ @@ -40,13 +44,15 @@ // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ // RUN: --lower-llvm-to-neura \ +// RUN: --fold-constant \ // RUN: --canonicalize-live-in \ // RUN: --leverage-predicated-value \ // RUN: --transform-ctrl-to-data-flow \ // RUN: --fold-constant \ // RUN: --insert-data-mov \ // RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" \ -// RUN: | FileCheck %s -check-prefix=MAPPING +// RUN: -o %t-mapping.mlir +// RUN: FileCheck %s --input-file=%t-mapping.mlir -check-prefix=MAPPING // RUN: mlir-neura-opt %s \ // RUN: --assign-accelerator \ @@ -57,7 +63,7 @@ // RUN: --fold-constant \ // RUN: --insert-data-mov \ // RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" \ -// RUN: --generate-code +// RUN: --generate-code // RUN: FileCheck %s --input-file=tmp-generated-instructions.yaml -check-prefix=YAML // RUN: FileCheck %s --input-file=tmp-generated-instructions.asm --check-prefix=ASM @@ -96,251 +102,153 @@ func.func @loop_test() -> f32 { // CHECK-NEXT: "neura.return"(%10) : (!neura.data) -> () // CHECK-NEXT: } -// CANONICALIZE: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { -// CANONICALIZE-NEXT: %0 = "neura.constant"() <{predicate = true, value = 10 : i64}> : () -> i64 -// CANONICALIZE-NEXT: %1 = "neura.constant"() <{predicate = true, value = 0 : i64}> : () -> i64 -// CANONICALIZE-NEXT: %2 = "neura.constant"() <{predicate = true, value = 1 : i64}> : () -> i64 -// CANONICALIZE-NEXT: %3 = "neura.constant"() <{predicate = true, value = 3.000000e+00 : f32}> : () -> f32 -// CANONICALIZE-NEXT: %4 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> : () -> f32 -// CANONICALIZE-NEXT: neura.br %1, %4, %3, %2, %0 : i64, f32, f32, i64, i64 to ^bb1 -// CANONICALIZE-NEXT: ^bb1(%5: i64, %6: f32, %7: f32, %8: i64, %9: i64): // 2 preds: ^bb0, ^bb1 -// CANONICALIZE-NEXT: %10 = "neura.fadd"(%6, %7) : (f32, f32) -> f32 -// CANONICALIZE-NEXT: %11 = "neura.add"(%5, %8) : (i64, i64) -> i64 -// CANONICALIZE-NEXT: %12 = "neura.icmp"(%11, %9) <{cmpType = "slt"}> : (i64, i64) -> i1 -// CANONICALIZE-NEXT: neura.cond_br %12 : i1 then %11, %10, %7, %8, %9 : i64, f32, f32, i64, i64 to ^bb1 else %10 : f32 to ^bb2 -// CANONICALIZE-NEXT: ^bb2(%13: f32): // pred: ^bb1 -// CANONICALIZE-NEXT: "neura.return"(%13) : (f32) -> () +// CANONICALIZE: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { +// CANONICALIZE-NEXT: %0 = "neura.constant"() <{predicate = true, value = 0 : i64}> : () -> i64 +// CANONICALIZE-NEXT: %1 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> : () -> f32 +// CANONICALIZE-NEXT: neura.br %0, %1 : i64, f32 to ^bb1 +// CANONICALIZE-NEXT: ^bb1(%2: i64, %3: f32): // 2 preds: ^bb0, ^bb1 +// CANONICALIZE-NEXT: %4 = "neura.fadd"(%3) {rhs_const_value = 3.000000e+00 : f32} : (f32) -> f32 +// CANONICALIZE-NEXT: %5 = "neura.add"(%2) {rhs_const_value = 1 : i64} : (i64) -> i64 +// CANONICALIZE-NEXT: %6 = "neura.icmp"(%5) <{cmpType = "slt"}> {rhs_const_value = 10 : i64} : (i64) -> i1 +// CANONICALIZE-NEXT: neura.cond_br %6 : i1 then %5, %4 : i64, f32 to ^bb1 else %4 : f32 to ^bb2 +// CANONICALIZE-NEXT: ^bb2(%7: f32): // pred: ^bb1 +// CANONICALIZE-NEXT: "neura.return"(%7) : (f32) -> () // CANONICALIZE-NEXT: } // CTRL2DATA: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { -// CTRL2DATA-NEXT: %0 = "neura.constant"() <{predicate = true, value = 10 : i64}> : () -> !neura.data +// CTRL2DATA-NEXT: %0 = "neura.constant"() <{predicate = true, value = 0 : i64}> : () -> !neura.data // CTRL2DATA-NEXT: %1 = "neura.grant_once"(%0) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %2 = "neura.constant"() <{predicate = true, value = 0 : i64}> : () -> !neura.data -// CTRL2DATA-NEXT: %3 = "neura.grant_once"(%2) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %4 = "neura.constant"() <{predicate = true, value = 1 : i64}> : () -> !neura.data -// CTRL2DATA-NEXT: %5 = "neura.grant_once"(%4) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %6 = "neura.constant"() <{predicate = true, value = 3.000000e+00 : f32}> : () -> !neura.data -// CTRL2DATA-NEXT: %7 = "neura.grant_once"(%6) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %8 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> : () -> !neura.data -// CTRL2DATA-NEXT: %9 = "neura.grant_once"(%8) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %10 = neura.reserve : !neura.data -// CTRL2DATA-NEXT: %11 = "neura.phi"(%10, %1) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %12 = neura.reserve : !neura.data -// CTRL2DATA-NEXT: %13 = "neura.phi"(%12, %5) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %14 = neura.reserve : !neura.data -// CTRL2DATA-NEXT: %15 = "neura.phi"(%14, %7) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %16 = neura.reserve : !neura.data -// CTRL2DATA-NEXT: %17 = "neura.phi"(%16, %9) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %18 = neura.reserve : !neura.data -// CTRL2DATA-NEXT: %19 = "neura.phi"(%18, %3) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %20 = "neura.fadd"(%17, %15) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %21 = "neura.add"(%19, %13) : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %22 = "neura.icmp"(%21, %11) <{cmpType = "slt"}> : (!neura.data, !neura.data) -> !neura.data -// CTRL2DATA-NEXT: %23 = neura.grant_predicate %21, %22 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: neura.ctrl_mov %23 -> %18 : !neura.data !neura.data -// CTRL2DATA-NEXT: %24 = neura.grant_predicate %20, %22 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: neura.ctrl_mov %24 -> %16 : !neura.data !neura.data -// CTRL2DATA-NEXT: %25 = neura.grant_predicate %15, %22 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: neura.ctrl_mov %25 -> %14 : !neura.data !neura.data -// CTRL2DATA-NEXT: %26 = neura.grant_predicate %13, %22 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: neura.ctrl_mov %26 -> %12 : !neura.data !neura.data -// CTRL2DATA-NEXT: %27 = neura.grant_predicate %11, %22 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: neura.ctrl_mov %27 -> %10 : !neura.data !neura.data -// CTRL2DATA-NEXT: %28 = "neura.not"(%22) : (!neura.data) -> !neura.data -// CTRL2DATA-NEXT: %29 = neura.grant_predicate %20, %28 : !neura.data, !neura.data -> !neura.data -// CTRL2DATA-NEXT: "neura.return"(%29) : (!neura.data) -> () +// CTRL2DATA-NEXT: %2 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> : () -> !neura.data +// CTRL2DATA-NEXT: %3 = "neura.grant_once"(%2) : (!neura.data) -> !neura.data +// CTRL2DATA-NEXT: %4 = neura.reserve : !neura.data +// CTRL2DATA-NEXT: %5 = "neura.phi"(%4, %3) : (!neura.data, !neura.data) -> !neura.data +// CTRL2DATA-NEXT: %6 = neura.reserve : !neura.data +// CTRL2DATA-NEXT: %7 = "neura.phi"(%6, %1) : (!neura.data, !neura.data) -> !neura.data +// CTRL2DATA-NEXT: %8 = "neura.fadd"(%5) {rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data +// CTRL2DATA-NEXT: %9 = "neura.add"(%7) {rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// CTRL2DATA-NEXT: %10 = "neura.icmp"(%9) <{cmpType = "slt"}> {rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data +// CTRL2DATA-NEXT: %11 = neura.grant_predicate %9, %10 : !neura.data, !neura.data -> !neura.data +// CTRL2DATA-NEXT: neura.ctrl_mov %11 -> %6 : !neura.data !neura.data +// CTRL2DATA-NEXT: %12 = neura.grant_predicate %8, %10 : !neura.data, !neura.data -> !neura.data +// CTRL2DATA-NEXT: neura.ctrl_mov %12 -> %4 : !neura.data !neura.data +// CTRL2DATA-NEXT: %13 = "neura.not"(%10) : (!neura.data) -> !neura.data +// CTRL2DATA-NEXT: %14 = neura.grant_predicate %8, %13 : !neura.data, !neura.data -> !neura.data +// CTRL2DATA-NEXT: "neura.return"(%14) : (!neura.data) -> () // CTRL2DATA-NEXT: } -// FUSE: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { -// FUSE-NEXT: %0 = "neura.grant_once"() <{constant_value = 10 : i64}> : () -> !neura.data -// FUSE-NEXT: %1 = "neura.grant_once"() <{constant_value = 0 : i64}> : () -> !neura.data -// FUSE-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> : () -> !neura.data -// FUSE-NEXT: %3 = "neura.grant_once"() <{constant_value = 3.000000e+00 : f32}> : () -> !neura.data -// FUSE-NEXT: %4 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> : () -> !neura.data -// FUSE-NEXT: %5 = neura.reserve : !neura.data -// FUSE-NEXT: %6 = "neura.phi"(%5, %0) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %7 = neura.reserve : !neura.data -// FUSE-NEXT: %8 = "neura.phi"(%7, %2) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %9 = neura.reserve : !neura.data -// FUSE-NEXT: %10 = "neura.phi"(%9, %3) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %11 = neura.reserve : !neura.data -// FUSE-NEXT: %12 = "neura.phi"(%11, %4) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %13 = neura.reserve : !neura.data -// FUSE-NEXT: %14 = "neura.phi"(%13, %1) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %15 = "neura.fadd"(%12, %10) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %16 = "neura.add"(%14, %8) : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %17 = "neura.icmp"(%16, %6) <{cmpType = "slt"}> : (!neura.data, !neura.data) -> !neura.data -// FUSE-NEXT: %18 = neura.grant_predicate %16, %17 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: neura.ctrl_mov %18 -> %13 : !neura.data !neura.data -// FUSE-NEXT: %19 = neura.grant_predicate %15, %17 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: neura.ctrl_mov %19 -> %11 : !neura.data !neura.data -// FUSE-NEXT: %20 = neura.grant_predicate %10, %17 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: neura.ctrl_mov %20 -> %9 : !neura.data !neura.data -// FUSE-NEXT: %21 = neura.grant_predicate %8, %17 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: neura.ctrl_mov %21 -> %7 : !neura.data !neura.data -// FUSE-NEXT: %22 = neura.grant_predicate %6, %17 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: neura.ctrl_mov %22 -> %5 : !neura.data !neura.data -// FUSE-NEXT: %23 = "neura.not"(%17) : (!neura.data) -> !neura.data -// FUSE-NEXT: %24 = neura.grant_predicate %15, %23 : !neura.data, !neura.data -> !neura.data -// FUSE-NEXT: "neura.return"(%24) : (!neura.data) -> () -// FUSE-NEXT: } +// FUSE: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { +// FUSE-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> : () -> !neura.data +// FUSE-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> : () -> !neura.data +// FUSE-NEXT: %2 = neura.reserve : !neura.data +// FUSE-NEXT: %3 = "neura.phi"(%2, %1) : (!neura.data, !neura.data) -> !neura.data +// FUSE-NEXT: %4 = neura.reserve : !neura.data +// FUSE-NEXT: %5 = "neura.phi"(%4, %0) : (!neura.data, !neura.data) -> !neura.data +// FUSE-NEXT: %6 = "neura.fadd"(%3) {rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data +// FUSE-NEXT: %7 = "neura.add"(%5) {rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// FUSE-NEXT: %8 = "neura.icmp"(%7) <{cmpType = "slt"}> {rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data +// FUSE-NEXT: %9 = neura.grant_predicate %7, %8 : !neura.data, !neura.data -> !neura.data +// FUSE-NEXT: neura.ctrl_mov %9 -> %4 : !neura.data !neura.data +// FUSE-NEXT: %10 = neura.grant_predicate %6, %8 : !neura.data, !neura.data -> !neura.data +// FUSE-NEXT: neura.ctrl_mov %10 -> %2 : !neura.data !neura.data +// FUSE-NEXT: %11 = "neura.not"(%8) : (!neura.data) -> !neura.data +// FUSE-NEXT: %12 = neura.grant_predicate %6, %11 : !neura.data, !neura.data -> !neura.data +// FUSE-NEXT: "neura.return"(%12) : (!neura.data) -> () +// FUSE-NEXT: } // MOV: func.func @loop_test() -> f32 attributes {accelerator = "neura"} { -// MOV-NEXT: %0 = "neura.grant_once"() <{constant_value = 10 : i64}> : () -> !neura.data -// MOV-NEXT: %1 = "neura.grant_once"() <{constant_value = 0 : i64}> : () -> !neura.data -// MOV-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> : () -> !neura.data -// MOV-NEXT: %3 = "neura.grant_once"() <{constant_value = 3.000000e+00 : f32}> : () -> !neura.data -// MOV-NEXT: %4 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> : () -> !neura.data +// MOV-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> : () -> !neura.data +// MOV-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> : () -> !neura.data +// MOV-NEXT: %2 = neura.reserve : !neura.data +// MOV-NEXT: %3 = "neura.data_mov"(%1) : (!neura.data) -> !neura.data +// MOV-NEXT: %4 = "neura.phi"(%2, %3) : (!neura.data, !neura.data) -> !neura.data // MOV-NEXT: %5 = neura.reserve : !neura.data // MOV-NEXT: %6 = "neura.data_mov"(%0) : (!neura.data) -> !neura.data // MOV-NEXT: %7 = "neura.phi"(%5, %6) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %8 = neura.reserve : !neura.data -// MOV-NEXT: %9 = "neura.data_mov"(%2) : (!neura.data) -> !neura.data -// MOV-NEXT: %10 = "neura.phi"(%8, %9) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %11 = neura.reserve : !neura.data -// MOV-NEXT: %12 = "neura.data_mov"(%3) : (!neura.data) -> !neura.data -// MOV-NEXT: %13 = "neura.phi"(%11, %12) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %14 = neura.reserve : !neura.data -// MOV-NEXT: %15 = "neura.data_mov"(%4) : (!neura.data) -> !neura.data -// MOV-NEXT: %16 = "neura.phi"(%14, %15) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %17 = neura.reserve : !neura.data -// MOV-NEXT: %18 = "neura.data_mov"(%1) : (!neura.data) -> !neura.data -// MOV-NEXT: %19 = "neura.phi"(%17, %18) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %20 = "neura.data_mov"(%16) : (!neura.data) -> !neura.data -// MOV-NEXT: %21 = "neura.data_mov"(%13) : (!neura.data) -> !neura.data -// MOV-NEXT: %22 = "neura.fadd"(%20, %21) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %23 = "neura.data_mov"(%19) : (!neura.data) -> !neura.data -// MOV-NEXT: %24 = "neura.data_mov"(%10) : (!neura.data) -> !neura.data -// MOV-NEXT: %25 = "neura.add"(%23, %24) : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %26 = "neura.data_mov"(%25) : (!neura.data) -> !neura.data -// MOV-NEXT: %27 = "neura.data_mov"(%7) : (!neura.data) -> !neura.data -// MOV-NEXT: %28 = "neura.icmp"(%26, %27) <{cmpType = "slt"}> : (!neura.data, !neura.data) -> !neura.data -// MOV-NEXT: %29 = "neura.data_mov"(%25) : (!neura.data) -> !neura.data -// MOV-NEXT: %30 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %31 = neura.grant_predicate %29, %30 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: neura.ctrl_mov %31 -> %17 : !neura.data !neura.data -// MOV-NEXT: %32 = "neura.data_mov"(%22) : (!neura.data) -> !neura.data -// MOV-NEXT: %33 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %34 = neura.grant_predicate %32, %33 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: neura.ctrl_mov %34 -> %14 : !neura.data !neura.data -// MOV-NEXT: %35 = "neura.data_mov"(%13) : (!neura.data) -> !neura.data -// MOV-NEXT: %36 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %37 = neura.grant_predicate %35, %36 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: neura.ctrl_mov %37 -> %11 : !neura.data !neura.data -// MOV-NEXT: %38 = "neura.data_mov"(%10) : (!neura.data) -> !neura.data -// MOV-NEXT: %39 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %40 = neura.grant_predicate %38, %39 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: neura.ctrl_mov %40 -> %8 : !neura.data !neura.data -// MOV-NEXT: %41 = "neura.data_mov"(%7) : (!neura.data) -> !neura.data -// MOV-NEXT: %42 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %43 = neura.grant_predicate %41, %42 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: neura.ctrl_mov %43 -> %5 : !neura.data !neura.data -// MOV-NEXT: %44 = "neura.data_mov"(%28) : (!neura.data) -> !neura.data -// MOV-NEXT: %45 = "neura.not"(%44) : (!neura.data) -> !neura.data -// MOV-NEXT: %46 = "neura.data_mov"(%22) : (!neura.data) -> !neura.data -// MOV-NEXT: %47 = "neura.data_mov"(%45) : (!neura.data) -> !neura.data -// MOV-NEXT: %48 = neura.grant_predicate %46, %47 : !neura.data, !neura.data -> !neura.data -// MOV-NEXT: %49 = "neura.data_mov"(%48) : (!neura.data) -> !neura.data -// MOV-NEXT: "neura.return"(%49) : (!neura.data) -> () +// MOV-NEXT: %8 = "neura.data_mov"(%4) : (!neura.data) -> !neura.data +// MOV-NEXT: %9 = "neura.fadd"(%8) {rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data +// MOV-NEXT: %10 = "neura.data_mov"(%7) : (!neura.data) -> !neura.data +// MOV-NEXT: %11 = "neura.add"(%10) {rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// MOV-NEXT: %12 = "neura.data_mov"(%11) : (!neura.data) -> !neura.data +// MOV-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data +// MOV-NEXT: %14 = "neura.data_mov"(%11) : (!neura.data) -> !neura.data +// MOV-NEXT: %15 = "neura.data_mov"(%13) : (!neura.data) -> !neura.data +// MOV-NEXT: %16 = neura.grant_predicate %14, %15 : !neura.data, !neura.data -> !neura.data +// MOV-NEXT: neura.ctrl_mov %16 -> %5 : !neura.data !neura.data +// MOV-NEXT: %17 = "neura.data_mov"(%9) : (!neura.data) -> !neura.data +// MOV-NEXT: %18 = "neura.data_mov"(%13) : (!neura.data) -> !neura.data +// MOV-NEXT: %19 = neura.grant_predicate %17, %18 : !neura.data, !neura.data -> !neura.data +// MOV-NEXT: neura.ctrl_mov %19 -> %2 : !neura.data !neura.data +// MOV-NEXT: %20 = "neura.data_mov"(%13) : (!neura.data) -> !neura.data +// MOV-NEXT: %21 = "neura.not"(%20) : (!neura.data) -> !neura.data +// MOV-NEXT: %22 = "neura.data_mov"(%9) : (!neura.data) -> !neura.data +// MOV-NEXT: %23 = "neura.data_mov"(%21) : (!neura.data) -> !neura.data +// MOV-NEXT: %24 = neura.grant_predicate %22, %23 : !neura.data, !neura.data -> !neura.data +// MOV-NEXT: %25 = "neura.data_mov"(%24) : (!neura.data) -> !neura.data +// MOV-NEXT: "neura.return"(%25) : (!neura.data) -> () // MOV-NEXT: } - -// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 5 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 2 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 10 : i64}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 2 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %1 = "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: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %3 = "neura.grant_once"() <{constant_value = 3.000000e+00 : f32}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %4 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 2 : i32}]} : () -> !neura.data + +// MAPPING: module { +// MAPPING-NEXT: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 3 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 1 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %2 = neura.reserve : !neura.data +// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 4 : 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 = 24 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %8 = neura.reserve : !neura.data -// MAPPING-NEXT: %9 = "neura.data_mov"(%2) {mapping_locs = [{id = 36 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.phi"(%8, %9) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %11 = neura.reserve : !neura.data -// MAPPING-NEXT: %12 = "neura.data_mov"(%3) {mapping_locs = [{id = 10 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %14 = neura.reserve : !neura.data -// MAPPING-NEXT: %15 = "neura.data_mov"(%4) {mapping_locs = [{id = 32 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = "neura.phi"(%14, %15) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %17 = neura.reserve : !neura.data -// MAPPING-NEXT: %18 = "neura.data_mov"(%1) {mapping_locs = [{id = 44 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %19 = "neura.phi"(%17, %18) {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: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %21 = "neura.data_mov"(%13) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %22 = "neura.fadd"(%20, %21) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 35 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %24 = "neura.data_mov"(%10) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %25 = "neura.add"(%23, %24) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %26 = "neura.data_mov"(%25) {mapping_locs = [{id = 40 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %27 = "neura.data_mov"(%7) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %28 = "neura.icmp"(%26, %27) <{cmpType = "slt"}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %29 = "neura.data_mov"(%25) {mapping_locs = [{id = 32 : i32, resource = "link", time_step = 2 : i32}, {id = 44 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %30 = "neura.data_mov"(%28) {mapping_locs = [{id = 32 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %31 = neura.grant_predicate %29, %30 {mapping_locs = [{id = 11 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %31 -> %17 {mapping_locs = [{id = 45 : i32, resource = "register", time_step = 4 : i32}, {id = 45 : i32, resource = "register", time_step = 5 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %32 = "neura.data_mov"(%22) {mapping_locs = [{id = 30 : i32, resource = "link", time_step = 4 : i32}, {id = 52 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %33 = "neura.data_mov"(%28) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 3 : i32}, {id = 43 : i32, resource = "link", time_step = 4 : i32}, {id = 53 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %34 = neura.grant_predicate %32, %33 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %34 -> %14 {mapping_locs = [{id = 40 : i32, resource = "link", time_step = 6 : i32}, {id = 39 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %35 = "neura.data_mov"(%13) {mapping_locs = [{id = 20 : i32, resource = "register", time_step = 3 : i32}, {id = 20 : i32, resource = "register", time_step = 4 : i32}, {id = 20 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %36 = "neura.data_mov"(%28) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 29 : i32, resource = "link", time_step = 4 : i32}, {id = 21 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %37 = neura.grant_predicate %35, %36 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %37 -> %11 {mapping_locs = [{id = 20 : i32, resource = "register", time_step = 6 : i32}, {id = 20 : i32, resource = "register", time_step = 7 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %38 = "neura.data_mov"(%10) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 1 : i32}, {id = 14 : i32, resource = "link", time_step = 2 : i32}, {id = 24 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %39 = "neura.data_mov"(%28) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %40 = neura.grant_predicate %38, %39 {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %40 -> %8 {mapping_locs = [{id = 17 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %41 = "neura.data_mov"(%7) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 2 : i32}, {id = 14 : i32, resource = "link", time_step = 3 : i32}, {id = 20 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %42 = "neura.data_mov"(%28) {mapping_locs = [{id = 41 : i32, resource = "register", time_step = 3 : i32}, {id = 41 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %43 = neura.grant_predicate %41, %42 {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 %43 -> %5 {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 5 : i32}, {id = 36 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %44 = "neura.data_mov"(%28) {mapping_locs = [{id = 40 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %45 = "neura.not"(%44) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %46 = "neura.data_mov"(%22) {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 4 : i32}, {id = 34 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %47 = "neura.data_mov"(%45) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 4 : i32}, {id = 56 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %48 = neura.grant_predicate %46, %47 {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: %49 = "neura.data_mov"(%48) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: "neura.return"(%49) {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data) -> () +// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %8 = "neura.data_mov"(%4) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %9 = "neura.fadd"(%8) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 1 : i32}], rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%7) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %11 = "neura.add"(%10) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 3 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 3 : i32}], rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %14 = "neura.data_mov"(%11) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 2 : i32}, {id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %15 = "neura.data_mov"(%13) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %16 -> %5 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %17 = "neura.data_mov"(%9) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 4 : i32}, {id = 128 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %18 = "neura.data_mov"(%13) {mapping_locs = [{id = 72 : i32, resource = "link", time_step = 3 : i32}, {id = 77 : i32, resource = "link", time_step = 4 : i32}, {id = 129 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %19 -> %2 {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 6 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %20 = "neura.data_mov"(%13) {mapping_locs = [{id = 71 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %21 = "neura.not"(%20) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %22 = "neura.data_mov"(%9) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 4 : i32}, {id = 47 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %24 = neura.grant_predicate %22, %23 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %25 = "neura.data_mov"(%24) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> () // MAPPING-NEXT: } +// MAPPING-NEXT: } // YAML: array_config: -// YAML-NEXT: columns: 4 -// YAML-NEXT: rows: 4 +// YAML-NEXT: columns: 6 +// YAML-NEXT: rows: 6 // YAML-NEXT: cores: -// YAML-NEXT: - column: 0 +// YAML-NEXT: - column: 1 // YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "4" +// YAML-NEXT: core_id: "7" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 2 +// YAML-NEXT: - timestep: 0 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#3.000000" +// YAML-NEXT: - operand: "#0" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "$56" // YAML-NEXT: color: "RED" -// ASM-LABEL: PE(0,1): -// ASM: { -// ASM: GRANT_ONCE, [#3.000000] -> [EAST, RED] -// ASM: } (t=2) - -// ASM-LABEL: PE(1,1): -// ASM: { -// ASM: DATA_MOV, [NORTH, RED] -> [EAST, RED] -// ASM: } (t=2) -// ASM: { -// ASM: PHI, [$20], [WEST, RED] -> [NORTH, RED], [$20] -// ASM: DATA_MOV, [NORTH, RED] -> [EAST, RED] -// ASM: } (t=3) -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [$21] -// ASM: CTRL_MOV, [EAST, RED] -> [NORTH, RED] -// ASM: } (t=5) -// ASM: { -// ASM: GRANT_PREDICATE, [$20], [$21] -> [$20] -// ASM: } (t=6) \ No newline at end of file +// ASM: PE(1,1): +// ASM-NEXT: { +// ASM-NEXT: GRANT_ONCE, [#0] -> [$56] +// ASM-NEXT: } (t=0) +// ASM-NEXT: { +// ASM-NEXT: GRANT_ONCE, [#10] -> [EAST, RED] +// ASM-NEXT: } (t=1) +// ASM-NEXT: { +// ASM-NEXT: PHI, [NORTH, RED], [$56] -> [NORTH, RED] +// ASM-NEXT: } (t=2) diff --git a/test/mapping_quality/tiny_loop.mlir b/test/mapping_quality/tiny_loop.mlir index 92c23f48..e35e7ba0 100644 --- a/test/mapping_quality/tiny_loop.mlir +++ b/test/mapping_quality/tiny_loop.mlir @@ -38,7 +38,7 @@ // RUN: --fuse-loop-control \ // RUN: --fold-constant \ // RUN: --insert-data-mov \ -// RUN: --map-to-accelerator="mapping-strategy=heuristic mapping-mode=spatial-temporal backtrack-config=customized=3,4" \ +// RUN: --map-to-accelerator="mapping-strategy=heuristic mapping-mode=spatial-temporal backtrack-config=customized=3,7" \ // RUN: | FileCheck %s -check-prefix=SPATIAL-TEMPORAL module { @@ -73,62 +73,62 @@ module { // CHECK-NEXT: "neura.return"(%15) : (i64) -> () // CHECK-NEXT: } -// SPATIAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 7 : i32, mapping_mode = "spatial-only", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// SPATIAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 0 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 0 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %3 = "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 -// SPATIAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 33 : i32, resource = "link", time_step = 0 : i32}, {id = 24 : i32, resource = "register", time_step = 1 : i32}, {id = 24 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 36 : i32, resource = "link", time_step = 0 : i32}, {id = 21 : i32, resource = "link", time_step = 1 : i32}, {id = 25 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 7 : i32, resource = "link", time_step = 0 : i32}, {id = 26 : i32, resource = "register", time_step = 1 : i32}, {id = 26 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 0 : i32}, {id = 4 : i32, resource = "link", time_step = 1 : i32}, {id = 14 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// SPATIAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 3 : i32}, {id = 22 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-only", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// SPATIAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data +// SPATIAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data +// SPATIAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 27 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 4 : i32}]} : () -> !neura.data +// SPATIAL-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data +// SPATIAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data +// SPATIAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 0 : i32}, {id = 47 : i32, resource = "link", time_step = 1 : i32}, {id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 0 : i32}, {id = 43 : i32, resource = "link", time_step = 1 : i32}, {id = 20 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 0 : i32}, {id = 3 : i32, resource = "link", time_step = 1 : i32}, {id = 7 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 0 : i32}, {id = 51 : i32, resource = "link", time_step = 1 : i32}, {id = 27 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data +// SPATIAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data // SPATIAL-NEXT: %11 = neura.reserve : !neura.data -// SPATIAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 2 : i32, resource = "link", time_step = 1 : i32}, {id = 1 : i32, resource = "link", time_step = 2 : i32}, {id = 10 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 16 : i32, resource = "link", time_step = 4 : i32}, {id = 36 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 3 : i32}, {id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 37 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 13 : i32, resource = "link", time_step = 4 : i32}, {id = 12 : i32, resource = "link", time_step = 5 : i32}, {id = 24 : i32, resource = "link", time_step = 6 : i32}, {id = 28 : i32, resource = "link", time_step = 7 : i32}, {id = 34 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 9 : i32, resource = "link", time_step = 5 : i32}, {id = 23 : i32, resource = "link", time_step = 6 : i32}, {id = 37 : i32, resource = "link", time_step = 7 : i32}, {id = 46 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 9 : i32, x = 2 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 30 : i32, resource = "link", time_step = 6 : i32}, {id = 52 : i32, resource = "register", time_step = 7 : i32}, {id = 52 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 6 : i32}, {id = 26 : i32, resource = "link", time_step = 7 : i32}, {id = 38 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 9 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 9 : i32}, {id = 29 : i32, resource = "link", time_step = 10 : i32}]} : !neura.data !neura.data -// SPATIAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 44 : i32, resource = "link", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 10 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data) -> () +// SPATIAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 94 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// SPATIAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 97 : i32, resource = "link", time_step = 2 : i32}, {id = 95 : i32, resource = "link", time_step = 3 : i32}, {id = 73 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 3 : i32}, {id = 30 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// SPATIAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 2 : i32}, {id = 77 : i32, resource = "link", time_step = 3 : i32}, {id = 55 : i32, resource = "link", time_step = 4 : i32}, {id = 31 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 4 : i32}, {id = 10 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// SPATIAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 5 : i32}, {id = 56 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 5 : i32}, {id = 72 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// SPATIAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data +// SPATIAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data) -> () // SPATIAL-NEXT: } -// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// SPATIAL-TEMPORAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 1 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 12 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 0 : i32}, {id = 32 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 1 : i32, resource = "link", time_step = 0 : i32}, {id = 12 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 12 : i32, resource = "link", time_step = 0 : i32}, {id = 33 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 39 : i32, resource = "link", time_step = 0 : i32}, {id = 34 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// SPATIAL-TEMPORAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 2 : i32}, {id = 16 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// SPATIAL-TEMPORAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 23 : i32, resource = "tile", time_step = 0 : i32, x = 5 : i32, y = 3 : i32}]} : () -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 1 : i32}]} : () -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 4 : i32}]} : () -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 0 : i32}, {id = 26 : i32, resource = "link", time_step = 1 : i32}, {id = 48 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 0 : i32}, {id = 86 : i32, resource = "link", time_step = 1 : i32}, {id = 91 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 0 : i32}, {id = 48 : i32, resource = "link", time_step = 1 : i32}, {id = 160 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 79 : i32, resource = "link", time_step = 0 : i32}, {id = 75 : i32, resource = "link", time_step = 1 : i32}, {id = 71 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 3 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data +// SPATIAL-TEMPORAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 70 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data // SPATIAL-TEMPORAL-NEXT: %11 = neura.reserve : !neura.data -// SPATIAL-TEMPORAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 1 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 12 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 32 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 11 : i32, resource = "link", time_step = 2 : i32}, {id = 0 : i32, resource = "register", time_step = 3 : i32}, {id = 0 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 11 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 5 : i32, x = 0 : i32, y = 0 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 32 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 33 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data !neura.data -// SPATIAL-TEMPORAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data) -> () +// SPATIAL-TEMPORAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 1 : i32}, {id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 26 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 3 : i32}, {id = 65 : i32, resource = "register", time_step = 4 : i32}, {id = 26 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 91 : i32, resource = "link", time_step = 4 : i32}, {id = 69 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 112 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 113 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 47 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data +// SPATIAL-TEMPORAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// SPATIAL-TEMPORAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> () // SPATIAL-TEMPORAL-NEXT: } \ No newline at end of file diff --git a/test/neura/ctrl/branch_for.mlir b/test/neura/ctrl/branch_for.mlir index f0e26134..cf663b92 100644 --- a/test/neura/ctrl/branch_for.mlir +++ b/test/neura/ctrl/branch_for.mlir @@ -187,72 +187,75 @@ func.func @loop_test() -> f32 { // MOV-NEXT: "neura.return"(%25) : (!neura.data) -> () // MOV-NEXT: } -// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 0 : i32}]} : () -> !neura.data +// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data // MAPPING-NEXT: %2 = neura.reserve : !neura.data -// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 0 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 0 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 0 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 3 : i32, x = 1 : 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 = 0 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 0 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %8 = "neura.data_mov"(%4) {mapping_locs = [{id = 0 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %9 = "neura.fadd"(%8) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 0 : i32}], rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%7) {mapping_locs = [{id = 4 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %11 = "neura.add"(%10) {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 0 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 4 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 0 : i32}], rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.data_mov"(%11) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 2 : i32}, {id = 20 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %15 = "neura.data_mov"(%13) {mapping_locs = [{id = 4 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 5 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %16 -> %5 {mapping_locs = [{id = 15 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %17 = "neura.data_mov"(%9) {mapping_locs = [{id = 2 : i32, resource = "link", time_step = 4 : i32}, {id = 1 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %18 = "neura.data_mov"(%13) {mapping_locs = [{id = 2 : i32, resource = "link", time_step = 3 : i32}, {id = 1 : i32, resource = "link", time_step = 4 : i32}, {id = 16 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 4 : i32, resource = "tile", time_step = 6 : i32, x = 0 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %19 -> %2 {mapping_locs = [{id = 11 : i32, resource = "link", time_step = 6 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %20 = "neura.data_mov"(%13) {mapping_locs = [{id = 3 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %21 = "neura.not"(%20) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %22 = "neura.data_mov"(%9) {mapping_locs = [{id = 3 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 8 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %24 = neura.grant_predicate %22, %23 {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 0 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %25 = "neura.data_mov"(%24) {mapping_locs = [{id = 8 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %6 = "neura.data_mov"(%0) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %8 = "neura.data_mov"(%4) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %9 = "neura.fadd"(%8) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}], rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%7) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %11 = "neura.add"(%10) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 1 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}], rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %14 = "neura.data_mov"(%11) {mapping_locs = [{id = 65 : i32, resource = "register", time_step = 2 : i32}, {id = 65 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %15 = "neura.data_mov"(%13) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %16 -> %5 {mapping_locs = [{id = 23 : i32, resource = "link", time_step = 4 : i32}, {id = 57 : i32, resource = "register", time_step = 5 : i32}, {id = 57 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %17 = "neura.data_mov"(%9) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 4 : i32}, {id = 20 : i32, resource = "link", time_step = 5 : i32}, {id = 64 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %18 = "neura.data_mov"(%13) {mapping_locs = [{id = 66 : i32, resource = "register", time_step = 3 : i32}, {id = 66 : i32, resource = "register", time_step = 4 : i32}, {id = 66 : i32, resource = "register", time_step = 5 : i32}, {id = 66 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %19 -> %2 {mapping_locs = [{id = 23 : i32, resource = "link", time_step = 7 : i32}, {id = 57 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %20 = "neura.data_mov"(%13) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %21 = "neura.not"(%20) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %22 = "neura.data_mov"(%9) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %24 = neura.grant_predicate %22, %23 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %25 = "neura.data_mov"(%24) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data // MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> () // MAPPING-NEXT: } // YAML: array_config: -// YAML-NEXT: columns: 4 -// YAML-NEXT: rows: 4 +// YAML-NEXT: columns: 6 +// YAML-NEXT: rows: 6 // YAML-NEXT: cores: -// YAML-NEXT: - column: 0 +// YAML-NEXT: - column: 2 // YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "0" +// YAML-NEXT: core_id: "2" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 +// YAML-NEXT: - timestep: 6 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: - opcode: "RETURN" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// ASM: PE(0,0): -// ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0] -> [EAST, RED] -// ASM-NEXT: } (t=0) -// ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0.000000] -> [$0] -// ASM-NEXT: } (t=2) -// ASM-NEXT: { -// ASM-NEXT: PHI, [NORTH, RED], [$0] -> [EAST, RED] -// ASM-NEXT: } (t=3) -// ASM-NEXT: { -// ASM-NEXT: DATA_MOV, [EAST, RED] -> [NORTH, RED] -// ASM-NEXT: } (t=4) -// ASM-NEXT: { -// ASM-NEXT: DATA_MOV, [EAST, RED] -> [NORTH, RED] -// ASM-NEXT: } (t=5) \ No newline at end of file +// ASM: PE(1,1): +// ASM-NEXT: { +// ASM-NEXT: GRANT_ONCE, [#0] -> [$56] +// ASM-NEXT: } (t=0) +// ASM-NEXT: { +// ASM-NEXT: PHI, [EAST, RED], [$56] -> [EAST, RED] +// ASM-NEXT: } (t=1) +// ASM-NEXT: { +// ASM-NEXT: GRANT_ONCE, [#0.000000] -> [$56] +// ASM-NEXT: } (t=2) +// ASM-NEXT: { +// ASM-NEXT: PHI, [EAST, RED], [$56] -> [$56] +// ASM-NEXT: } (t=3) +// ASM-NEXT: { +// ASM-NEXT: FADD, [$56] -> [EAST, RED] +// ASM-NEXT: } (t=4) +// ASM-NEXT: { +// ASM-NEXT: CTRL_MOV, [WEST, RED] -> [$57] +// ASM-NEXT: } (t=5) +// ASM-NEXT: { +// ASM-NEXT: CTRL_MOV, [WEST, RED] -> [$57] +// ASM-NEXT: } (t=8) From f4e783970c6a3322ec266f049703052408bbe28b Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Fri, 26 Sep 2025 14:34:08 +0800 Subject: [PATCH 3/6] add nested loop mapping test --- .../perfect_nested/perfect_nested.mlir | 128 +++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/test/controflow_fuse/perfect_nested/perfect_nested.mlir b/test/controflow_fuse/perfect_nested/perfect_nested.mlir index 1bb7acca..c3e8e2ef 100644 --- a/test/controflow_fuse/perfect_nested/perfect_nested.mlir +++ b/test/controflow_fuse/perfect_nested/perfect_nested.mlir @@ -28,6 +28,22 @@ // RUN: --transform-ctrl-to-data-flow \ // RUN: | FileCheck %s -check-prefix=CTRL2DATA +// RUN: mlir-neura-opt %t-llvm.mlir \ +// RUN: --assign-accelerator \ +// RUN: --lower-arith-to-neura \ +// RUN: --lower-memref-to-neura \ +// RUN: --lower-builtin-to-neura \ +// RUN: --lower-llvm-to-neura \ +// RUN: --canonicalize-cast \ +// RUN: --fold-constant \ +// RUN: --canonicalize-live-in \ +// RUN: --leverage-predicated-value \ +// RUN: --transform-ctrl-to-data-flow \ +// RUN: --fold-constant \ +// RUN: --insert-data-mov \ +// RUN: --map-to-accelerator="mapping-strategy=heuristic backtrack-config=customized" \ +// RUN: | FileCheck %s -check-prefix=MAPPING + module attributes {} { func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {llvm.linkage = #llvm.linkage} { affine.for %arg2 = 0 to 128 { @@ -173,4 +189,114 @@ module attributes {} { // CTRL2DATA-NEXT: neura.ctrl_mov %57 -> %12 : !neura.data, i1> !neura.data, i1> // CTRL2DATA-NEXT: neura.ctrl_mov %53 -> %10 : !neura.data !neura.data // CTRL2DATA-NEXT: "neura.return"() : () -> () -// CTRL2DATA-NEXT: } \ No newline at end of file +// CTRL2DATA-NEXT: } + + +// MAPPING: func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 10 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 8 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data, i1> +// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data, i1> +// MAPPING-NEXT: %2 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 0 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data +// MAPPING-NEXT: %3 = neura.reserve : !neura.data, i1> +// MAPPING-NEXT: %4 = "neura.data_mov"(%1) {mapping_locs = [{id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %5 = "neura.phi"(%3, %4) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %6 = neura.reserve : !neura.data, i1> +// MAPPING-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %8 = "neura.phi"(%6, %7) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %9 = neura.reserve : !neura.data +// MAPPING-NEXT: %10 = "neura.data_mov"(%2) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 0 : i32}, {id = 129 : i32, resource = "register", time_step = 1 : i32}, {id = 129 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %11 = "neura.phi"(%9, %10) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %12 = neura.reserve : !neura.data +// MAPPING-NEXT: %13 = "neura.data_mov"(%2) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %14 = "neura.phi"(%12, %13) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 1 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %15 = "neura.data_mov"(%14) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %16 = "neura.icmp"(%15) <{cmpType = "slt"}> {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 3 : i32}], rhs_const_value = 128 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %18 = "neura.data_mov"(%16) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 2 : i32}, {id = 176 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %20 = "neura.data_mov"(%8) {mapping_locs = [{id = 177 : i32, resource = "register", time_step = 3 : i32}, {id = 177 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 178 : i32, resource = "register", time_step = 2 : i32}, {id = 178 : i32, resource = "register", time_step = 3 : i32}, {id = 178 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %22 = neura.grant_predicate %20, %21 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %23 = "neura.data_mov"(%5) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %24 = "neura.data_mov"(%16) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 2 : i32}, {id = 168 : i32, resource = "register", time_step = 3 : i32}, {id = 168 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %25 = neura.grant_predicate %23, %24 {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %26 = "neura.data_mov"(%14) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 1 : i32}, {id = 128 : i32, resource = "register", time_step = 2 : i32}, {id = 128 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %27 = "neura.data_mov"(%16) {mapping_locs = [{id = 77 : i32, resource = "link", time_step = 2 : i32}, {id = 129 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %28 = neura.grant_predicate %26, %27 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %29 = neura.reserve : !neura.data +// MAPPING-NEXT: %30 = "neura.data_mov"(%28) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 4 : i32}, {id = 129 : i32, resource = "register", time_step = 5 : i32}, {id = 129 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %31 = "neura.phi"(%29, %30) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %32 = neura.reserve : !neura.data, i1> +// MAPPING-NEXT: %33 = "neura.data_mov"(%25) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %34 = "neura.phi"(%32, %33) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %35 = neura.reserve : !neura.data +// MAPPING-NEXT: %36 = "neura.data_mov"(%19) {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %37 = "neura.phi"(%35, %36) {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %38 = neura.reserve : !neura.data, i1> +// MAPPING-NEXT: %39 = "neura.data_mov"(%22) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %40 = "neura.phi"(%38, %39) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %41 = neura.reserve : !neura.data +// MAPPING-NEXT: %42 = "neura.data_mov"(%19) {mapping_locs = [{id = 77 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %43 = "neura.phi"(%41, %42) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data +// MAPPING-NEXT: %44 = "neura.data_mov"(%43) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %45 = "neura.icmp"(%44) <{cmpType = "slt"}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 2 : i32}], rhs_const_value = 128 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %46 = "neura.data_mov"(%40) {mapping_locs = [{id = 177 : i32, resource = "register", time_step = 6 : i32}, {id = 177 : i32, resource = "register", time_step = 7 : i32}, {id = 177 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %47 = "neura.data_mov"(%45) {mapping_locs = [{id = 130 : i32, resource = "register", time_step = 6 : i32}, {id = 56 : i32, resource = "link", time_step = 7 : i32}, {id = 176 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %48 = neura.grant_predicate %46, %47 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %49 = "neura.data_mov"(%37) {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 5 : i32}, {id = 176 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %50 = "neura.data_mov"(%45) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %51 = neura.grant_predicate %49, %50 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %52 = "neura.data_mov"(%43) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 5 : i32}, {id = 120 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %53 = "neura.data_mov"(%45) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %54 = neura.grant_predicate %52, %53 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %55 = "neura.data_mov"(%34) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 6 : i32}, {id = 120 : i32, resource = "register", time_step = 7 : i32}, {id = 120 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %56 = "neura.data_mov"(%45) {mapping_locs = [{id = 133 : i32, resource = "register", time_step = 6 : i32}, {id = 53 : i32, resource = "link", time_step = 7 : i32}, {id = 121 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %57 = neura.grant_predicate %55, %56 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 9 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %58 = "neura.data_mov"(%31) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 7 : i32}, {id = 129 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %59 = "neura.data_mov"(%45) {mapping_locs = [{id = 131 : i32, resource = "register", time_step = 6 : i32}, {id = 131 : i32, resource = "register", time_step = 7 : i32}, {id = 131 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %60 = neura.grant_predicate %58, %59 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %61 = "neura.data_mov"(%45) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 6 : i32}, {id = 128 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %62 = "neura.not"(%61) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 8 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %63 = "neura.data_mov"(%31) {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 7 : i32}, {id = 80 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %64 = "neura.data_mov"(%62) {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %65 = neura.grant_predicate %63, %64 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %66 = "neura.data_mov"(%37) {mapping_locs = [{id = 225 : i32, resource = "register", time_step = 5 : i32}, {id = 225 : i32, resource = "register", time_step = 6 : i32}, {id = 225 : i32, resource = "register", time_step = 7 : i32}, {id = 225 : i32, resource = "register", time_step = 8 : i32}, {id = 225 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %67 = "neura.data_mov"(%62) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 8 : i32}, {id = 78 : i32, resource = "link", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %68 = neura.grant_predicate %66, %67 {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 4 : i32}]} : !neura.data, !neura.data -> !neura.data +// MAPPING-NEXT: %69 = "neura.data_mov"(%40) {mapping_locs = [{id = 76 : i32, resource = "link", time_step = 6 : i32}, {id = 80 : i32, resource = "link", time_step = 7 : i32}, {id = 136 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %70 = "neura.data_mov"(%62) {mapping_locs = [{id = 54 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %71 = neura.grant_predicate %69, %70 {mapping_locs = [{id = 17 : i32, resource = "tile", time_step = 9 : i32, x = 5 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %72 = "neura.data_mov"(%34) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 6 : i32}, {id = 73 : i32, resource = "link", time_step = 7 : i32}, {id = 122 : i32, resource = "register", time_step = 8 : i32}, {id = 122 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %73 = "neura.data_mov"(%62) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 8 : i32}, {id = 120 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %74 = neura.grant_predicate %72, %73 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 10 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> +// MAPPING-NEXT: %75 = "neura.data_mov"(%48) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %76 = "neura.data_mov"(%51) {mapping_locs = [{id = 178 : i32, resource = "register", time_step = 7 : i32}, {id = 178 : i32, resource = "register", time_step = 8 : i32}, {id = 178 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %77 = "neura.data_mov"(%51) {mapping_locs = [{id = 180 : i32, resource = "register", time_step = 7 : i32}, {id = 180 : i32, resource = "register", time_step = 8 : i32}, {id = 180 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %78 = "neura.data_mov"(%51) {mapping_locs = [{id = 181 : i32, resource = "register", time_step = 7 : i32}, {id = 181 : i32, resource = "register", time_step = 8 : i32}, {id = 181 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %79 = "neura.data_mov"(%51) {mapping_locs = [{id = 182 : i32, resource = "register", time_step = 7 : i32}, {id = 182 : i32, resource = "register", time_step = 8 : i32}, {id = 182 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %80 = "neura.data_mov"(%51) {mapping_locs = [{id = 183 : i32, resource = "register", time_step = 7 : i32}, {id = 183 : i32, resource = "register", time_step = 8 : i32}, {id = 183 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %81 = "neura.data_mov"(%54) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 7 : i32}, {id = 72 : i32, resource = "link", time_step = 8 : i32}, {id = 177 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %82 = neura.load_indexed %75[%76, %77, %78, %79, %80, %81 : !neura.data, !neura.data, !neura.data, !neura.data, !neura.data, !neura.data] !neura.data, i1> {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data +// MAPPING-NEXT: %83 = "neura.data_mov"(%82) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 10 : i32}, {id = 168 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %84 = "neura.data_mov"(%57) {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 9 : i32}, {id = 52 : i32, resource = "link", time_step = 10 : i32}, {id = 170 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> +// MAPPING-NEXT: %85 = "neura.data_mov"(%51) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 7 : i32}, {id = 171 : i32, resource = "register", time_step = 8 : i32}, {id = 171 : i32, resource = "register", time_step = 9 : i32}, {id = 171 : i32, resource = "register", time_step = 10 : i32}, {id = 171 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %86 = "neura.data_mov"(%51) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 7 : i32}, {id = 75 : i32, resource = "link", time_step = 8 : i32}, {id = 172 : i32, resource = "register", time_step = 9 : i32}, {id = 172 : i32, resource = "register", time_step = 10 : i32}, {id = 172 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %87 = "neura.data_mov"(%60) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 9 : i32}, {id = 53 : i32, resource = "link", time_step = 10 : i32}, {id = 52 : i32, resource = "link", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %88 = "neura.data_mov"(%51) {mapping_locs = [{id = 179 : i32, resource = "register", time_step = 7 : i32}, {id = 179 : i32, resource = "register", time_step = 8 : i32}, {id = 75 : i32, resource = "link", time_step = 9 : i32}, {id = 173 : i32, resource = "register", time_step = 10 : i32}, {id = 173 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %89 = "neura.data_mov"(%51) {mapping_locs = [{id = 76 : i32, resource = "link", time_step = 7 : i32}, {id = 184 : i32, resource = "register", time_step = 8 : i32}, {id = 184 : i32, resource = "register", time_step = 9 : i32}, {id = 79 : i32, resource = "link", time_step = 10 : i32}, {id = 75 : i32, resource = "link", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %90 = "neura.data_mov"(%54) {mapping_locs = [{id = 122 : i32, resource = "register", time_step = 7 : i32}, {id = 52 : i32, resource = "link", time_step = 8 : i32}, {id = 174 : i32, resource = "register", time_step = 9 : i32}, {id = 174 : i32, resource = "register", time_step = 10 : i32}, {id = 174 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: neura.store_indexed %83 to %84[%85, %86, %87, %88, %89, %90 : !neura.data, !neura.data, !neura.data, !neura.data, !neura.data, !neura.data] !neura.data, i1> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 12 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data +// MAPPING-NEXT: %91 = "neura.data_mov"(%54) {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %92 = "neura.add"(%91) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 8 : i32, x = 3 : i32, y = 2 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %92 -> %41 {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 8 : i32}, {id = 131 : i32, resource = "register", time_step = 9 : i32}, {id = 131 : i32, resource = "register", time_step = 10 : i32}, {id = 131 : i32, resource = "register", time_step = 11 : i32}, {id = 131 : i32, resource = "register", time_step = 12 : i32}, {id = 131 : i32, resource = "register", time_step = 13 : i32}, {id = 131 : i32, resource = "register", time_step = 14 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: neura.ctrl_mov %48 -> %38 {mapping_locs = [{id = 179 : i32, resource = "register", time_step = 9 : i32}, {id = 179 : i32, resource = "register", time_step = 10 : i32}, {id = 179 : i32, resource = "register", time_step = 11 : i32}, {id = 179 : i32, resource = "register", time_step = 12 : i32}, {id = 179 : i32, resource = "register", time_step = 13 : i32}, {id = 179 : i32, resource = "register", time_step = 14 : i32}, {id = 179 : i32, resource = "register", time_step = 15 : i32}]} : !neura.data, i1> !neura.data, i1> +// MAPPING-NEXT: neura.ctrl_mov %51 -> %35 {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 7 : i32}, {id = 224 : i32, resource = "register", time_step = 8 : i32}, {id = 224 : i32, resource = "register", time_step = 9 : i32}, {id = 224 : i32, resource = "register", time_step = 10 : i32}, {id = 224 : i32, resource = "register", time_step = 11 : i32}, {id = 224 : i32, resource = "register", time_step = 12 : i32}, {id = 224 : i32, resource = "register", time_step = 13 : i32}, {id = 224 : i32, resource = "register", time_step = 14 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: neura.ctrl_mov %57 -> %32 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 9 : i32}, {id = 169 : i32, resource = "register", time_step = 10 : i32}, {id = 169 : i32, resource = "register", time_step = 11 : i32}, {id = 169 : i32, resource = "register", time_step = 12 : i32}, {id = 169 : i32, resource = "register", time_step = 13 : i32}, {id = 169 : i32, resource = "register", time_step = 14 : i32}, {id = 169 : i32, resource = "register", time_step = 15 : i32}]} : !neura.data, i1> !neura.data, i1> +// MAPPING-NEXT: neura.ctrl_mov %60 -> %29 {mapping_locs = [{id = 132 : i32, resource = "register", time_step = 9 : i32}, {id = 132 : i32, resource = "register", time_step = 10 : i32}, {id = 132 : i32, resource = "register", time_step = 11 : i32}, {id = 132 : i32, resource = "register", time_step = 12 : i32}, {id = 132 : i32, resource = "register", time_step = 13 : i32}, {id = 132 : i32, resource = "register", time_step = 14 : i32}, {id = 132 : i32, resource = "register", time_step = 15 : i32}, {id = 132 : i32, resource = "register", time_step = 16 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: %93 = "neura.data_mov"(%65) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data +// MAPPING-NEXT: %94 = "neura.add"(%93) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 1 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data +// MAPPING-NEXT: neura.ctrl_mov %94 -> %12 {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 10 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: neura.ctrl_mov %68 -> %9 {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 10 : i32}, {id = 77 : i32, resource = "link", time_step = 11 : i32}, {id = 130 : i32, resource = "register", time_step = 12 : i32}]} : !neura.data !neura.data +// MAPPING-NEXT: neura.ctrl_mov %71 -> %6 {mapping_locs = [{id = 57 : i32, resource = "link", time_step = 9 : i32}, {id = 56 : i32, resource = "link", time_step = 10 : i32}, {id = 177 : i32, resource = "register", time_step = 11 : i32}, {id = 177 : i32, resource = "register", time_step = 12 : i32}]} : !neura.data, i1> !neura.data, i1> +// MAPPING-NEXT: neura.ctrl_mov %74 -> %3 {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 10 : i32}, {id = 121 : i32, resource = "register", time_step = 11 : i32}, {id = 121 : i32, resource = "register", time_step = 12 : i32}, {id = 121 : i32, resource = "register", time_step = 13 : i32}]} : !neura.data, i1> !neura.data, i1> +// MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 3 : i32}]} : () -> () +// MAPPING-NEXT: } \ No newline at end of file From ef28a9836b91b147bebfa4a1434df3730779fdab Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Fri, 26 Sep 2025 23:18:13 +0800 Subject: [PATCH 4/6] refactor test, code in tryToRouteDataMov --- include/NeuraDialect/NeuraOps.td | 17 --- lib/NeuraDialect/Mapping/mapping_util.cpp | 73 ++++++------ .../perfect_nested/perfect_nested.mlir | 109 +----------------- .../simple_loop/simple_loop.mlir | 58 +--------- .../simple_loop_reduction.mlir | 32 +---- test/mapping_quality/branch_for.mlir | 32 +---- test/mapping_quality/tiny_loop.mlir | 58 +--------- test/neura/ctrl/branch_for.mlir | 107 ++++++++++------- 8 files changed, 109 insertions(+), 377 deletions(-) diff --git a/include/NeuraDialect/NeuraOps.td b/include/NeuraDialect/NeuraOps.td index 63fbd789..88513411 100644 --- a/include/NeuraDialect/NeuraOps.td +++ b/include/NeuraDialect/NeuraOps.td @@ -211,23 +211,6 @@ def Neura_CastOp : Op{ // let assemblyFormat = "$input type($input) `->` type($output) `,` $predicate attr-dict"; } - -// Defines an alloca operation for memory allocation. -def Neura_AllocaOp : Op { - let summary = "Memory allocation operation"; - let description = [{ - Allocates memory on the stack, similar to llvm.alloca. - Takes a predicated size value and returns a pointer to the allocated memory. - - Example: - %ptr = neura.alloca %size : !neura.data -> !llvm.ptr - }]; - - let arguments = (ins AnyType:$size); - let results = (outs AnyType:$result); - let assemblyFormat = "$size attr-dict `:` type($size) `->` type($result)"; -} - // ---------------------------------------------------- // Defines vector operations. diff --git a/lib/NeuraDialect/Mapping/mapping_util.cpp b/lib/NeuraDialect/Mapping/mapping_util.cpp index 32747e6f..d19f952c 100644 --- a/lib/NeuraDialect/Mapping/mapping_util.cpp +++ b/lib/NeuraDialect/Mapping/mapping_util.cpp @@ -417,47 +417,45 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, MappingLoc dst_loc, bool is_backward_move, const MappingState &state, std::vector &path_out) { - // Clears the output path. - path_out.clear(); + assert(path_out.empty() && "Output path should be empty"); // Gets the source tile and destination tile. Tile *src_tile = dyn_cast(src_loc.resource); Tile *dst_tile = dyn_cast(dst_loc.resource); - if (!src_tile || !dst_tile) { - llvm::outs() << "[tryRouteDataMove] Source or destination is not a tile\n "; - return false; - } + assert(src_tile && dst_tile && + "Source and destination locations must be tiles"); // Calculates the deadline time step (adds II for backward moves). - int deadline_step = dst_loc.time_step; + int exclusive_deadline_step = dst_loc.time_step; if (is_backward_move) { - deadline_step += state.getII(); + exclusive_deadline_step += state.getII(); } llvm::outs() << "[tryRouteDataMove] Routing from Tile#" << src_tile->getId() << " @t=" << src_loc.time_step << " to Tile#" - << dst_tile->getId() << " @t=" << deadline_step << "\n"; + << dst_tile->getId() << " @t=" << exclusive_deadline_step + << "\n"; // Special case: source tile and destination tile are the same. if (src_tile == dst_tile) { // Uses register as routing resource within the same tile. int start_time = src_loc.time_step; - int end_time = deadline_step; + int exclusive_end_time = exclusive_deadline_step; // Finds an available register to store the data. Register *available_reg = - getAvailableRegister(state, src_tile, start_time, end_time); + getAvailableRegister(state, src_tile, start_time, exclusive_end_time); if (!available_reg) { llvm::outs() << "[tryRouteDataMove] Cannot find available register on Tile#" << src_tile->getId() << " for time range: t=" << start_time - << " to t=" << end_time << "\n"; + << " to t=" << exclusive_end_time << "\n"; return false; } // Builds path: uses register to store data for the specified time period. - for (int t = start_time; t < end_time; ++t) { + for (int t = start_time; t < exclusive_end_time; ++t) { path_out.push_back({available_reg, t}); } @@ -491,15 +489,16 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, // Checks if destination tile is reached with appropriate timing. if (current_state.current_tile == dst_tile) { - if (current_state.current_time <= deadline_step) { - if (current_state.current_time == deadline_step) { + if (current_state.current_time <= exclusive_deadline_step) { + if (current_state.current_time == exclusive_deadline_step) { // Arrives exactly at deadline, no additional register needed. path_out = current_state.path; return true; } else { // Arrives early, needs register on destination tile to wait. - Register *wait_reg = getAvailableRegister( - state, dst_tile, current_state.current_time, deadline_step); + Register *wait_reg = + getAvailableRegister(state, dst_tile, current_state.current_time, + exclusive_deadline_step); if (!wait_reg) { llvm::outs() << "[tryRouteDataMove] Cannot find available waiting" "register on destination Tile#" @@ -509,7 +508,8 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, // Builds complete path. path_out = current_state.path; - for (int t = current_state.current_time; t < deadline_step; ++t) { + for (int t = current_state.current_time; t < exclusive_deadline_step; + ++t) { path_out.push_back({wait_reg, t}); } return true; @@ -521,27 +521,13 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, } // Skips if current time already exceeds deadline. - if (current_state.current_time >= deadline_step) { + if (current_state.current_time >= exclusive_deadline_step) { continue; } // Explores two routing options from current tile: - // Option 1: Uses register on current tile to wait one time step. - Register *wait_register = getAvailableRegister( - state, current_state.current_tile, current_state.current_time, - current_state.current_time + 1); - if (wait_register) { - int next_time = current_state.current_time + 1; - if (visited.insert({current_state.current_tile, next_time}).second) { - std::vector new_path = current_state.path; - new_path.push_back({wait_register, current_state.current_time}); - - search_queue.push({current_state.current_tile, next_time, new_path}); - } - } - - // Option 2: Moves to adjacent tile through link. + // Option 1: Moves to adjacent tile through link. for (Link *out_link : current_state.current_tile->getOutLinks()) { MappingLoc link_loc = {out_link, current_state.current_time}; @@ -561,13 +547,28 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, search_queue.push({next_tile, next_time, new_path}); } } + + // Option 2: Uses register on current tile to wait one time step. + Register *wait_register = getAvailableRegister( + state, current_state.current_tile, current_state.current_time, + current_state.current_time + 1); + if (wait_register) { + int next_time = current_state.current_time + 1; + // Checks if this (tile, time) combination has been visited. + if (visited.insert({current_state.current_tile, next_time}).second) { + std::vector new_path = current_state.path; + new_path.push_back({wait_register, current_state.current_time}); + + search_queue.push({current_state.current_tile, next_time, new_path}); + } + } } // Search failed. llvm::outs() << "[tryRouteDataMove] Cannot find routing path from Tile#" << src_tile->getId() << " @t=" << src_loc.time_step - << " to Tile#" << dst_tile->getId() << " @t=" << deadline_step - << "\n"; + << " to Tile#" << dst_tile->getId() + << " @t=" << exclusive_deadline_step << "\n"; return false; } diff --git a/test/controflow_fuse/perfect_nested/perfect_nested.mlir b/test/controflow_fuse/perfect_nested/perfect_nested.mlir index c3e8e2ef..0255ebe1 100644 --- a/test/controflow_fuse/perfect_nested/perfect_nested.mlir +++ b/test/controflow_fuse/perfect_nested/perfect_nested.mlir @@ -192,111 +192,4 @@ module attributes {} { // CTRL2DATA-NEXT: } -// MAPPING: func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 10 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 8 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data, i1> -// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 2 : i32}]} : () -> !neura.data, i1> -// MAPPING-NEXT: %2 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 0 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %3 = neura.reserve : !neura.data, i1> -// MAPPING-NEXT: %4 = "neura.data_mov"(%1) {mapping_locs = [{id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %5 = "neura.phi"(%3, %4) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %6 = neura.reserve : !neura.data, i1> -// MAPPING-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %8 = "neura.phi"(%6, %7) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %9 = neura.reserve : !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%2) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 0 : i32}, {id = 129 : i32, resource = "register", time_step = 1 : i32}, {id = 129 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %11 = "neura.phi"(%9, %10) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %12 = neura.reserve : !neura.data -// MAPPING-NEXT: %13 = "neura.data_mov"(%2) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.phi"(%12, %13) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 1 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %15 = "neura.data_mov"(%14) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = "neura.icmp"(%15) <{cmpType = "slt"}> {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 3 : i32}], rhs_const_value = 128 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %17 = "neura.data_mov"(%11) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %18 = "neura.data_mov"(%16) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 2 : i32}, {id = 176 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %20 = "neura.data_mov"(%8) {mapping_locs = [{id = 177 : i32, resource = "register", time_step = 3 : i32}, {id = 177 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 178 : i32, resource = "register", time_step = 2 : i32}, {id = 178 : i32, resource = "register", time_step = 3 : i32}, {id = 178 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %22 = neura.grant_predicate %20, %21 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %23 = "neura.data_mov"(%5) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %24 = "neura.data_mov"(%16) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 2 : i32}, {id = 168 : i32, resource = "register", time_step = 3 : i32}, {id = 168 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %25 = neura.grant_predicate %23, %24 {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %26 = "neura.data_mov"(%14) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 1 : i32}, {id = 128 : i32, resource = "register", time_step = 2 : i32}, {id = 128 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %27 = "neura.data_mov"(%16) {mapping_locs = [{id = 77 : i32, resource = "link", time_step = 2 : i32}, {id = 129 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %28 = neura.grant_predicate %26, %27 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %29 = neura.reserve : !neura.data -// MAPPING-NEXT: %30 = "neura.data_mov"(%28) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 4 : i32}, {id = 129 : i32, resource = "register", time_step = 5 : i32}, {id = 129 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %31 = "neura.phi"(%29, %30) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %32 = neura.reserve : !neura.data, i1> -// MAPPING-NEXT: %33 = "neura.data_mov"(%25) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %34 = "neura.phi"(%32, %33) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %35 = neura.reserve : !neura.data -// MAPPING-NEXT: %36 = "neura.data_mov"(%19) {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %37 = "neura.phi"(%35, %36) {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %38 = neura.reserve : !neura.data, i1> -// MAPPING-NEXT: %39 = "neura.data_mov"(%22) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %40 = "neura.phi"(%38, %39) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %41 = neura.reserve : !neura.data -// MAPPING-NEXT: %42 = "neura.data_mov"(%19) {mapping_locs = [{id = 77 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %43 = "neura.phi"(%41, %42) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %44 = "neura.data_mov"(%43) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %45 = "neura.icmp"(%44) <{cmpType = "slt"}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 2 : i32}], rhs_const_value = 128 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %46 = "neura.data_mov"(%40) {mapping_locs = [{id = 177 : i32, resource = "register", time_step = 6 : i32}, {id = 177 : i32, resource = "register", time_step = 7 : i32}, {id = 177 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %47 = "neura.data_mov"(%45) {mapping_locs = [{id = 130 : i32, resource = "register", time_step = 6 : i32}, {id = 56 : i32, resource = "link", time_step = 7 : i32}, {id = 176 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %48 = neura.grant_predicate %46, %47 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %49 = "neura.data_mov"(%37) {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 5 : i32}, {id = 176 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %50 = "neura.data_mov"(%45) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %51 = neura.grant_predicate %49, %50 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %52 = "neura.data_mov"(%43) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 5 : i32}, {id = 120 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %53 = "neura.data_mov"(%45) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %54 = neura.grant_predicate %52, %53 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %55 = "neura.data_mov"(%34) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 6 : i32}, {id = 120 : i32, resource = "register", time_step = 7 : i32}, {id = 120 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %56 = "neura.data_mov"(%45) {mapping_locs = [{id = 133 : i32, resource = "register", time_step = 6 : i32}, {id = 53 : i32, resource = "link", time_step = 7 : i32}, {id = 121 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %57 = neura.grant_predicate %55, %56 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 9 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %58 = "neura.data_mov"(%31) {mapping_locs = [{id = 129 : i32, resource = "register", time_step = 7 : i32}, {id = 129 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %59 = "neura.data_mov"(%45) {mapping_locs = [{id = 131 : i32, resource = "register", time_step = 6 : i32}, {id = 131 : i32, resource = "register", time_step = 7 : i32}, {id = 131 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %60 = neura.grant_predicate %58, %59 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %61 = "neura.data_mov"(%45) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 6 : i32}, {id = 128 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %62 = "neura.not"(%61) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 8 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %63 = "neura.data_mov"(%31) {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 7 : i32}, {id = 80 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %64 = "neura.data_mov"(%62) {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %65 = neura.grant_predicate %63, %64 {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 9 : i32, x = 4 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %66 = "neura.data_mov"(%37) {mapping_locs = [{id = 225 : i32, resource = "register", time_step = 5 : i32}, {id = 225 : i32, resource = "register", time_step = 6 : i32}, {id = 225 : i32, resource = "register", time_step = 7 : i32}, {id = 225 : i32, resource = "register", time_step = 8 : i32}, {id = 225 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %67 = "neura.data_mov"(%62) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 8 : i32}, {id = 78 : i32, resource = "link", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %68 = neura.grant_predicate %66, %67 {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 4 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %69 = "neura.data_mov"(%40) {mapping_locs = [{id = 76 : i32, resource = "link", time_step = 6 : i32}, {id = 80 : i32, resource = "link", time_step = 7 : i32}, {id = 136 : i32, resource = "register", time_step = 8 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %70 = "neura.data_mov"(%62) {mapping_locs = [{id = 54 : i32, resource = "link", time_step = 8 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %71 = neura.grant_predicate %69, %70 {mapping_locs = [{id = 17 : i32, resource = "tile", time_step = 9 : i32, x = 5 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %72 = "neura.data_mov"(%34) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 6 : i32}, {id = 73 : i32, resource = "link", time_step = 7 : i32}, {id = 122 : i32, resource = "register", time_step = 8 : i32}, {id = 122 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %73 = "neura.data_mov"(%62) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 8 : i32}, {id = 120 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %74 = neura.grant_predicate %72, %73 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 10 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// MAPPING-NEXT: %75 = "neura.data_mov"(%48) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %76 = "neura.data_mov"(%51) {mapping_locs = [{id = 178 : i32, resource = "register", time_step = 7 : i32}, {id = 178 : i32, resource = "register", time_step = 8 : i32}, {id = 178 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %77 = "neura.data_mov"(%51) {mapping_locs = [{id = 180 : i32, resource = "register", time_step = 7 : i32}, {id = 180 : i32, resource = "register", time_step = 8 : i32}, {id = 180 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %78 = "neura.data_mov"(%51) {mapping_locs = [{id = 181 : i32, resource = "register", time_step = 7 : i32}, {id = 181 : i32, resource = "register", time_step = 8 : i32}, {id = 181 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %79 = "neura.data_mov"(%51) {mapping_locs = [{id = 182 : i32, resource = "register", time_step = 7 : i32}, {id = 182 : i32, resource = "register", time_step = 8 : i32}, {id = 182 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %80 = "neura.data_mov"(%51) {mapping_locs = [{id = 183 : i32, resource = "register", time_step = 7 : i32}, {id = 183 : i32, resource = "register", time_step = 8 : i32}, {id = 183 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %81 = "neura.data_mov"(%54) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 7 : i32}, {id = 72 : i32, resource = "link", time_step = 8 : i32}, {id = 177 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %82 = neura.load_indexed %75[%76, %77, %78, %79, %80, %81 : !neura.data, !neura.data, !neura.data, !neura.data, !neura.data, !neura.data] !neura.data, i1> {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data -// MAPPING-NEXT: %83 = "neura.data_mov"(%82) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 10 : i32}, {id = 168 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %84 = "neura.data_mov"(%57) {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 9 : i32}, {id = 52 : i32, resource = "link", time_step = 10 : i32}, {id = 170 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// MAPPING-NEXT: %85 = "neura.data_mov"(%51) {mapping_locs = [{id = 75 : i32, resource = "link", time_step = 7 : i32}, {id = 171 : i32, resource = "register", time_step = 8 : i32}, {id = 171 : i32, resource = "register", time_step = 9 : i32}, {id = 171 : i32, resource = "register", time_step = 10 : i32}, {id = 171 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %86 = "neura.data_mov"(%51) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 7 : i32}, {id = 75 : i32, resource = "link", time_step = 8 : i32}, {id = 172 : i32, resource = "register", time_step = 9 : i32}, {id = 172 : i32, resource = "register", time_step = 10 : i32}, {id = 172 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %87 = "neura.data_mov"(%60) {mapping_locs = [{id = 128 : i32, resource = "register", time_step = 9 : i32}, {id = 53 : i32, resource = "link", time_step = 10 : i32}, {id = 52 : i32, resource = "link", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %88 = "neura.data_mov"(%51) {mapping_locs = [{id = 179 : i32, resource = "register", time_step = 7 : i32}, {id = 179 : i32, resource = "register", time_step = 8 : i32}, {id = 75 : i32, resource = "link", time_step = 9 : i32}, {id = 173 : i32, resource = "register", time_step = 10 : i32}, {id = 173 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %89 = "neura.data_mov"(%51) {mapping_locs = [{id = 76 : i32, resource = "link", time_step = 7 : i32}, {id = 184 : i32, resource = "register", time_step = 8 : i32}, {id = 184 : i32, resource = "register", time_step = 9 : i32}, {id = 79 : i32, resource = "link", time_step = 10 : i32}, {id = 75 : i32, resource = "link", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %90 = "neura.data_mov"(%54) {mapping_locs = [{id = 122 : i32, resource = "register", time_step = 7 : i32}, {id = 52 : i32, resource = "link", time_step = 8 : i32}, {id = 174 : i32, resource = "register", time_step = 9 : i32}, {id = 174 : i32, resource = "register", time_step = 10 : i32}, {id = 174 : i32, resource = "register", time_step = 11 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: neura.store_indexed %83 to %84[%85, %86, %87, %88, %89, %90 : !neura.data, !neura.data, !neura.data, !neura.data, !neura.data, !neura.data] !neura.data, i1> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 12 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data -// MAPPING-NEXT: %91 = "neura.data_mov"(%54) {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %92 = "neura.add"(%91) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 8 : i32, x = 3 : i32, y = 2 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %92 -> %41 {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 8 : i32}, {id = 131 : i32, resource = "register", time_step = 9 : i32}, {id = 131 : i32, resource = "register", time_step = 10 : i32}, {id = 131 : i32, resource = "register", time_step = 11 : i32}, {id = 131 : i32, resource = "register", time_step = 12 : i32}, {id = 131 : i32, resource = "register", time_step = 13 : i32}, {id = 131 : i32, resource = "register", time_step = 14 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: neura.ctrl_mov %48 -> %38 {mapping_locs = [{id = 179 : i32, resource = "register", time_step = 9 : i32}, {id = 179 : i32, resource = "register", time_step = 10 : i32}, {id = 179 : i32, resource = "register", time_step = 11 : i32}, {id = 179 : i32, resource = "register", time_step = 12 : i32}, {id = 179 : i32, resource = "register", time_step = 13 : i32}, {id = 179 : i32, resource = "register", time_step = 14 : i32}, {id = 179 : i32, resource = "register", time_step = 15 : i32}]} : !neura.data, i1> !neura.data, i1> -// MAPPING-NEXT: neura.ctrl_mov %51 -> %35 {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 7 : i32}, {id = 224 : i32, resource = "register", time_step = 8 : i32}, {id = 224 : i32, resource = "register", time_step = 9 : i32}, {id = 224 : i32, resource = "register", time_step = 10 : i32}, {id = 224 : i32, resource = "register", time_step = 11 : i32}, {id = 224 : i32, resource = "register", time_step = 12 : i32}, {id = 224 : i32, resource = "register", time_step = 13 : i32}, {id = 224 : i32, resource = "register", time_step = 14 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: neura.ctrl_mov %57 -> %32 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 9 : i32}, {id = 169 : i32, resource = "register", time_step = 10 : i32}, {id = 169 : i32, resource = "register", time_step = 11 : i32}, {id = 169 : i32, resource = "register", time_step = 12 : i32}, {id = 169 : i32, resource = "register", time_step = 13 : i32}, {id = 169 : i32, resource = "register", time_step = 14 : i32}, {id = 169 : i32, resource = "register", time_step = 15 : i32}]} : !neura.data, i1> !neura.data, i1> -// MAPPING-NEXT: neura.ctrl_mov %60 -> %29 {mapping_locs = [{id = 132 : i32, resource = "register", time_step = 9 : i32}, {id = 132 : i32, resource = "register", time_step = 10 : i32}, {id = 132 : i32, resource = "register", time_step = 11 : i32}, {id = 132 : i32, resource = "register", time_step = 12 : i32}, {id = 132 : i32, resource = "register", time_step = 13 : i32}, {id = 132 : i32, resource = "register", time_step = 14 : i32}, {id = 132 : i32, resource = "register", time_step = 15 : i32}, {id = 132 : i32, resource = "register", time_step = 16 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %93 = "neura.data_mov"(%65) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 9 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %94 = "neura.add"(%93) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 10 : i32, x = 4 : i32, y = 1 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %94 -> %12 {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 10 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: neura.ctrl_mov %68 -> %9 {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 10 : i32}, {id = 77 : i32, resource = "link", time_step = 11 : i32}, {id = 130 : i32, resource = "register", time_step = 12 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: neura.ctrl_mov %71 -> %6 {mapping_locs = [{id = 57 : i32, resource = "link", time_step = 9 : i32}, {id = 56 : i32, resource = "link", time_step = 10 : i32}, {id = 177 : i32, resource = "register", time_step = 11 : i32}, {id = 177 : i32, resource = "register", time_step = 12 : i32}]} : !neura.data, i1> !neura.data, i1> -// MAPPING-NEXT: neura.ctrl_mov %74 -> %3 {mapping_locs = [{id = 121 : i32, resource = "register", time_step = 10 : i32}, {id = 121 : i32, resource = "register", time_step = 11 : i32}, {id = 121 : i32, resource = "register", time_step = 12 : i32}, {id = 121 : i32, resource = "register", time_step = 13 : i32}]} : !neura.data, i1> !neura.data, i1> -// MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 3 : i32}]} : () -> () -// MAPPING-NEXT: } \ No newline at end of file +// MAPPING: func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 10 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 8 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file diff --git a/test/controflow_fuse/simple_loop/simple_loop.mlir b/test/controflow_fuse/simple_loop/simple_loop.mlir index cbcdd22d..ae282786 100644 --- a/test/controflow_fuse/simple_loop/simple_loop.mlir +++ b/test/controflow_fuse/simple_loop/simple_loop.mlir @@ -208,60 +208,4 @@ module attributes {} { // FUSE-NEXT: "neura.return"() : () -> () // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// FUSE-MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = "%arg0"}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 3 : i32}]} : () -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = "%arg1"}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 1 : i32}]} : () -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %2 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %3 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 0 : i32, x = 4 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %4 = "neura.grant_once"() <{constant_value = 1 : i32}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 1 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %5 = "neura.grant_once"() <{constant_value = 2 : i32}> {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 4 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %6 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %7 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 1 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%7) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 0 : i32}, {id = 26 : i32, resource = "link", time_step = 1 : i32}, {id = 112 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%6) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 0 : i32}, {id = 64 : i32, resource = "link", time_step = 1 : i32}, {id = 69 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %10 = "neura.data_mov"(%3) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 0 : i32}, {id = 49 : i32, resource = "link", time_step = 1 : i32}, {id = 113 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %11 = "neura.data_mov"(%2) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 0 : i32}, {id = 114 : i32, resource = "register", time_step = 1 : i32}, {id = 114 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %8, start = %9, end = %10, step = %11) {iterationType = "increment", mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// FUSE-MAPPING-NEXT: %12 = neura.reserve : !neura.data, i1> -// FUSE-MAPPING-NEXT: %13 = "neura.data_mov"(%1) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %14 = "neura.phi"(%12, %13) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %15 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %16 = "neura.data_mov"(%4) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 4 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %18 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %19 = "neura.data_mov"(%5) {mapping_locs = [{id = 208 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %21 = neura.reserve : !neura.data, i1> -// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%0) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, i1>, !neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %24 = "neura.data_mov"(%23) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 1 : i32}, {id = 120 : i32, resource = "register", time_step = 2 : i32}, {id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%valid) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %26 = neura.grant_predicate %24, %25 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %27 = "neura.data_mov"(%20) {mapping_locs = [{id = 91 : i32, resource = "link", time_step = 2 : i32}, {id = 69 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %28 = "neura.data_mov"(%valid) {mapping_locs = [{id = 112 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %29 = neura.grant_predicate %27, %28 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %30 = "neura.data_mov"(%17) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 3 : i32}, {id = 72 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %31 = "neura.data_mov"(%valid) {mapping_locs = [{id = 47 : i32, resource = "link", time_step = 3 : i32}, {id = 24 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %32 = neura.grant_predicate %30, %31 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %33 = "neura.data_mov"(%14) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 4 : i32}, {id = 64 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %34 = "neura.data_mov"(%valid) {mapping_locs = [{id = 114 : i32, resource = "register", time_step = 3 : i32}, {id = 47 : i32, resource = "link", time_step = 4 : i32}, {id = 65 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %35 = neura.grant_predicate %33, %34 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, i1>, !neura.data -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %36 = "neura.data_mov"(%26) {mapping_locs = [{id = 49 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %37 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 113 : i32, resource = "register", time_step = 3 : i32}, {id = 113 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %38 = neura.load_indexed %36[%37 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data -// FUSE-MAPPING-NEXT: %39 = "neura.data_mov"(%38) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %40 = "neura.data_mov"(%29) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 4 : i32}, {id = 104 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %41 = "neura.mul"(%39, %40) {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %42 = "neura.data_mov"(%41) {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %43 = "neura.data_mov"(%32) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 5 : i32}, {id = 23 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %44 = "neura.add"(%42, %43) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %45 = "neura.data_mov"(%44) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %46 = "neura.data_mov"(%35) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 6 : i32}, {id = 5 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data, i1>) -> !neura.data, i1> -// FUSE-MAPPING-NEXT: %47 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 45 : i32, resource = "link", time_step = 3 : i32}, {id = 43 : i32, resource = "link", time_step = 4 : i32}, {id = 21 : i32, resource = "link", time_step = 5 : i32}, {id = 8 : i32, resource = "register", time_step = 6 : i32}, {id = 8 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: neura.store_indexed %45 to %46[%47 : !neura.data] !neura.data, i1> {mapping_locs = [{id = 1 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 0 : i32}]} : !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %26 -> %21 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data, i1> !neura.data, i1> -// FUSE-MAPPING-NEXT: neura.ctrl_mov %29 -> %18 {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 4 : i32}, {id = 70 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %32 -> %15 {mapping_locs = [{id = 28 : i32, resource = "link", time_step = 5 : i32}, {id = 81 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %35 -> %12 {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 6 : i32}, {id = 64 : i32, resource = "register", time_step = 7 : i32}]} : !neura.data, i1> !neura.data, i1> -// FUSE-MAPPING-NEXT: "neura.return"() {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : () -> () -// FUSE-MAPPING-NEXT: } \ No newline at end of file +// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file diff --git a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir index f738e641..601d3ab8 100644 --- a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir +++ b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir @@ -166,34 +166,4 @@ module attributes {} { // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 5 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// FUSE-MAPPING-NEXT: %0 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %1 = "neura.grant_always"() <{constant_value = 128 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %2 = "neura.grant_once"() <{constant_value = 0 : i32}> {mapping_locs = [{id = 17 : i32, resource = "tile", time_step = 1 : i32, x = 5 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 32 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 5 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data -// FUSE-MAPPING-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 0 : i32}, {id = 160 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 111 : i32, resource = "link", time_step = 0 : i32}, {id = 91 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %7 = "neura.data_mov"(%1) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 0 : i32}, {id = 64 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %8 = "neura.data_mov"(%0) {mapping_locs = [{id = 64 : i32, resource = "link", time_step = 0 : i32}, {id = 161 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 3 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// FUSE-MAPPING-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 160 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %11 = neura.reserve : !neura.data -// FUSE-MAPPING-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 57 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 53 : i32, resource = "link", time_step = 2 : i32}, {id = 52 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 68 : i32, resource = "link", time_step = 2 : i32}, {id = 168 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 56 : i32, resource = "link", time_step = 2 : i32}, {id = 176 : i32, resource = "register", time_step = 3 : i32}, {id = 176 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 68 : i32, resource = "link", time_step = 3 : i32}, {id = 72 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 5 : i32, x = 4 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// FUSE-MAPPING-NEXT: %20 = "neura.data_mov"(%nextindex) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %21 = "neura.cast"(%20) <{cast_type = "i64_to_i32"}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %22 = "neura.data_mov"(%16) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 3 : i32}, {id = 120 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: %24 = "neura.add"(%22, %23) {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: neura.ctrl_mov %24 -> %11 {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 5 : i32}, {id = 128 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data -// FUSE-MAPPING-NEXT: %25 = "neura.data_mov"(%19) {mapping_locs = [{id = 176 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// FUSE-MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data) -> () -// FUSE-MAPPING-NEXT: } \ No newline at end of file +// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 5 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file diff --git a/test/mapping_quality/branch_for.mlir b/test/mapping_quality/branch_for.mlir index e63517e6..b353a454 100644 --- a/test/mapping_quality/branch_for.mlir +++ b/test/mapping_quality/branch_for.mlir @@ -189,37 +189,7 @@ func.func @loop_test() -> f32 { // MAPPING: module { // MAPPING-NEXT: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 0 : i32, x = 3 : i32, y = 3 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %2 = neura.reserve : !neura.data -// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 3 : i32, x = 4 : 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 = 168 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %8 = "neura.data_mov"(%4) {mapping_locs = [{id = 80 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %9 = "neura.fadd"(%8) {mapping_locs = [{id = 10 : i32, resource = "tile", time_step = 4 : i32, x = 4 : i32, y = 1 : i32}], rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%7) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %11 = "neura.add"(%10) {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 2 : i32, x = 3 : i32, y = 3 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 168 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {mapping_locs = [{id = 21 : i32, resource = "tile", time_step = 3 : i32, x = 3 : i32, y = 3 : i32}], rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.data_mov"(%11) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 2 : i32}, {id = 120 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %15 = "neura.data_mov"(%13) {mapping_locs = [{id = 73 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %16 -> %5 {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 4 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %17 = "neura.data_mov"(%9) {mapping_locs = [{id = 34 : i32, resource = "link", time_step = 4 : i32}, {id = 128 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %18 = "neura.data_mov"(%13) {mapping_locs = [{id = 72 : i32, resource = "link", time_step = 3 : i32}, {id = 77 : i32, resource = "link", time_step = 4 : i32}, {id = 129 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 16 : i32, resource = "tile", time_step = 6 : i32, x = 4 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %19 -> %2 {mapping_locs = [{id = 55 : i32, resource = "link", time_step = 6 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %20 = "neura.data_mov"(%13) {mapping_locs = [{id = 71 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %21 = "neura.not"(%20) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %22 = "neura.data_mov"(%9) {mapping_locs = [{id = 31 : i32, resource = "link", time_step = 4 : i32}, {id = 27 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 4 : i32}, {id = 47 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %24 = neura.grant_predicate %22, %23 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %25 = "neura.data_mov"(%24) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> () -// MAPPING-NEXT: } -// MAPPING-NEXT: } + // YAML: array_config: // YAML-NEXT: columns: 6 diff --git a/test/mapping_quality/tiny_loop.mlir b/test/mapping_quality/tiny_loop.mlir index e35e7ba0..710366ac 100644 --- a/test/mapping_quality/tiny_loop.mlir +++ b/test/mapping_quality/tiny_loop.mlir @@ -74,61 +74,5 @@ module { // CHECK-NEXT: } // SPATIAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-only", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// SPATIAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 0 : i32, x = 2 : i32, y = 2 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 27 : i32, resource = "tile", time_step = 1 : i32, x = 3 : i32, y = 4 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// SPATIAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 0 : i32}, {id = 47 : i32, resource = "link", time_step = 1 : i32}, {id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 0 : i32}, {id = 43 : i32, resource = "link", time_step = 1 : i32}, {id = 20 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 21 : i32, resource = "link", time_step = 0 : i32}, {id = 3 : i32, resource = "link", time_step = 1 : i32}, {id = 7 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 46 : i32, resource = "link", time_step = 0 : i32}, {id = 51 : i32, resource = "link", time_step = 1 : i32}, {id = 27 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// SPATIAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %11 = neura.reserve : !neura.data -// SPATIAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 94 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 28 : i32, resource = "tile", time_step = 2 : i32, x = 4 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 97 : i32, resource = "link", time_step = 2 : i32}, {id = 95 : i32, resource = "link", time_step = 3 : i32}, {id = 73 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 3 : i32}, {id = 30 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 15 : i32, resource = "tile", time_step = 5 : i32, x = 3 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 99 : i32, resource = "link", time_step = 2 : i32}, {id = 77 : i32, resource = "link", time_step = 3 : i32}, {id = 55 : i32, resource = "link", time_step = 4 : i32}, {id = 31 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 6 : i32, resource = "link", time_step = 4 : i32}, {id = 10 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 6 : i32, x = 3 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 50 : i32, resource = "link", time_step = 5 : i32}, {id = 56 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 52 : i32, resource = "link", time_step = 5 : i32}, {id = 72 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 22 : i32, resource = "tile", time_step = 7 : i32, x = 4 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 78 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data -// SPATIAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 29 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 3 : i32, resource = "tile", time_step = 7 : i32, x = 3 : i32, y = 0 : i32}]} : (!neura.data) -> () -// SPATIAL-NEXT: } -// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// SPATIAL-TEMPORAL-NEXT: %0 = "neura.grant_always"() <{constant_value = 16 : i64}> {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 2 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %1 = "neura.grant_always"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 23 : i32, resource = "tile", time_step = 0 : i32, x = 5 : i32, y = 3 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %2 = "neura.grant_once"() <{constant_value = 1 : i64}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 1 : i32, x = 2 : i32, y = 1 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %3 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 4 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %4 = "neura.grant_always"() <{constant_value = true}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %5 = "neura.data_mov"(%4) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 0 : i32}, {id = 26 : i32, resource = "link", time_step = 1 : i32}, {id = 48 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %6 = "neura.data_mov"(%3) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 0 : i32}, {id = 86 : i32, resource = "link", time_step = 1 : i32}, {id = 91 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %7 = "neura.data_mov"(%0) {mapping_locs = [{id = 42 : i32, resource = "link", time_step = 0 : i32}, {id = 48 : i32, resource = "link", time_step = 1 : i32}, {id = 160 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %8 = "neura.data_mov"(%1) {mapping_locs = [{id = 79 : i32, resource = "link", time_step = 0 : i32}, {id = 75 : i32, resource = "link", time_step = 1 : i32}, {id = 71 : i32, resource = "link", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %nextindex, %valid = neura.loop_control(parent_valid = %5, start = %6, end = %7, step = %8) {iterationType = "increment", mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 3 : i32}]} : !neura.data, !neura.data, !neura.data, !neura.data -> !neura.data, !neura.data -// SPATIAL-TEMPORAL-NEXT: %9 = "neura.data_mov"(%valid) {mapping_locs = [{id = 70 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %10 = "neura.not"(%9) {mapping_locs = [{id = 26 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %11 = neura.reserve : !neura.data -// SPATIAL-TEMPORAL-NEXT: %12 = "neura.data_mov"(%2) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 1 : i32}, {id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %13 = "neura.phi"(%11, %12) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %14 = "neura.data_mov"(%13) {mapping_locs = [{id = 26 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %15 = "neura.data_mov"(%valid) {mapping_locs = [{id = 69 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %17 = "neura.data_mov"(%13) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 3 : i32}, {id = 65 : i32, resource = "register", time_step = 4 : i32}, {id = 26 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %18 = "neura.data_mov"(%10) {mapping_locs = [{id = 91 : i32, resource = "link", time_step = 4 : i32}, {id = 69 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %20 = "neura.data_mov"(%16) {mapping_locs = [{id = 112 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %21 = "neura.data_mov"(%16) {mapping_locs = [{id = 113 : i32, resource = "register", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: %22 = "neura.add"(%20, %21) {mapping_locs = [{id = 14 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 2 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: neura.ctrl_mov %22 -> %11 {mapping_locs = [{id = 47 : i32, resource = "link", time_step = 5 : i32}]} : !neura.data !neura.data -// SPATIAL-TEMPORAL-NEXT: %23 = "neura.data_mov"(%19) {mapping_locs = [{id = 48 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// SPATIAL-TEMPORAL-NEXT: "neura.return"(%23) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> () -// SPATIAL-TEMPORAL-NEXT: } \ No newline at end of file +// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file diff --git a/test/neura/ctrl/branch_for.mlir b/test/neura/ctrl/branch_for.mlir index cf663b92..5aebe111 100644 --- a/test/neura/ctrl/branch_for.mlir +++ b/test/neura/ctrl/branch_for.mlir @@ -188,52 +188,79 @@ func.func @loop_test() -> f32 { // MOV-NEXT: } // MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// MAPPING-NEXT: %0 = "neura.grant_once"() <{constant_value = 0 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %1 = "neura.grant_once"() <{constant_value = 0.000000e+00 : f32}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %2 = neura.reserve : !neura.data -// MAPPING-NEXT: %3 = "neura.data_mov"(%1) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %4 = "neura.phi"(%2, %3) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 3 : i32, x = 1 : 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 = 56 : i32, resource = "register", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %7 = "neura.phi"(%5, %6) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %8 = "neura.data_mov"(%4) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %9 = "neura.fadd"(%8) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 1 : i32}], rhs_const_value = 3.000000e+00 : f32} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%7) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %11 = "neura.add"(%10) {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 2 : i32, x = 2 : i32, y = 1 : i32}], rhs_const_value = 1 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %12 = "neura.data_mov"(%11) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %13 = "neura.icmp"(%12) <{cmpType = "slt"}> {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 3 : i32, x = 2 : i32, y = 1 : i32}], rhs_const_value = 10 : i64} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.data_mov"(%11) {mapping_locs = [{id = 65 : i32, resource = "register", time_step = 2 : i32}, {id = 65 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %15 = "neura.data_mov"(%13) {mapping_locs = [{id = 64 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %16 = neura.grant_predicate %14, %15 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 4 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %16 -> %5 {mapping_locs = [{id = 23 : i32, resource = "link", time_step = 4 : i32}, {id = 57 : i32, resource = "register", time_step = 5 : i32}, {id = 57 : i32, resource = "register", time_step = 6 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %17 = "neura.data_mov"(%9) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 4 : i32}, {id = 20 : i32, resource = "link", time_step = 5 : i32}, {id = 64 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %18 = "neura.data_mov"(%13) {mapping_locs = [{id = 66 : i32, resource = "register", time_step = 3 : i32}, {id = 66 : i32, resource = "register", time_step = 4 : i32}, {id = 66 : i32, resource = "register", time_step = 5 : i32}, {id = 66 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %19 = neura.grant_predicate %17, %18 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 7 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %19 -> %2 {mapping_locs = [{id = 23 : i32, resource = "link", time_step = 7 : i32}, {id = 57 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %20 = "neura.data_mov"(%13) {mapping_locs = [{id = 24 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %21 = "neura.not"(%20) {mapping_locs = [{id = 9 : i32, resource = "tile", time_step = 4 : i32, x = 3 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %22 = "neura.data_mov"(%9) {mapping_locs = [{id = 20 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %23 = "neura.data_mov"(%21) {mapping_locs = [{id = 27 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %24 = neura.grant_predicate %22, %23 {mapping_locs = [{id = 8 : i32, resource = "tile", time_step = 5 : i32, x = 2 : i32, y = 1 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %25 = "neura.data_mov"(%24) {mapping_locs = [{id = 25 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: "neura.return"(%25) {mapping_locs = [{id = 2 : i32, resource = "tile", time_step = 6 : i32, x = 2 : i32, y = 0 : i32}]} : (!neura.data) -> () -// MAPPING-NEXT: } -// YAML: array_config: -// YAML-NEXT: columns: 6 -// YAML-NEXT: rows: 6 -// YAML-NEXT: cores: -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "2" +// YAML: - column: 1 +// YAML-NEXT: row: 1 +// YAML-NEXT: core_id: "7" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 6 +// YAML-NEXT: - timestep: 0 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "RETURN" +// YAML-NEXT: - opcode: "GRANT_ONCE" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: - operand: "#0" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 1 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 2 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "#0.000000" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 3 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 4 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "FADD" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$56" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 5 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$57" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 8 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$57" // YAML-NEXT: color: "RED" From 4d4a041244db5f3e1fdb716de75ce2a715a59899 Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Sat, 27 Sep 2025 00:47:39 +0800 Subject: [PATCH 5/6] add comments & rename variables --- lib/NeuraDialect/Mapping/mapping_util.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/NeuraDialect/Mapping/mapping_util.cpp b/lib/NeuraDialect/Mapping/mapping_util.cpp index d19f952c..2f3d9f93 100644 --- a/lib/NeuraDialect/Mapping/mapping_util.cpp +++ b/lib/NeuraDialect/Mapping/mapping_util.cpp @@ -440,22 +440,19 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, // Special case: source tile and destination tile are the same. if (src_tile == dst_tile) { // Uses register as routing resource within the same tile. - int start_time = src_loc.time_step; - int exclusive_end_time = exclusive_deadline_step; - // Finds an available register to store the data. - Register *available_reg = - getAvailableRegister(state, src_tile, start_time, exclusive_end_time); + Register *available_reg = getAvailableRegister( + state, src_tile, src_loc.time_step, exclusive_deadline_step); if (!available_reg) { llvm::outs() << "[tryRouteDataMove] Cannot find available register on Tile#" - << src_tile->getId() << " for time range: t=" << start_time - << " to t=" << exclusive_end_time << "\n"; + << src_tile->getId() << " for time range: t=" << src_loc.time_step + << " to t=" << exclusive_deadline_step << "\n"; return false; } // Builds path: uses register to store data for the specified time period. - for (int t = start_time; t < exclusive_end_time; ++t) { + for (int t = src_loc.time_step; t < exclusive_deadline_step; ++t) { path_out.push_back({available_reg, t}); } @@ -489,6 +486,8 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, // Checks if destination tile is reached with appropriate timing. if (current_state.current_tile == dst_tile) { + // The link/register between producer tile and consumer tile is belonging + // to the producer tile with same time step. if (current_state.current_time <= exclusive_deadline_step) { if (current_state.current_time == exclusive_deadline_step) { // Arrives exactly at deadline, no additional register needed. @@ -554,7 +553,11 @@ bool mlir::neura::tryRouteDataMove(Operation *mov_op, MappingLoc src_loc, current_state.current_time + 1); if (wait_register) { int next_time = current_state.current_time + 1; - // Checks if this (tile, time) combination has been visited. + // Checks if this(tile, time) combination has been visited. + // Though theoretically we can revisit a tile at different time steps + // to explore alternative routing paths, we disallow this during the + // routing search to prevent exponential search complexity and ensure + // algorithm termination within reasonable time bounds. if (visited.insert({current_state.current_tile, next_time}).second) { std::vector new_path = current_state.path; new_path.push_back({wait_register, current_state.current_time}); From e68310871bfc90c8d5ecbdc9c4c06f6c8f9b7a55 Mon Sep 17 00:00:00 2001 From: ShangkunLI Date: Sat, 27 Sep 2025 01:48:14 +0800 Subject: [PATCH 6/6] change the size to 4x4 --- .../Transforms/MapToAcceleratorPass.cpp | 2 +- test/code_gen/test_code_generate.mlir | 739 ++---------------- .../perfect_nested/perfect_nested.mlir | 2 +- .../simple_loop/simple_loop.mlir | 2 +- .../simple_loop_reduction.mlir | 2 +- test/mapping_quality/branch_for.mlir | 54 +- test/mapping_quality/tiny_loop.mlir | 6 +- test/neura/ctrl/branch_for.mlir | 70 +- 8 files changed, 124 insertions(+), 753 deletions(-) diff --git a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp index f07f9465..20c00db8 100644 --- a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp +++ b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp @@ -169,7 +169,7 @@ struct MapToAcceleratorPass } // AcceleratorConfig config{/*numTiles=*/8}; // Example - Architecture architecture(6, 6); + Architecture architecture(4, 4); int res_mii = calculateResMii(func, architecture); const int possibleMinII = std::max(rec_mii, res_mii); diff --git a/test/code_gen/test_code_generate.mlir b/test/code_gen/test_code_generate.mlir index c3ad2928..46a17e1c 100644 --- a/test/code_gen/test_code_generate.mlir +++ b/test/code_gen/test_code_generate.mlir @@ -6,8 +6,8 @@ // RUN: --transform-ctrl-to-data-flow \ // RUN: --insert-data-mov \ // RUN: --map-to-accelerator="mapping-strategy=heuristic" \ -// RUN: --generate-code \ -// RUN: | FileCheck %s -check-prefix=MAPPING +// RUN: --generate-code -o %t-mapping.mlir +// RU: FileCheck %s --input-file=%t-mapping.mlir -check-prefix=MAPPING // RUN: FileCheck %s --input-file=tmp-generated-instructions.yaml --check-prefix=YAML // RUN: FileCheck %s --input-file=tmp-generated-instructions.asm --check-prefix=ASM @@ -31,74 +31,7 @@ func.func @loop_test() -> f32 { return %result : f32 } -// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { -// MAPPING-NEXT: %0 = "neura.constant"() <{predicate = true, value = 10 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 1 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %1 = "neura.data_mov"(%0) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %2 = "neura.grant_once"(%1) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %3 = "neura.constant"() <{predicate = true, value = 0 : i64}> {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 0 : i32, x = 1 : i32, y = 1 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %4 = "neura.data_mov"(%3) {mapping_locs = [{id = 19 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %5 = "neura.grant_once"(%4) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %6 = "neura.constant"() <{predicate = true, value = 1 : i64}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 0 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %7 = "neura.data_mov"(%6) {mapping_locs = [{id = 62 : i32, resource = "link", time_step = 0 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %8 = "neura.grant_once"(%7) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 1 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %9 = "neura.constant"() <{predicate = true, value = 3.000000e+00 : f32}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 2 : i32, x = 1 : i32, y = 3 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %10 = "neura.data_mov"(%9) {mapping_locs = [{id = 152 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %11 = "neura.grant_once"(%10) {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %12 = "neura.constant"() <{predicate = true, value = 0.000000e+00 : f32}> {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 3 : i32}]} : () -> !neura.data -// MAPPING-NEXT: %13 = "neura.data_mov"(%12) {mapping_locs = [{id = 144 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %14 = "neura.grant_once"(%13) {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 3 : i32, x = 0 : i32, y = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %15 = neura.reserve : !neura.data -// MAPPING-NEXT: %16 = "neura.data_mov"(%2) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 2 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %17 = "neura.phi"(%15, %16) {mapping_locs = [{id = 7 : i32, resource = "tile", time_step = 3 : i32, x = 1 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %18 = neura.reserve : !neura.data -// MAPPING-NEXT: %19 = "neura.data_mov"(%8) {mapping_locs = [{id = 192 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %20 = "neura.phi"(%18, %19) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %21 = neura.reserve : !neura.data -// MAPPING-NEXT: %22 = "neura.data_mov"(%11) {mapping_locs = [{id = 152 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %23 = "neura.phi"(%21, %22) {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 4 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %24 = neura.reserve : !neura.data -// MAPPING-NEXT: %25 = "neura.data_mov"(%14) {mapping_locs = [{id = 62 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %26 = "neura.phi"(%24, %25) {mapping_locs = [{id = 24 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %27 = neura.reserve : !neura.data -// MAPPING-NEXT: %28 = "neura.data_mov"(%5) {mapping_locs = [{id = 48 : i32, resource = "register", time_step = 1 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %29 = "neura.phi"(%27, %28) {mapping_locs = [{id = 6 : i32, resource = "tile", time_step = 2 : i32, x = 0 : i32, y = 1 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %30 = "neura.data_mov"(%26) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %31 = "neura.data_mov"(%23) {mapping_locs = [{id = 66 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %32 = "neura.fadd"(%30, %31) {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 4 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %33 = "neura.data_mov"(%29) {mapping_locs = [{id = 18 : i32, resource = "link", time_step = 2 : i32}, {id = 40 : i32, resource = "link", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %34 = "neura.data_mov"(%20) {mapping_locs = [{id = 83 : i32, resource = "link", time_step = 2 : i32}, {id = 144 : i32, resource = "register", time_step = 3 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %35 = "neura.add"(%33, %34) {mapping_locs = [{id = 18 : i32, resource = "tile", time_step = 4 : i32, x = 0 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %36 = "neura.data_mov"(%35) {mapping_locs = [{id = 60 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %37 = "neura.data_mov"(%17) {mapping_locs = [{id = 22 : i32, resource = "link", time_step = 3 : i32}, {id = 44 : i32, resource = "link", time_step = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %38 = "neura.icmp"(%36, %37) <{cmpType = "slt"}> {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 5 : i32, x = 1 : i32, y = 3 : i32}]} : (!neura.data, !neura.data) -> !neura.data -// MAPPING-NEXT: %39 = "neura.data_mov"(%35) {mapping_locs = [{id = 61 : i32, resource = "link", time_step = 4 : i32}, {id = 96 : i32, resource = "register", time_step = 5 : i32}, {id = 96 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %40 = "neura.data_mov"(%38) {mapping_locs = [{id = 63 : i32, resource = "link", time_step = 5 : i32}, {id = 61 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %41 = neura.grant_predicate %39, %40 {mapping_locs = [{id = 12 : i32, resource = "tile", time_step = 7 : i32, x = 0 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %41 -> %27 {mapping_locs = [{id = 39 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %42 = "neura.data_mov"(%32) {mapping_locs = [{id = 200 : i32, resource = "register", time_step = 5 : i32}, {id = 200 : i32, resource = "register", time_step = 6 : i32}, {id = 200 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %43 = "neura.data_mov"(%38) {mapping_locs = [{id = 155 : i32, resource = "register", time_step = 5 : i32}, {id = 66 : i32, resource = "link", time_step = 6 : i32}, {id = 201 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %44 = neura.grant_predicate %42, %43 {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 4 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %44 -> %24 {mapping_locs = [{id = 85 : i32, resource = "link", time_step = 8 : i32}, {id = 192 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %45 = "neura.data_mov"(%23) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 4 : i32}, {id = 105 : i32, resource = "register", time_step = 5 : i32}, {id = 105 : i32, resource = "register", time_step = 6 : i32}, {id = 105 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %46 = "neura.data_mov"(%38) {mapping_locs = [{id = 154 : i32, resource = "register", time_step = 5 : i32}, {id = 65 : i32, resource = "link", time_step = 6 : i32}, {id = 104 : i32, resource = "register", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %47 = neura.grant_predicate %45, %46 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 8 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %47 -> %21 {mapping_locs = [{id = 44 : i32, resource = "link", time_step = 8 : i32}, {id = 153 : i32, resource = "register", time_step = 9 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %48 = "neura.data_mov"(%20) {mapping_locs = [{id = 82 : i32, resource = "link", time_step = 2 : i32}, {id = 87 : i32, resource = "link", time_step = 3 : i32}, {id = 152 : i32, resource = "register", time_step = 4 : i32}, {id = 152 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %49 = "neura.data_mov"(%38) {mapping_locs = [{id = 153 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %50 = neura.grant_predicate %48, %49 {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %50 -> %18 {mapping_locs = [{id = 63 : i32, resource = "link", time_step = 6 : i32}, {id = 62 : i32, resource = "link", time_step = 7 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %51 = "neura.data_mov"(%17) {mapping_locs = [{id = 56 : i32, resource = "register", time_step = 3 : i32}, {id = 22 : i32, resource = "link", time_step = 4 : i32}, {id = 104 : i32, resource = "register", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %52 = "neura.data_mov"(%38) {mapping_locs = [{id = 65 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %53 = neura.grant_predicate %51, %52 {mapping_locs = [{id = 13 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 2 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: neura.ctrl_mov %53 -> %15 {mapping_locs = [{id = 43 : i32, resource = "link", time_step = 6 : i32}, {id = 57 : i32, resource = "register", time_step = 7 : i32}, {id = 57 : i32, resource = "register", time_step = 8 : i32}]} : !neura.data !neura.data -// MAPPING-NEXT: %54 = "neura.data_mov"(%38) {mapping_locs = [{id = 66 : i32, resource = "link", time_step = 5 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %55 = "neura.not"(%54) {mapping_locs = [{id = 25 : i32, resource = "tile", time_step = 6 : i32, x = 1 : i32, y = 4 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %56 = "neura.data_mov"(%32) {mapping_locs = [{id = 87 : i32, resource = "link", time_step = 5 : i32}, {id = 152 : i32, resource = "register", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %57 = "neura.data_mov"(%55) {mapping_locs = [{id = 87 : i32, resource = "link", time_step = 6 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: %58 = neura.grant_predicate %56, %57 {mapping_locs = [{id = 19 : i32, resource = "tile", time_step = 7 : i32, x = 1 : i32, y = 3 : i32}]} : !neura.data, !neura.data -> !neura.data -// MAPPING-NEXT: %59 = "neura.data_mov"(%58) {mapping_locs = [{id = 64 : i32, resource = "link", time_step = 7 : i32}]} : (!neura.data) -> !neura.data -// MAPPING-NEXT: "neura.return"(%59) {mapping_locs = [{id = 20 : i32, resource = "tile", time_step = 8 : i32, x = 2 : i32, y = 3 : i32}]} : (!neura.data) -> () -// MAPPING-NEXT: } +// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 2 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { // Each core represents a processing element in the CGRA array // Example: column: 1, row: 1 represents the core at position (1,1) in the 4x4 grid @@ -135,603 +68,69 @@ func.func @loop_test() -> f32 { // written into local register $20. // -// YAML: array_config: -// YAML-NEXT: columns: 6 -// YAML-NEXT: rows: 6 -// YAML-NEXT: cores: -// YAML-NEXT: - column: 0 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "6" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 1 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$48" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 2 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$48" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "7" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 1 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#10" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 2 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$57" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 0 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "12" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$96" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$96" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "13" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$104" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$105" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$104" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$104" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 8 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$105" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$104" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 0 -// YAML-NEXT: row: 3 -// YAML-NEXT: core_id: "18" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#1" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 2 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0.000000" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$144" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$144" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$144" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ADD" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$144" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 3 -// YAML-NEXT: core_id: "19" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 2 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CONSTANT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#3.000000" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ICMP" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$153" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$153" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$152" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 9 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$153" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 3 -// YAML-NEXT: core_id: "20" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 8 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "RETURN" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 0 -// YAML-NEXT: row: 4 -// YAML-NEXT: core_id: "24" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 1 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$192" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 2 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$192" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 9 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$192" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 4 -// YAML-NEXT: core_id: "25" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "FADD" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$200" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$201" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "NOT" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 8 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$200" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$201" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" - - -// ASM-LABEL: PE(0,1): -// ASM: { -// ASM: GRANT_ONCE, [EAST, RED] -> [$48] -// ASM: } (t=1) -// ASM: { -// ASM: PHI, [NORTH, RED], [$48] -> [NORTH, RED] -// ASM: } (t=2) - -// ASM-LABEL: PE(1,1): -// ASM: { -// ASM: CONSTANT, [#0] -> [WEST, RED] -// ASM: } (t=0) -// ASM: { -// ASM: CONSTANT, [#10] -> [$56] -// ASM: } (t=1) -// ASM: { -// ASM: GRANT_ONCE, [$56] -> [$56] -// ASM: } (t=2) -// ASM: { -// ASM: PHI, [NORTH, RED], [$56] -> [NORTH, RED] -// ASM: } (t=3) -// ASM: { -// ASM: CTRL_MOV, [SOUTH, RED] -> [$57] -// ASM: } (t=7) - -// ASM-LABEL: PE(0,2): -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [NORTH, RED] -// ASM: } (t=3) -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [$96] -// ASM: } (t=5) -// ASM: { -// ASM: GRANT_PREDICATE, [$96], [NORTH, RED] -> [SOUTH, RED] -// ASM: } (t=7) - -// ASM-LABEL: PE(1,2): -// ASM: { -// ASM: DATA_MOV, [NORTH, RED] -> [$104] -// ASM: } (t=3) -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [NORTH, RED] -// ASM: } (t=4) -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [$105] -// ASM: DATA_MOV, [SOUTH, RED] -> [$104] -// ASM: } (t=5) -// ASM: { -// ASM: GRANT_PREDICATE, [$104], [NORTH, RED] -> [SOUTH, RED] -// ASM: } (t=6) -// ASM: { -// ASM: GRANT_PREDICATE, [$105], [$104] -> [NORTH, RED] -// ASM: } (t=8) - -// ASM-LABEL: PE(0,3): -// ASM: { -// ASM: CONSTANT, [#1] -> [NORTH, RED] -// ASM: } (t=0) -// ASM: { -// ASM: CONSTANT, [#0.000000] -> [$144] -// ASM: } (t=2) -// ASM: { -// ASM: GRANT_ONCE, [$144] -> [NORTH, RED] -// ASM: DATA_MOV, [SOUTH, RED] -> [$144] -// ASM: } (t=3) -// ASM: { -// ASM: ADD, [SOUTH, RED], [$144] -> [EAST, RED], [SOUTH, RED] -// ASM: } (t=4) -// ASM: { -// ASM: DATA_MOV, [EAST, RED] -> [SOUTH, RED] -// ASM: } (t=6) -// ASM: { -// ASM: CTRL_MOV, [EAST, RED] -> [NORTH, RED] -// ASM: } (t=7) - -// ASM-LABEL: PE(1,3): -// ASM: { -// ASM: CONSTANT, [#3.000000] -> [$152] -// ASM: } (t=2) -// ASM: { -// ASM: GRANT_ONCE, [$152] -> [$152] -// ASM: } (t=3) -// ASM: { -// ASM: PHI, [SOUTH, RED], [$152] -> [NORTH, RED], [SOUTH, RED] -// ASM: DATA_MOV, [SOUTH, RED] -> [$152] -// ASM: } (t=4) -// ASM: { -// ASM: ICMP, [WEST, RED], [SOUTH, RED] -> [WEST, RED], [NORTH, RED], [SOUTH, RED], [$153] -// ASM: } (t=5) -// ASM: { -// ASM: GRANT_PREDICATE, [$152], [$153] -> [WEST, RED] -// ASM: DATA_MOV, [SOUTH, RED] -> [$152] -// ASM: } (t=6) -// ASM: { -// ASM: GRANT_PREDICATE, [$152], [NORTH, RED] -> [EAST, RED] -// ASM: } (t=7) -// ASM: { -// ASM: CTRL_MOV, [NORTH, RED] -> [$153] -// ASM: } (t=9) - -// ASM-LABEL: PE(2,3): -// ASM: { -// ASM: RETURN, [WEST, RED] -// ASM: } (t=8) - -// ASM-LABEL: PE(0,4): -// ASM: { -// ASM: GRANT_ONCE, [SOUTH, RED] -> [$192] -// ASM: } (t=1) -// ASM: { -// ASM: PHI, [SOUTH, RED], [$192] -> [SOUTH, RED], [EAST, RED] -// ASM: } (t=2) -// ASM: { -// ASM: PHI, [EAST, RED], [SOUTH, RED] -> [EAST, RED] -// ASM: } (t=4) -// ASM: { -// ASM: CTRL_MOV, [WEST, RED] -> [$192] -// ASM: } (t=9) - -// ASM-LABEL: PE(1,4): -// ASM: { -// ASM: DATA_MOV, [WEST, RED] -> [SOUTH, RED] -// ASM: } (t=3) -// ASM: { -// ASM: FADD, [WEST, RED], [SOUTH, RED] -> [$200], [SOUTH, RED] -// ASM: DATA_MOV, [NORTH, RED] -> [$201] -// ASM: } (t=5) -// ASM: { -// ASM: NOT, [SOUTH, RED] -> [SOUTH, RED] -// ASM: } (t=6) -// ASM: { -// ASM: GRANT_PREDICATE, [$200], [$201] -> [WEST, RED] -// ASM: } (t=8) +// YAML: - column: 1 +// YAML-NEXT: row: 0 +// YAML-NEXT: core_id: "1" +// YAML-NEXT: entries: +// YAML-NEXT: - entry_id: "entry0" +// YAML-NEXT: instructions: +// YAML-NEXT: - timestep: 1 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 2 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$8" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 3 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "PHI" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$9" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$8" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "$8" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 4 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "DATA_MOV" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - timestep: 5 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_PREDICATE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "$8" +// YAML-NEXT: color: "RED" +// YAML-NEXT: - operand: "NORTH" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "$9" +// YAML-NEXT: color: "RED" + + +// ASM: PE(0,0): +// ASM-NEXT: { +// ASM-NEXT: CONSTANT, [#0] -> [EAST, RED] +// ASM-NEXT: } (t=0) +// ASM-NEXT: { +// ASM-NEXT: CONSTANT, [#10] -> [EAST, RED] +// ASM-NEXT: } (t=1) \ No newline at end of file diff --git a/test/controflow_fuse/perfect_nested/perfect_nested.mlir b/test/controflow_fuse/perfect_nested/perfect_nested.mlir index 0255ebe1..4f4447ab 100644 --- a/test/controflow_fuse/perfect_nested/perfect_nested.mlir +++ b/test/controflow_fuse/perfect_nested/perfect_nested.mlir @@ -192,4 +192,4 @@ module attributes {} { // CTRL2DATA-NEXT: } -// MAPPING: func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 10 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 8 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file +// MAPPING: func.func @_Z10bert_node1PA1_A1_A1_A1_A128_bPA1_A128_S1_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 10 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 8 : i32, res_mii = 3 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { \ No newline at end of file diff --git a/test/controflow_fuse/simple_loop/simple_loop.mlir b/test/controflow_fuse/simple_loop/simple_loop.mlir index ae282786..951b08ac 100644 --- a/test/controflow_fuse/simple_loop/simple_loop.mlir +++ b/test/controflow_fuse/simple_loop/simple_loop.mlir @@ -208,4 +208,4 @@ module attributes {} { // FUSE-NEXT: "neura.return"() : () -> () // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file +// FUSE-MAPPING: func.func @_Z11simple_loopPiS_(%arg0: memref, %arg1: memref) attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 2 : i32, res_mii = 2 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { \ No newline at end of file diff --git a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir index 601d3ab8..a995893b 100644 --- a/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir +++ b/test/controflow_fuse/simple_loop_reduction/simple_loop_reduction.mlir @@ -166,4 +166,4 @@ module attributes {} { // FUSE-NEXT: } -// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 5 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file +// FUSE-MAPPING: func.func @_Z10simpleloopv() -> i32 attributes {accelerator = "neura", llvm.linkage = #llvm.linkage, mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { \ No newline at end of file diff --git a/test/mapping_quality/branch_for.mlir b/test/mapping_quality/branch_for.mlir index b353a454..5b438daa 100644 --- a/test/mapping_quality/branch_for.mlir +++ b/test/mapping_quality/branch_for.mlir @@ -188,37 +188,31 @@ func.func @loop_test() -> f32 { // MOV-NEXT: } // MAPPING: module { -// MAPPING-NEXT: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING-NEXT: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// YAML: array_config: -// YAML-NEXT: columns: 6 -// YAML-NEXT: rows: 6 +// YAML: array_config: +// YAML-NEXT: columns: 4 +// YAML-NEXT: rows: 4 // YAML-NEXT: cores: -// YAML-NEXT: - column: 1 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "7" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 0 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "#0" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" - - -// ASM: PE(1,1): +// YAML-NEXT: - column: 0 +// YAML-NEXT: row: 1 +// YAML-NEXT: core_id: "4" +// YAML-NEXT: entries: +// YAML-NEXT: - entry_id: "entry0" +// YAML-NEXT: instructions: +// YAML-NEXT: - timestep: 2 +// YAML-NEXT: operations: +// YAML-NEXT: - opcode: "GRANT_ONCE" +// YAML-NEXT: src_operands: +// YAML-NEXT: - operand: "#3.000000" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: color: "RED" + + +// ASM: PE(0,1): // ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0] -> [$56] -// ASM-NEXT: } (t=0) -// ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#10] -> [EAST, RED] -// ASM-NEXT: } (t=1) -// ASM-NEXT: { -// ASM-NEXT: PHI, [NORTH, RED], [$56] -> [NORTH, RED] -// ASM-NEXT: } (t=2) +// ASM-NEXT: GRANT_ONCE, [#3.000000] -> [EAST, RED] +// ASM-NEXT: } (t=2) \ No newline at end of file diff --git a/test/mapping_quality/tiny_loop.mlir b/test/mapping_quality/tiny_loop.mlir index 710366ac..dd7f13e9 100644 --- a/test/mapping_quality/tiny_loop.mlir +++ b/test/mapping_quality/tiny_loop.mlir @@ -38,7 +38,7 @@ // RUN: --fuse-loop-control \ // RUN: --fold-constant \ // RUN: --insert-data-mov \ -// RUN: --map-to-accelerator="mapping-strategy=heuristic mapping-mode=spatial-temporal backtrack-config=customized=3,7" \ +// RUN: --map-to-accelerator="mapping-strategy=heuristic mapping-mode=spatial-temporal backtrack-config=customized=4,4" \ // RUN: | FileCheck %s -check-prefix=SPATIAL-TEMPORAL module { @@ -73,6 +73,6 @@ module { // CHECK-NEXT: "neura.return"(%15) : (i64) -> () // CHECK-NEXT: } -// SPATIAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-only", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// SPATIAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 7 : i32, mapping_mode = "spatial-only", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { \ No newline at end of file +// SPATIAL-TEMPORAL: func.func @simple_add_loop() -> i64 attributes {accelerator = "neura", mapping_info = {compiled_ii = 3 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 3 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { \ No newline at end of file diff --git a/test/neura/ctrl/branch_for.mlir b/test/neura/ctrl/branch_for.mlir index 5aebe111..7b51971c 100644 --- a/test/neura/ctrl/branch_for.mlir +++ b/test/neura/ctrl/branch_for.mlir @@ -187,11 +187,15 @@ func.func @loop_test() -> f32 { // MOV-NEXT: "neura.return"(%25) : (!neura.data) -> () // MOV-NEXT: } -// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 6 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 6 : i32, y_tiles = 6 : i32}} { +// MAPPING: func.func @loop_test() -> f32 attributes {accelerator = "neura", mapping_info = {compiled_ii = 4 : i32, mapping_mode = "spatial-temporal", mapping_strategy = "heuristic", rec_mii = 4 : i32, res_mii = 1 : i32, x_tiles = 4 : i32, y_tiles = 4 : i32}} { -// YAML: - column: 1 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "7" +// YAML: array_config: +// YAML-NEXT: columns: 4 +// YAML-NEXT: rows: 4 +// YAML-NEXT: cores: +// YAML-NEXT: - column: 0 +// YAML-NEXT: row: 0 +// YAML-NEXT: core_id: "0" // YAML-NEXT: entries: // YAML-NEXT: - entry_id: "entry0" // YAML-NEXT: instructions: @@ -202,17 +206,6 @@ func.func @loop_test() -> f32 { // YAML-NEXT: - operand: "#0" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 1 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "PHI" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 2 @@ -222,67 +215,52 @@ func.func @loop_test() -> f32 { // YAML-NEXT: - operand: "#0.000000" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" +// YAML-NEXT: - operand: "$0" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 3 // YAML-NEXT: operations: // YAML-NEXT: - opcode: "PHI" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$56" +// YAML-NEXT: - operand: "$0" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$56" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: - timestep: 4 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "FADD" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$56" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: // YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$57" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 8 +// YAML-NEXT: - timestep: 5 // YAML-NEXT: operations: -// YAML-NEXT: - opcode: "CTRL_MOV" +// YAML-NEXT: - opcode: "DATA_MOV" // YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" +// YAML-NEXT: - operand: "EAST" // YAML-NEXT: color: "RED" // YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$57" +// YAML-NEXT: - operand: "NORTH" // YAML-NEXT: color: "RED" -// ASM: PE(1,1): +// ASM: PE(0,0): // ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0] -> [$56] +// ASM-NEXT: GRANT_ONCE, [#0] -> [EAST, RED] // ASM-NEXT: } (t=0) // ASM-NEXT: { -// ASM-NEXT: PHI, [EAST, RED], [$56] -> [EAST, RED] -// ASM-NEXT: } (t=1) -// ASM-NEXT: { -// ASM-NEXT: GRANT_ONCE, [#0.000000] -> [$56] +// ASM-NEXT: GRANT_ONCE, [#0.000000] -> [$0] // ASM-NEXT: } (t=2) // ASM-NEXT: { -// ASM-NEXT: PHI, [EAST, RED], [$56] -> [$56] +// ASM-NEXT: PHI, [NORTH, RED], [$0] -> [EAST, RED] // ASM-NEXT: } (t=3) // ASM-NEXT: { -// ASM-NEXT: FADD, [$56] -> [EAST, RED] +// ASM-NEXT: DATA_MOV, [EAST, RED] -> [NORTH, RED] // ASM-NEXT: } (t=4) // ASM-NEXT: { -// ASM-NEXT: CTRL_MOV, [WEST, RED] -> [$57] +// ASM-NEXT: DATA_MOV, [EAST, RED] -> [NORTH, RED] // ASM-NEXT: } (t=5) -// ASM-NEXT: { -// ASM-NEXT: CTRL_MOV, [WEST, RED] -> [$57] -// ASM-NEXT: } (t=8)