Skip to content

Commit c8bc4a9

Browse files
author
Raphael
committed
(feature) Extend the header and the typedef's to incorperate the collective operations
* Extend the header / typedef * Rename the existing "CollectB" to "ParallelReduction" * Extend floogen to support reduction operations * Extend the route configuration to support collectiv operations
1 parent ea35a99 commit c8bc4a9

8 files changed

Lines changed: 96 additions & 12 deletions

File tree

floogen/model/routing.py

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,9 @@ class Routing(BaseModel):
557557
port_id_bits: int = 1
558558
num_vc_id_bits: int = 0
559559
en_multicast: bool = False
560+
en_parallel_reduction: bool = False
561+
en_narrow_offload_reduction: bool = False
562+
en_wide_offload_reduction: bool = False
560563

561564
@field_validator("route_algo", mode="before")
562565
@classmethod
@@ -566,6 +569,28 @@ def validate_route_algo(cls, v):
566569
v = RouteAlgo[v]
567570
return v
568571

572+
@model_validator(mode="after")
573+
def validate_collective(self):
574+
"""Reduction can be supported with multicast only."""
575+
if not self.en_multicast and (
576+
self.en_parallel_reduction or
577+
self.en_narrow_offload_reduction or
578+
self.en_wide_offload_reduction
579+
):
580+
raise ValueError(
581+
"Multicast must be enabled to use any reduction feature "
582+
)
583+
return self
584+
585+
@model_validator(mode="after")
586+
def validate_multicast_route_algo(self):
587+
"""Multicast is supported with XY routing only"""
588+
if self.en_multicast and self.route_algo != RouteAlgo.XY:
589+
raise ValueError(
590+
"Multicast is only supported with XY routing algorithm, "
591+
f"but got {self.route_algo}"
592+
)
593+
return self
569594
def render_param_decl(self) -> str:
570595
"""Render the SystemVerilog parameter declaration."""
571596
string = ""
@@ -627,6 +652,14 @@ def render_hdr_typedef(self, network_type) -> str:
627652

628653
if self.num_vc_id_bits == 0:
629654
if self.en_multicast:
655+
if ( self.en_parallel_reduction
656+
or self.en_narrow_offload_reduction
657+
or self.en_wide_offload_reduction
658+
):
659+
return (
660+
f"`FLOO_TYPEDEF_HDR_T(hdr_t, {dst_type}, id_t, {ch_type}, rob_idx_t,"
661+
f"id_t, collect_comm_e, reduction_op_t)")
662+
630663
return (
631664
f"`FLOO_TYPEDEF_HDR_T(hdr_t, {dst_type}, id_t, {ch_type}, rob_idx_t,"
632665
f"id_t, collect_comm_e)")
@@ -645,6 +678,9 @@ def render_route_cfg(self, name) -> str:
645678
self.route_algo == RouteAlgo.ID and not self.use_id_table else 0,
646679
"NumSamRules": len(self.sam),
647680
"NumRoutes": self.num_endpoints if self.route_algo == RouteAlgo.SRC else 0,
648-
"EnMultiCast": bool_to_sv(self.en_multicast)
681+
"EnMultiCast": bool_to_sv(self.en_multicast),
682+
"EnParallelReduction": bool_to_sv(self.en_parallel_reduction),
683+
"EnNarrowOffloadReduction": bool_to_sv(self.en_narrow_offload_reduction),
684+
"EnWideOffloadReduction": bool_to_sv(self.en_wide_offload_reduction)
649685
}
650686
return sv_param_decl(name, sv_struct_render(fields), dtype="route_cfg_t")

hw/floo_axi_chimney.sv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ module floo_axi_chimney #(
613613
floo_axi_b.hdr.atop = aw_out_hdr_out.hdr.atop;
614614
floo_axi_b.payload = meta_buf_rsp_out.b;
615615
floo_axi_b.payload.id = aw_out_hdr_out.id;
616-
floo_axi_b.hdr.commtype = (aw_out_hdr_out.hdr.commtype == Multicast)? CollectB : Unicast;
616+
floo_axi_b.hdr.commtype = (aw_out_hdr_out.hdr.commtype == Multicast)?
617+
ParallelReduction : Unicast;
617618
end
618619

619620
always_comb begin

hw/floo_nw_chimney.sv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ module floo_nw_chimney #(
947947
floo_narrow_b.payload = axi_narrow_meta_buf_rsp_out.b;
948948
floo_narrow_b.payload.id = narrow_aw_buf_hdr_out.id;
949949
floo_narrow_b.hdr.commtype = (narrow_aw_buf_hdr_out.hdr.commtype == Multicast)?
950-
CollectB : Unicast;
950+
ParallelReduction : Unicast;
951951
end
952952

953953
always_comb begin
@@ -1015,7 +1015,8 @@ module floo_nw_chimney #(
10151015
floo_wide_b.hdr.axi_ch = WideB;
10161016
floo_wide_b.payload = axi_wide_meta_buf_rsp_out.b;
10171017
floo_wide_b.payload.id = wide_aw_buf_hdr_out.id;
1018-
floo_wide_b.hdr.commtype = (wide_aw_buf_hdr_out.hdr.commtype == Multicast)? CollectB : Unicast;
1018+
floo_wide_b.hdr.commtype = (wide_aw_buf_hdr_out.hdr.commtype == Multicast)?
1019+
ParallelReduction : Unicast;
10191020
end
10201021

10211022
always_comb begin

hw/floo_output_arbiter.sv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module floo_output_arbiter import floo_pkg::*;
3939

4040
// Determine which input ports are to be reduced
4141
for (genvar i = 0; i < NumRoutes; i++) begin : gen_reduce_mask
42-
assign reduce_mask[i] = (data_i[i].hdr.commtype == CollectB);
42+
assign reduce_mask[i] = (data_i[i].hdr.commtype == ParallelReduction);
4343
end
4444

4545
// Arbitrate unicasts

hw/floo_pkg.sv

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,42 @@ package floo_pkg;
8989
Unicast = 2'd0,
9090
/// Multicast communication
9191
Multicast = 2'd1,
92-
/// Reduction of AXI B-responses
93-
CollectB = 2'd2
92+
/// Parallel reduction operations
93+
ParallelReduction = 2'd2,
94+
/// Offload Reduction
95+
OffloadReduction = 2'd3
9496
} collect_comm_e;
9597

98+
/// Different offloadable reduction
99+
typedef enum logic [3:0] {
100+
R_Select = 4'b0000, // Select the first incoming flit
101+
F_Add = 4'b0100, // FP Addition
102+
F_Mul = 4'b0101, // FP Multiplication
103+
F_Min = 4'b0110, // FP Min
104+
F_Max = 4'b0111, // FP Max
105+
A_Add = 4'b1000, // Atomic Add (signed)
106+
A_Mul = 4'b1001, // (Non-) Atomic (signed)
107+
A_Min_S = 4'b1010, // Atomic Min (signed)
108+
A_Min_U = 4'b1110, // Atomic Min (unsigned)
109+
A_Max_S = 4'b1011, // Atomic Max (signed)
110+
A_Max_U = 4'b1111 // Atomic Max (unsigned)
111+
} reduction_offload_op_e;
112+
113+
/// Different instantanous reduction
114+
typedef enum logic [3:0] {
115+
SelectAW = 4'b0000, // Select the first incoming flit
116+
CollectB = 4'b0001, // Collect the B responses from an AXI transmission
117+
LSBAnd = 4'b0010 // AND Connect the LSB of the payload (useful for barrier ops)
118+
} reduction_parallel_op_e;
119+
120+
/// Union for both Datatype(s) - because they need to have the same size for the chimney
121+
/// The chimney needs this information as it does not know if we support an offload reduction
122+
/// or an parallel reduction.
123+
typedef union packed {
124+
reduction_offload_op_e op_offload;
125+
reduction_parallel_op_e op_parallel;
126+
} reduction_op_t;
127+
96128
/// The types of AXI channels in narrow-wide AXI network interfaces
97129
typedef enum logic [3:0] {
98130
NarrowAw = 4'd0,
@@ -157,6 +189,12 @@ package floo_pkg;
157189
int unsigned NumRoutes;
158190
/// Whether to enable the multicast feature in the NoC
159191
bit EnMultiCast;
192+
/// Whether to use the parallel reduction on the narrow req link
193+
bit EnParallelReduction;
194+
/// Whether to use the offload reduction on the narrow req link
195+
bit EnNarrowOffloadReduction;
196+
/// Whether to use the offload reduction on the wide link
197+
bit EnWideOffloadReduction;
160198
} route_cfg_t;
161199

162200
/// Configuration for the network interface (chimney)
@@ -220,7 +258,10 @@ package floo_pkg;
220258
IdAddrOffset: 0,
221259
NumSamRules: 0,
222260
NumRoutes: 0,
223-
EnMultiCast: 1'b0
261+
EnMultiCast: 1'b0,
262+
EnParallelReduction: 1'b0,
263+
EnNarrowOffloadReduction: 1'b0,
264+
EnWideOffloadReduction: 1'b0
224265
};
225266

226267
/// The AXI channel to link mapping in a single-AXI network interface

hw/floo_route_xymask.sv

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ module floo_route_xymask
3636
// `dst_id` in from the forward path.
3737
assign dst_id = (FwdMode)? channel_i.hdr.dst_id : channel_i.hdr.src_id;
3838
assign src_id = (FwdMode)? channel_i.hdr.src_id : channel_i.hdr.dst_id;
39-
// TODO(fischeti): Clarify with Chen why `CollectB` are excluded
40-
assign mask_in = (FwdMode && channel_i.hdr.commtype==CollectB)? '0 : channel_i.hdr.mask;
39+
// TODO(fischeti): Clarify with Chen why `ParallelReduction` are excluded
40+
assign mask_in = (FwdMode && channel_i.hdr.commtype==ParallelReduction)?
41+
'0 : channel_i.hdr.mask;
4142

4243
// We compute minimum and maximum destination IDs, to decide whether
4344
// we need to send left and/or right resp. up and/or down.

hw/include/floo_noc/typedef.svh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
//
4848
// For `SourceRouting`:
4949
// `FLOO_TYPEDEF_HDR_T(hdr_t, route_t, id_t, floo_pkg::axi_ch_e, logic)
50-
`define FLOO_TYPEDEF_HDR_T(hdr_t, dst_t, src_t, ch_t, rob_idx_t, mask_t = logic, collect_comm_t = logic) \
50+
`define FLOO_TYPEDEF_HDR_T(hdr_t, dst_t, src_t, ch_t, rob_idx_t, mask_t = logic, collect_comm_t = logic, reduction_t = logic) \
5151
typedef struct packed { \
5252
logic rob_req; \
5353
rob_idx_t rob_idx; \
@@ -58,6 +58,7 @@
5858
logic atop; \
5959
ch_t axi_ch; \
6060
collect_comm_t commtype; \
61+
reduction_t reduction_op; \
6162
} hdr_t;
6263

6364
////////////////////////////////////////////////////////////////////////////////////////////////////

hw/test/floo_test_pkg.sv

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ package floo_test_pkg;
3333
IdAddrOffset: 0,
3434
NumSamRules: 1,
3535
NumRoutes: 1,
36-
EnMultiCast: 1'b0
36+
EnMultiCast: 1'b0,
37+
EnParallelReduction: 1'b0,
38+
EnNarrowOffloadReduction: 1'b0,
39+
EnWideOffloadReduction: 1'b0
3740
};
3841

3942
// Common chimney parameters

0 commit comments

Comments
 (0)