Skip to content

[ChannelGenerator] Assign the channel only for circuit flow #1013

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

Merged
merged 4 commits into from
Jan 8, 2025

Conversation

Yu-Zhewen
Copy link
Collaborator

No description provided.

@Yu-Zhewen Yu-Zhewen changed the title [ChannelGenerator] Only assign a channel for circuit flow [ChannelGenerator] Only assign the channel for circuit flow Jan 8, 2025
@Yu-Zhewen Yu-Zhewen changed the title [ChannelGenerator] Only assign the channel for circuit flow [ChannelGenerator] Assign the channel only for circuit flow Jan 8, 2025
Copy link
Collaborator

@jtuyls jtuyls left a comment

Choose a reason for hiding this comment

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

Could you document in the description and as a comment in the code what the assignment strategy is for packet routing (round robin) and why?


/// Returns its next usable producer channel.
std::optional<uint8_t> getAndAssignProducerDMAChannel() {
for (uint8_t i = 0; i < numProducerChannels; i++) {
std::optional<uint8_t> getAndAssignProducerDMAChannel(bool isPacketFlow) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

getAndAssignProducerDMAChannel indicates that a channel is retrieved and assigned. Not assigning it based on some internal condition will lead to confusion and potential bugs, so instead, I think we should have separate getDMAChannel and assignChannel (already exists) functions which can be called by a user (AssignChannels) when appropriate. We can keep getAndAssignProducerDMAChannel around if it is still useful and call getDMAChannel and assignChannel under the hood.

numConsumerChannels(numConsumerChannels) {
assert(numProducerChannels > 0 && numConsumerChannels > 0 &&
"Invalid number of producer/consumer channels.");
// Initialize to the last channel for round-robin usage.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it makes sense to have an AssignmentMode similar to the ChannelBdIdGenerator:

ChannelAssignmentMode {
  FirstAvailable,
  RoundRobin
}

Or if the logic differs quite a bit, use specialized child classes instead: RoundRobinChannelGenerator, FirstAvailableChannelGenerator.

DenseSet<uint8_t> assignedProducerChannels;
DenseSet<uint8_t> assignedConsumerChannels;
// Tracks the last used channel, for both circuit and packet flows.
Copy link
Collaborator

Choose a reason for hiding this comment

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

There might be a bit of unclarity about what 'using' a DMA channel means, so I think 'lastRetrievedDMAChannel' might be a more clear name. And maybe document this as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@jtuyls jtuyls left a comment

Choose a reason for hiding this comment

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

LGTM

@Yu-Zhewen Yu-Zhewen enabled auto-merge (squash) January 8, 2025 22:42
@Yu-Zhewen Yu-Zhewen merged commit f76c245 into main Jan 8, 2025
7 checks passed
@Yu-Zhewen Yu-Zhewen deleted the zhewen_channelgen_packet branch January 8, 2025 23:06
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