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

Gpu memory pool code confusing #139

Open
ximitiejiang opened this issue Aug 16, 2024 · 0 comments
Open

Gpu memory pool code confusing #139

ximitiejiang opened this issue Aug 16, 2024 · 0 comments

Comments

@ximitiejiang
Copy link

hello, i am learning the code of gpu memory pool and felt confusing for below code:

while (current != memory_blocks_.end()) {

my understanding is: this while loop is to make previous iterator point to the last block and current iterator point to end of block container then we can create a new block after the last block and insert to end of block container.
but why we need below "if"?
i think this would lead to create a new block between previous and current block, seems not make sense....

    hollow_begin = previous->data + previous->size;
    if (hollow_begin + allocated_size <= current->data) {
      memory_block.data = hollow_begin;
      memory_block.pitch = 0;
      memory_block.size = allocated_size;

      host_mutex_.lock();
      memory_blocks_.insert_after(previous, memory_block);
      host_mutex_.unlock();

      return;
    } 

maybe i missed some logic, please correct me, thank you in advance.

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

No branches or pull requests

1 participant