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

[src] Add optimization to cuda allocator #2820

Merged
merged 3 commits into from
Nov 15, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/cudamatrix/cu-allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,20 @@ void* CuMemoryAllocator::MallocFromSubregion(SubRegion *subregion,
// region was sufficiently large. We don't check this; if it segfaults, we'll
// debug.

int max_iters=20;
int i=0;
//search for a block that we don't have to synchronize on
auto it = iter;
while (it != subregion->free_blocks.end() && i<max_iters) {
ryanleary marked this conversation as resolved.
Show resolved Hide resolved
if (it->second->thread_id == std::this_thread::get_id() || it->second->t <= synchronize_gpu_t_) {
iter = it;
break;
} else {
it++;
i++;
}
}

MemoryBlock *block = iter->second;
// Erase 'block' from its subregion's free blocks list... the next lines are
// similar to RemoveFromFreeBlocks(), but we code it directly as we have the
Expand Down