diff --git a/lib/NeuraDialect/Architecture/Architecture.cpp b/lib/NeuraDialect/Architecture/Architecture.cpp index 933cc209..37961ae5 100644 --- a/lib/NeuraDialect/Architecture/Architecture.cpp +++ b/lib/NeuraDialect/Architecture/Architecture.cpp @@ -209,28 +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++); - RegisterFile *register_file_0 = new RegisterFile(0); - register_file_0->addRegister(register_0); - register_file_0->addRegister(register_1); - - // Creates registers as a register file. - Register *register_2 = new Register(reg_id++); - Register *register_3 = new Register(reg_id++); - RegisterFile *register_file_1 = new RegisterFile(1); - register_file_1->addRegister(register_2); - register_file_1->addRegister(register_3); + 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 2e998c93..2f3d9f93 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 @@ -416,143 +417,161 @@ 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; - } + assert(path_out.empty() && "Output path should be empty"); - // Defines the time window for the register allocation. - int start_time = src_loc.time_step; - int exclusive_end_time = dst_loc.time_step; + // Gets the source tile and destination tile. + Tile *src_tile = dyn_cast(src_loc.resource); + Tile *dst_tile = dyn_cast(dst_loc.resource); - // For backward moves, we need to adjust the end time. - if (is_backward_move) { - exclusive_end_time += state.getII(); - } + assert(src_tile && dst_tile && + "Source and destination locations must be tiles"); - // 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"; + // Calculates the deadline time step (adds II for backward moves). + int exclusive_deadline_step = dst_loc.time_step; + if (is_backward_move) { + 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=" << 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. + // Finds an available register to store the data. + 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=" << src_loc.time_step + << " to t=" << exclusive_deadline_step << "\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 = src_loc.time_step; t < exclusive_deadline_step; ++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) { + // 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. + 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, + exclusive_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 < exclusive_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)) { + // Skips if current time already exceeds deadline. + if (current_state.current_time >= exclusive_deadline_step) { + continue; + } + + // Explores two routing options from current tile: + + // 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}; + + // Checks if link is available at current time step. + if (!state.isAvailableAcrossTime(link_loc)) { 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; + 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}); } + } - std::vector extended_path = current_path; - extended_path.push_back(current_step_next_link); - queue.push({next_tile, next_step, std::move(extended_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. + // 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}); + + 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=" << exclusive_deadline_step << "\n"; return false; } diff --git a/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp b/lib/NeuraDialect/Transforms/MapToAcceleratorPass.cpp index eda7f7ff..20c00db8 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..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 = 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 = 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: 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: -// 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: src_operands: -// YAML-NEXT: - operand: "#10" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// 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: - 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: "$4" -// 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: color: "RED" -// YAML-NEXT: - operand: "$4" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$4" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$4" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$5" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 0 -// YAML-NEXT: core_id: "2" -// 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: "$8" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 1 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_ONCE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$8" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$8" -// 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: "$8" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "WEST" -// 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: src_operands: -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// 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: 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: "EAST" -// 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: 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: 4 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ICMP" -// 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: - 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: src_operands: -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 6 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$21" -// 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: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$22" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "CTRL_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "WEST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$20" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 2 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "6" -// YAML-NEXT: entries: -// YAML-NEXT: - entry_id: "entry0" -// YAML-NEXT: instructions: -// YAML-NEXT: - timestep: 3 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "ADD" -// 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: "$25" -// 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: color: "RED" -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 5 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "FADD" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$24" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$26" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "DATA_MOV" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "EAST" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" -// 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: color: "RED" -// YAML-NEXT: - operand: "$24" -// 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: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "EAST" -// 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: color: "RED" -// YAML-NEXT: - operand: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$24" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - opcode: "CTRL_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: 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: "NORTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - column: 3 -// YAML-NEXT: row: 1 -// YAML-NEXT: core_id: "7" -// 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: "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: color: "RED" -// YAML-NEXT: dst_operands: -// YAML-NEXT: - operand: "$28" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - timestep: 7 -// YAML-NEXT: operations: -// YAML-NEXT: - opcode: "GRANT_PREDICATE" -// YAML-NEXT: src_operands: -// YAML-NEXT: - operand: "$28" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "WEST" -// 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: 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: "EAST" -// YAML-NEXT: color: "RED" -// 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: - column: 2 -// YAML-NEXT: row: 2 -// YAML-NEXT: core_id: "10" -// 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: src_operands: -// YAML-NEXT: - operand: "SOUTH" -// YAML-NEXT: color: "RED" -// YAML-NEXT: - operand: "$40" -// 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: 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: 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: "$41" -// 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: 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: "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: 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: "SOUTH" -// 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: { -// ASM: GRANT_ONCE, [WEST, RED] -> [NORTH, RED] -// ASM: } (t=1) -// ASM: { -// ASM: GRANT_ONCE, [WEST, RED] -> [$4] -// 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: { -// ASM: CONSTANT, [#1] -> [$8] -// ASM: } (t=0) -// ASM: { -// ASM: GRANT_ONCE, [$8] -> [$8] -// ASM: } (t=1) -// ASM: { -// ASM: PHI, [NORTH, RED], [$8] -> [NORTH, RED], [WEST, RED] -// ASM: } (t=2) - -// ASM-LABEL: PE(3,0): -// ASM: { -// ASM: RETURN, [NORTH, RED] -// ASM: } (t=8) - -// ASM-LABEL: PE(0,1): -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [EAST, RED] -// ASM: } (t=5) - -// ASM-LABEL: PE(1,1): -// ASM: { -// ASM: PHI, [EAST, RED], [SOUTH, RED] -> [EAST, RED] -// ASM: } (t=2) -// ASM: { -// ASM: ICMP, [EAST, RED], [SOUTH, RED] -> [EAST, RED], [NORTH, RED], [$22], [$21], [SOUTH, RED], [$20] -// ASM: } (t=4) -// ASM: { -// ASM: NOT, [$20] -> [EAST, RED] -// 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: } (t=7) - -// ASM-LABEL: PE(2,1): -// ASM: { -// ASM: ADD, [WEST, RED], [SOUTH, RED] -> [WEST, RED], [$25] -// ASM: } (t=3) -// ASM: { -// ASM: PHI, [$24], [EAST, RED] -> [$24] -// ASM: } (t=4) -// ASM: { -// ASM: FADD, [$24], [NORTH, RED] -> [$26], [EAST, RED] -// ASM: DATA_MOV, [EAST, RED] -> [$24] -// ASM: } (t=5) -// ASM: { -// ASM: GRANT_PREDICATE, [$25], [$24] -> [WEST, RED] -// ASM: DATA_MOV, [WEST, RED] -> [EAST, 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: } (t=8) - -// ASM-LABEL: PE(3,1): -// ASM: { -// ASM: GRANT_ONCE, [NORTH, RED] -> [WEST, RED] -// ASM: } (t=3) -// ASM: { -// ASM: DATA_MOV, [EAST, RED] -> [$28] -// ASM: } (t=6) -// ASM: { -// ASM: GRANT_PREDICATE, [$28], [WEST, RED] -> [SOUTH, RED] -// ASM: } (t=7) - -// ASM-LABEL: PE(1,2): -// ASM: { -// ASM: DATA_MOV, [SOUTH, RED] -> [EAST, RED] -// ASM: DATA_MOV, [EAST, RED] -> [SOUTH, RED] -// ASM: } (t=5) - -// ASM-LABEL: PE(2,2): -// ASM: { -// ASM: GRANT_ONCE, [NORTH, RED] -> [$40] -// ASM: } (t=3) -// ASM: { -// ASM: PHI, [SOUTH, RED], [$40] -> [SOUTH, RED], [WEST, RED] -// ASM: } (t=4) -// ASM: { -// ASM: DATA_MOV, [WEST, RED] -> [SOUTH, RED] -// ASM: } (t=6) -// ASM: { -// ASM: CTRL_MOV, [NORTH, RED] -> [$41] -// ASM: } (t=9) - -// ASM-LABEL: PE(3,2): -// ASM: { -// ASM: CONSTANT, [#0.000000] -> [SOUTH, RED] -// ASM: } (t=2) - -// ASM-LABEL: PE(2,3): -// ASM: { -// ASM: CONSTANT, [#3.000000] -> [SOUTH, RED] -// ASM: } (t=2) - - - +// 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 1bb7acca..4f4447ab 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,7 @@ 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 = 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 7a686758..951b08ac 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 = 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-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: %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: %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: %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: } \ 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 c7a11ee2..a995893b 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,4 @@ 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-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: } \ 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 e4eb55bf..5b438daa 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,117 @@ 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: 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 = 4 : i32, y_tiles = 4 : i32}} { -// 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-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: } -// YAML: array_config: +// YAML: array_config: // YAML-NEXT: columns: 4 // YAML-NEXT: rows: 4 // YAML-NEXT: cores: -// 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-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 +// 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, [#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 92c23f48..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,4" \ +// 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,62 +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 = 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-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: } +// 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 = 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-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: } \ 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 f0e26134..7b51971c 100644 --- a/test/neura/ctrl/branch_for.mlir +++ b/test/neura/ctrl/branch_for.mlir @@ -188,36 +188,6 @@ func.func @loop_test() -> f32 { // 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-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: %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: "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 @@ -238,21 +208,59 @@ func.func @loop_test() -> f32 { // 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: "$0" +// 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: "$0" +// YAML-NEXT: color: "RED" +// YAML-NEXT: dst_operands: +// YAML-NEXT: - operand: "EAST" +// 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: "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" -// 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(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)