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

Use 4k page instead of 2M for managed tensor #2058

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
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
8 changes: 3 additions & 5 deletions fbgemm_gpu/src/cumem_utils.cu
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,9 @@ Tensor new_host_mapped_tensor(
// can minimize the cost while holding this global lock.
void* const ptr = malloc(size_bytes);

// advise the kernel to allocate large 2M pages
madvise(ptr, size_bytes, MADV_HUGEPAGE);

// pre-fault/map the pages by setting the first byte of the page
size_t pageSize = (1 << 21);
// Pre-fault/map the pages by setting the first byte of the page
// TODO: parallelize the mapping of pages with a threadpool executor
const size_t pageSize = (size_t)sysconf(_SC_PAGESIZE);
uintptr_t alignedPtr = (((uintptr_t)ptr + pageSize - 1) & ~(pageSize - 1));
for (uintptr_t p = alignedPtr; p < ((uintptr_t)ptr + size_bytes);
p += pageSize) {
Expand Down