Skip to content

Refactor copyToGPU into separate allocateOnGPU and copyToGPU methods #825

@BenYang2002

Description

@BenYang2002

The current copyToGPU method is responsible for both allocating memory on the GPU and copying data into that memory. To improve modularity, readability, and reusability, we propose splitting this function into two distinct methods:

allocateOnGPU() – responsible for memory allocation only

copyToGPU() – responsible for copying data to the already allocated GPU memory

This change will make GPU memory operations more flexible and easier to manage independently, especially for cases where allocation and copying need to be handled separately (e.g., zero-copy memory sharing, conditional data updates, or deferred initialization).

Tasks:

Extract allocation logic into allocateOnGPU()

Extract copy logic into copyToGPU()

Update existing usages of copyToGPU() to use the two new methods in sequence

Add comments and documentation for the two new methods

Add tests

Metadata

Metadata

Assignees

Labels

Operations ManagerReplacing spaghetti with chain of command

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions