Skip to content

Gpu memory pool code confusing #139

Description

@ximitiejiang

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions