Skip to content

TOOLS/PERF: Add cuda-async memory allocator - #11566

Merged
tvegas1 merged 10 commits into
openucx:masterfrom
tvegas1:perftest_cuda_async
Aug 27, 2026
Merged

tvegas1 merged 10 commits into
openucx:masterfrom
tvegas1:perftest_cuda_async

Conversation

@tvegas1

@tvegas1 tvegas1 commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

What?

Add a named perftest memory allocator registry and a new cuda-async allocator selected with -m cuda-async and asymmetric case -m cuda-async,cuda.

Why?

Perftest currently maps allocators by memory type, which prevents multiple allocation methods from sharing the same UCX memory type. cudaMallocAsync needs a separate allocator name while still using CUDA memory type metadata.

How?

  • Register allocators by explicit string name
  • Keep allocator registry data visible to perftest modules
  • Update perftest parsing/help/header paths to use allocator names
  • Implement the cuda-async allocator with cudaMallocAsync and cudaFreeAsync
  • Add a CUDA CI smoke test for it.

@tvegas1
tvegas1 requested a review from tomerg-nvidia June 23, 2026 13:58
Comment thread src/tools/perf/api/libperf.h Outdated
Comment on lines +278 to +281
char send_mem_alloc_name[UCX_PERF_ALLOC_NAME_MAX]; /* Send memory allocator
name */
char recv_mem_alloc_name[UCX_PERF_ALLOC_NAME_MAX]; /* Recv memory allocator
name */

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alignment/long lines

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread src/tools/perf/cuda/cuda_alloc.c Outdated
return UCS_OK;
}

static ucs_status_t uct_perf_cuda_alloc_reg_mem(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and in many other places you use uct_perf prefix, shouldn't it be ucx_perf?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread src/tools/perf/cuda/cuda_alloc.c Outdated
return status;
}

status = uct_perf_cuda_reg_mem(perf, length, UCS_MEMORY_TYPE_CUDA_MANAGED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it use the ASYNC_MEM_TYPE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would keep it for later pr

Comment thread src/tools/perf/cuda/cuda_alloc.c Outdated
#if CUDART_VERSION >= 11020
static ucx_perf_allocator_t cuda_async_allocator = {
.name = "cuda-async",
.mem_type = UCS_MEMORY_TYPE_CUDA_MANAGED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it use the ASYNC_MEM_TYPE

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would keep it for later pr

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it.

ucs_memory_type_t send_mem_type; /* Send memory type */
ucs_memory_type_t recv_mem_type; /* Recv memory type */
/* Send memory allocator name */
char send_mem_alloc_name[UCX_PERF_ALLOC_NAME_MAX];

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that breaks the 1:1 relationship between memory type and allocator. And this change is quite intrusive therefore.. Maybe it's enough just to add an environment variable to force async allocayion?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessarily, it just decouples memory type understood in UCX with allocation api. currently it is cuda-async, later there might be others, where memory type is still CUDA. so now we index by arg string to find allocator.

brminich
brminich previously approved these changes Jul 3, 2026
Comment thread src/tools/perf/cuda/cuda_alloc.c Outdated
}

status = ucx_perf_cuda_uct_reg_mem(perf, length,
UCS_MEMORY_TYPE_CUDA_MANAGED, flags,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why managed? Can we take it from alloc_mem? on grace we detect it as cuda

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment thread src/tools/perf/cuda/cuda_alloc.c Outdated
#if CUDART_VERSION >= 11020
static ucx_perf_allocator_t cuda_async_allocator = {
.name = "cuda-async",
.mem_type = UCS_MEMORY_TYPE_CUDA_MANAGED,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

@brminich
brminich dismissed their stale review July 3, 2026 12:11

approved by mistake

@tvegas1

tvegas1 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

also added cuda-alloc parameter

tvegas1 and others added 4 commits August 10, 2026 18:47
Honor UCX_CUDA_COPY_ASYNC_MEM_TYPE when selecting -m cuda-async instead of
hardcoding cuda-managed.
Route remaining default_mem_type call sites through the allocator resolve callback.
@tvegas1
tvegas1 merged commit e917453 into openucx:master Aug 27, 2026
161 checks passed
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

Successfully merging this pull request may close these issues.

4 participants