Skip to content

Decouple CommandEncoder from Device#3316

Open
zcbenz wants to merge 1 commit intoml-explore:mainfrom
zcbenz:encoder-refactor-3
Open

Decouple CommandEncoder from Device#3316
zcbenz wants to merge 1 commit intoml-explore:mainfrom
zcbenz:encoder-refactor-3

Conversation

@zcbenz
Copy link
Copy Markdown
Collaborator

@zcbenz zcbenz commented Mar 25, 2026

Refs #3078, #3216.

Refactor code to use metal::get_command_encoder and CommandEncoder APIs, instead of the Device methods like Device::get_command_encoder/add_temporary that take stream index.

The motivation is that, Device are global objects that shared by all threads, but we do not want to share CommandEncoder between threads, which does not have any performance benefit and brings various race conditions. This refactoring would allow us to store CommandEncoder in thread-local storages and detect thread-safety issues caused by using streams from different threads.

@zcbenz zcbenz force-pushed the encoder-refactor-3 branch from e732b85 to 2daec6c Compare March 25, 2026 09:52
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.

1 participant