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

Extract CommandQueue interface #17352

Merged
merged 6 commits into from
Jan 31, 2025
Merged

Extract CommandQueue interface #17352

merged 6 commits into from
Jan 31, 2025

Conversation

ayerofieiev-tt
Copy link
Member

@ayerofieiev-tt ayerofieiev-tt commented Jan 30, 2025

Ticket

#17339

Problem description

CommandQueue exposes all the details.
CommandQueue has many things in the interface which I'd prefer us to cleanup.
We need to allow MeshBuffer and MeshWorkload to go via CommandQueue.

What's changed

CommandQueue is now just an inteface
command_queue.hpp is what you care about and it now includes way less.

Moved command_queue_commands.hpp our of API folder. Yay! 😁

HWCommandQueue implements that interface.
Device creates it inside.
hardware_command_queue.hpp is relocated from api and can't be included. Yay! 😁

There is some mess with command_queue_interface.hpp. Need to sort out separately. 💩

What's next

I expect that next we work our an interface that works for both MeshBuffer and MeshWorkload, while still accommodating Buffer and Program 🔮

// CommandQueue
virtual void enqueue_program(Program& program, bool blocking) = 0;
virtual void enqueue_write_buffer(Buffer& buffer, const void* src, const BufferRegion& region, bool blocking, tt::stl::Span<const SubDeviceId> sub_device_ids = {}) = 0;

vs

// MeshCommandQueue
void enqueue_mesh_workload(MeshWorkload& mesh_workload, bool blocking);
void enqueue_write_shard(
        std::shared_ptr<MeshBuffer>& mesh_buffer, const void* host_data, const Coordinate& coord, bool blocking);
void enqueue_write_shard_to_sub_grid(
        const MeshBuffer& buffer, const void* host_data, const LogicalDeviceRange& device_range, bool blocking);
void enqueue_write_mesh_buffer(const std::shared_ptr<MeshBuffer>& buffer, const void* host_data, bool blocking);

enqueue_program vs enqueue_mesh_workload

I propose to update as enqueue_workload(MeshWorkload) and make sure that MeshWorkload can be (maybe even implicitly) constructed from Program

enqueue_write_buffer vs enqueue_write*

I don't know how to best handle. Need to align with @omilyutin-tt @tt-asaigal @cfjchu

Checklist

#include "trace_buffer.hpp"
#include "hardware_command_queue.hpp"
#include "memcpy.hpp"
#include "command_queue_interface.hpp"
Copy link
Member Author

Choose a reason for hiding this comment

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

not an interface really. need to find a better name, likely need to split. definitely need to move some things to cpp.
contains SystemMemoryManager, some "deprecated" singleton and a bunch of other things. Very big include.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, definitely needs a split. Since now there is an actual "cq interface", maybe rename to "cq utils"?

Copy link
Contributor

@omilyutin-tt omilyutin-tt left a comment

Choose a reason for hiding this comment

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

Great!

#include "trace_buffer.hpp"
#include "hardware_command_queue.hpp"
#include "memcpy.hpp"
#include "command_queue_interface.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, definitely needs a split. Since now there is an actual "cq interface", maybe rename to "cq utils"?

tt_metal/api/tt-metalium/program_impl.hpp Outdated Show resolved Hide resolved
tt_metal/api/tt-metalium/command_queue.hpp Show resolved Hide resolved
Comment on lines +31 to +32
volatile bool is_dprint_server_hung() override;
volatile bool is_noc_hung() override;
Copy link
Contributor

Choose a reason for hiding this comment

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

🥇

tt_metal/api/tt-metalium/command_queue.hpp Outdated Show resolved Hide resolved
@ayerofieiev-tt ayerofieiev-tt merged commit a44e186 into main Jan 31, 2025
9 checks passed
@ayerofieiev-tt ayerofieiev-tt deleted the ay/cq_interface branch January 31, 2025 01:51
yieldthought pushed a commit that referenced this pull request Jan 31, 2025
### Ticket
#17339

### Problem description
CommandQueue exposes all the details.
CommandQueue has many things in the interface which I'd prefer us to
cleanup.
We need to allow MeshBuffer and MeshWorkload to go via CommandQueue.

### What's changed
CommandQueue is now just an inteface
command_queue.hpp is what you care about and it now includes way less.

Moved command_queue_commands.hpp our of API folder. Yay! 😁

HWCommandQueue implements that interface. 
Device creates it inside.
hardware_command_queue.hpp is relocated from api and can't be included.
Yay! 😁

There is still some crap with 3 free functions which had Enqueue in them
- which have nothing to do with CommandQueue - for now, located in
command_queue.hpp 💩
There is some mess with command_queue_interface.hpp and
command_queue_commands.hpp. Need to sort out separately. 💩

### What's next
I expect that next we work our an interface that works for both
MeshBuffer and MeshWorkload, while still accommodating Buffer and
Program 🔮
```cpp
// CommandQueue
virtual void enqueue_program(Program& program, bool blocking) = 0;
virtual void enqueue_write_buffer(Buffer& buffer, const void* src, const BufferRegion& region, bool blocking, tt::stl::Span<const SubDeviceId> sub_device_ids = {}) = 0;
```
vs
```cpp
// MeshCommandQueue
void enqueue_mesh_workload(MeshWorkload& mesh_workload, bool blocking);
void enqueue_write_shard(
        std::shared_ptr<MeshBuffer>& mesh_buffer, const void* host_data, const Coordinate& coord, bool blocking);
void enqueue_write_shard_to_sub_grid(
        const MeshBuffer& buffer, const void* host_data, const LogicalDeviceRange& device_range, bool blocking);
void enqueue_write_mesh_buffer(const std::shared_ptr<MeshBuffer>& buffer, const void* host_data, bool blocking);
```

#### enqueue_program vs enqueue_mesh_workload

I propose to update as `enqueue_workload(MeshWorkload)` and make sure
that MeshWorkload can be (maybe even implicitly) constructed from
Program

#### enqueue_write_buffer vs enqueue_write*

I don't know how to best handle. Need to align with @omilyutin-tt
@tt-asaigal @cfjchu

### Checklist
- [x] [Post commit
CI](https://github.com/tenstorrent/tt-metal/actions/runs/13060406436)
nikileshx pushed a commit to nikileshx/tt-metal that referenced this pull request Feb 3, 2025
### Ticket
tenstorrent#17339

### Problem description
CommandQueue exposes all the details.
CommandQueue has many things in the interface which I'd prefer us to
cleanup.
We need to allow MeshBuffer and MeshWorkload to go via CommandQueue.

### What's changed
CommandQueue is now just an inteface
command_queue.hpp is what you care about and it now includes way less.

Moved command_queue_commands.hpp our of API folder. Yay! 😁

HWCommandQueue implements that interface. 
Device creates it inside.
hardware_command_queue.hpp is relocated from api and can't be included.
Yay! 😁

There is still some crap with 3 free functions which had Enqueue in them
- which have nothing to do with CommandQueue - for now, located in
command_queue.hpp 💩
There is some mess with command_queue_interface.hpp and
command_queue_commands.hpp. Need to sort out separately. 💩

### What's next
I expect that next we work our an interface that works for both
MeshBuffer and MeshWorkload, while still accommodating Buffer and
Program 🔮
```cpp
// CommandQueue
virtual void enqueue_program(Program& program, bool blocking) = 0;
virtual void enqueue_write_buffer(Buffer& buffer, const void* src, const BufferRegion& region, bool blocking, tt::stl::Span<const SubDeviceId> sub_device_ids = {}) = 0;
```
vs
```cpp
// MeshCommandQueue
void enqueue_mesh_workload(MeshWorkload& mesh_workload, bool blocking);
void enqueue_write_shard(
        std::shared_ptr<MeshBuffer>& mesh_buffer, const void* host_data, const Coordinate& coord, bool blocking);
void enqueue_write_shard_to_sub_grid(
        const MeshBuffer& buffer, const void* host_data, const LogicalDeviceRange& device_range, bool blocking);
void enqueue_write_mesh_buffer(const std::shared_ptr<MeshBuffer>& buffer, const void* host_data, bool blocking);
```

#### enqueue_program vs enqueue_mesh_workload

I propose to update as `enqueue_workload(MeshWorkload)` and make sure
that MeshWorkload can be (maybe even implicitly) constructed from
Program

#### enqueue_write_buffer vs enqueue_write*

I don't know how to best handle. Need to align with @omilyutin-tt
@tt-asaigal @cfjchu

### Checklist
- [x] [Post commit
CI](https://github.com/tenstorrent/tt-metal/actions/runs/13060406436)
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.

Extract CommandQueue interface
4 participants