Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit for ctrl&data preloading. #69

Closed
wants to merge 0 commits into from

Conversation

yyan7223
Copy link
Collaborator

No description provided.

@yyan7223
Copy link
Collaborator Author

I'm confused about how to transmit preload data through NoC.
should it be:
recv_from_noc->recv_from_tile_store_request_pkt_queue->crossbar->send_to_noc ?
if belongs to current controller, then recv_from_noc->send_to_tile_store_request_data_queue ?

@yyan7223
Copy link
Collaborator Author

Another issue is that CtrlPktType of recv_ctrl_pkt_queue is incompatible with NocPktType of recv_from_noc
The former has many fields like ctrl_addr, ctrl_operation, ctrl_fu_in, while the latter only has addr and data
which means the recv_from_cpu_ctrl_pkt of the first controller cannot be transferred to other controllers through NoC.

@tancheng
Copy link
Owner

Another issue is that CtrlPktType of recv_ctrl_pkt_queue is incompatible with NocPktType of recv_from_noc The former has many fields like ctrl_addr, ctrl_operation, ctrl_fu_in, while the latter only has addr and data which means the recv_from_cpu_ctrl_pkt of the first controller cannot be transferred to other controllers through NoC.

Replied here: #68 (comment)

@tancheng
Copy link
Owner

tancheng commented Jan 19, 2025

I'm confused about how to transmit preload data through NoC. should it be: recv_from_noc->recv_from_tile_store_request_pkt_queue->crossbar->send_to_noc ? if belongs to current controller, then recv_from_noc->send_to_tile_store_request_data_queue ?

We just need to send data pkt into NoC regardless the pkt's dst (via the s.crossbar.recv[kStoreRequestInportIdx] or a new crossbar recv port). So all the pkts would go into NoC first. Then, I believe following can already automatically handle current controller case:

elif s.recv_from_noc.msg.cmd == CMD_STORE_REQUEST:

Each controller would only receive the pkt belonging to its self, i.e., controller 2 would never receive pkt belonging to controller 1/3.

Comment on lines 323 to 333
@update
def update_send_to_ctrl_ring_msg():
# Delivers the ctrl pkt that belongs to current controller to the CGRA tiles.
if s.recv_ctrl_pkt_queue.send.msg.dst == controller_id:
if s.send_to_ctrl_ring_ctrl_pkt.rdy:
s.send_to_ctrl_ring_ctrl_pkt.val @= 1
s.send_to_ctrl_ring_ctrl_pkt.msg @= s.recv_ctrl_pkt_queue.send.msg
else:
s.send_to_ctrl_ring_ctrl_pkt.val @= 0
s.send_to_ctrl_ring_ctrl_pkt.msg @= CtrlPktType()

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You already send config into NoC. Then the handler should be implemented on line 275.

lib/cmd_type.py Outdated
@@ -19,6 +19,8 @@
CMD_LOAD_REQUEST = 4
CMD_LOAD_RESPONSE = 5
CMD_STORE_REQUEST = 6
CMD_PRELOAD_CTRL = 7
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMD_CONFIG if for this purpose.

lib/cmd_type.py Outdated
@@ -19,6 +19,8 @@
CMD_LOAD_REQUEST = 4
CMD_LOAD_RESPONSE = 5
CMD_STORE_REQUEST = 6
CMD_PRELOAD_CTRL = 7
CMD_PRELOAD_DATA = 8
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMD_STORE_REQUEST can be leveraged for this purpose.

Comment on lines 279 to 321
if controller_id == 0:
# Preloads ctrl to the 1st controller.
if s.recv_ctrl_pkt_queue.recv.rdy:
s.recv_ctrl_pkt_queue.recv.val @= s.recv_from_cpu_ctrl_pkt.val
s.recv_ctrl_pkt_queue.recv.msg @= s.recv_from_cpu_ctrl_pkt.msg
# Preloads data to the 1st controller.
if s.send_to_tile_store_request_addr_queue.recv.rdy & \
s.send_to_tile_store_request_data_queue.recv.rdy:
s.recv_from_cpu_ctrl_pkt.rdy @= 1
# TODO: Renames recv_from_cpu_ctrl_pkt to recv_from_cpu_pkt, add cmd, data, and addr field for preloading.
#s.send_to_tile_store_request_addr_queue.recv.msg @= \
# CGRAAddrType(s.recv_from_cpu_ctrl_pkt.msg.addr)
#s.send_to_tile_store_request_data_queue.recv.msg @= \
# CGRADataType(s.recv_from_cpu_ctrl_pkt.msg.data, s.recv_from_cpu_ctrl_pkt.msg.predicate, 0, 0)
s.send_to_tile_store_request_addr_queue.recv.msg @= CGRAAddrType()
s.send_to_tile_store_request_data_queue.recv.msg @= CGRADataType()
s.send_to_tile_store_request_addr_queue.recv.val @= s.recv_from_cpu_ctrl_pkt.val
s.send_to_tile_store_request_data_queue.recv.val @= s.recv_from_cpu_ctrl_pkt.val

else:
# Preloads ctrl to the rest of controllers through NoC.
if s.recv_from_noc.msg.cmd == CMD_PRELOAD_CTRL:
if s.recv_ctrl_pkt_queue.recv.rdy:
s.recv_ctrl_pkt_queue.recv.val @= s.recv_from_noc.val
# TODO: CtrlPktType of recv_ctrl_pkt_queue is incompatible with NocPktType of recv_from_noc.
#s.recv_ctrl_pkt_queue.recv.msg @= CtrlPktType(received_pkt.src,
# received_pkt.dst,
# received_pkt.opaque,
# received_pkt.cmd,
# received_pkt.addr,
# received_pkt.data,
# received_pkt.predicate)
# Preloads data to the rest of controllers through NoC.
elif s.recv_from_noc.msg.cmd == CMD_PRELOAD_DATA:
if s.send_to_tile_store_request_addr_queue.recv.rdy & \
s.send_to_tile_store_request_data_queue.recv.rdy:
s.recv_from_noc.rdy @= 1
s.send_to_tile_store_request_addr_queue.recv.msg @= \
CGRAAddrType(received_pkt.addr)
s.send_to_tile_store_request_data_queue.recv.msg @= \
CGRADataType(received_pkt.data, received_pkt.predicate, 0, 0)
s.send_to_tile_store_request_addr_queue.recv.val @= s.recv_from_noc.val
s.send_to_tile_store_request_data_queue.recv.val @= s.recv_from_noc.val
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe line 256 already handled these.

0, # dst_y
0,
0,
CMD_PRELOAD_CTRL,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to CMD_CONFIG.

0)

# For the data preloading.
# TODO: Where deos the preloading data for other controllers come from, recv_from_noc or recv_from_tile_store_request_pkt?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the most simple/straightforward way is:

      s.crossbar.recv[kStoreRequestFromCpuInportIdx].val @= \
          s.recv_ctrl_pkt_queue.send.val & (s.recv_ctrl_pkt_queue.send.msg.cmd_action == CMD_STORE_REQUEST)
      s.recv_ctrl_pkt_queue.send.rdy @= s.crossbar.recv[kStoreRequestFromCpuInportIdx].rdy

Comment on lines 207 to 211
s.crossbar.recv[kPreloadCtrlIdx].val @= \
s.recv_ctrl_pkt_queue.send.val
s.recv_ctrl_pkt_queue.send.rdy @= s.crossbar.recv[kPreloadCtrlIdx].rdy
s.crossbar.recv[kPreloadCtrlIdx].msg @= \
NocPktType(controller_id,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should depend on cpu msg type:

  s.crossbar.recv[kPreloadCtrlIdx].val @= s.recv_ctrl_pkt_queue.send.val & (s.recv_ctrl_pkt_queue.send.msg.cmd_action == CMD_CONFIG)
  s.recv_ctrl_pkt_queue.send.rdy @= s.crossbar.recv[kPreloadCtrlIdx].rdy
  s.crossbar.recv[kPreloadCtrlIdx].msg @= \
          NocPktType(controller_id,

@yyan7223 yyan7223 requested a review from tancheng January 23, 2025 03:16
@@ -20,7 +20,7 @@

class ControllerRTL(Component):

def construct(s, ControllerIdType, CmdType, CtrlPktType, NocPktType,
def construct(s, ControllerIdType, CmdType, PreloadPktType, NocPktType,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename PreloadPktType to FromCpuPktType?


@update
def update_received_msg():
kLoadRequestInportIdx = 0
kLoadResponseInportIdx = 1
kStoreRequestInportIdx = 2
kPreloadCtrlIdx = 3
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kPreloadCtrlIdx -> kFromCpuCtrlIdx?


@update
def update_received_msg():
kLoadRequestInportIdx = 0
kLoadResponseInportIdx = 1
kStoreRequestInportIdx = 2
kPreloadCtrlIdx = 3
kPreloaDataIdx = 4
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kPreloaDataIdx -> kFromCpuDataIdx?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants