Skip to content

Add example for memory reallocation on GPU - #789

Open
QingleiCao wants to merge 1 commit into
ICLDisco:masterfrom
QingleiCao:qinglei/gpu_reallocation_example
Open

Add example for memory reallocation on GPU#789
QingleiCao wants to merge 1 commit into
ICLDisco:masterfrom
QingleiCao:qinglei/gpu_reallocation_example

Conversation

@QingleiCao

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 21, 2026 07:25
@QingleiCao
QingleiCao requested a review from a team as a code owner July 21, 2026 07:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new CUDA runtime example/test intended to demonstrate GPU tile “reallocation” and validate expected host-visible results after resizing.

Changes:

  • Introduces a new PTG/JDF taskgraph that reallocates a tile on GPU, updates original->span, and verifies values after D2H.
  • Adds a new C test driver that initializes PaRSEC, builds a 1-tile matrix, runs the taskpool, and reports pass/fail.
  • Hooks the new executable/JDF into the CUDA tests CMake build.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
tests/runtime/cuda/reallocate_tile_example.jdf New CUDA PTG example implementing GPU/CPU reallocation paths and a correctness check.
tests/runtime/cuda/reallocate_tile_example_main.c New driver to run the generated taskpool and report pass/fail/skip.
tests/runtime/cuda/CMakeLists.txt Builds the new test executable and generates sources from the new JDF.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +30 to +43
old_ptr = active_copy->device_private;
if( NULL != old_ptr ) {
zone_free(cuda_device->super.memory, old_ptr);
active_copy->device_private = NULL;
}

new_ptr = zone_malloc(cuda_device->super.memory, target_bytes);
if( NULL == new_ptr ) {
return -1;
}

active_copy->device_private = new_ptr;
*new_ptr_out = new_ptr;
return 0;
Comment on lines +124 to +133
c_copy->original->span = target_bytes;
if( NULL != cpu_copy ) {
new_cpu_stage_ptr = malloc(target_bytes);
if( NULL == new_cpu_stage_ptr ) {
*OUT = *OUT + 1;
fprintf(stderr, "TASK(%d): CPU stage buffer reallocation failed\n", k);
return PARSEC_HOOK_RETURN_DONE;
}
cpu_copy->device_private = new_cpu_stage_ptr;
}
Comment on lines +143 to +145
if( cudaSuccess != cudaMemcpyAsync(new_A, host_init, target_bytes,
cudaMemcpyHostToDevice, parsec_body.stream) ) {
*OUT = *OUT + 1;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#endif

parsec = parsec_init(1, &argc, &argv);
Comment on lines +43 to +51
if( 0 == parsec_context_query(parsec, PARSEC_CONTEXT_QUERY_DEVICES, PARSEC_DEV_CUDA) ) {
parsec_warning("reallocate_tile_example requires at least one CUDA device");
printf("TEST SKIPPED\n");
parsec_fini(&parsec);
#if defined(DISTRIBUTED)
MPI_Finalize();
#endif
return EXIT_SUCCESS;
}
Comment on lines +34 to +37
# Testing for GPU tile reallocation path used by HICMA runtime decision
parsec_addtest_executable(C reallocate_tile_example SOURCES "reallocate_tile_example_main.c")
target_include_directories(reallocate_tile_example PRIVATE $<$<NOT:${PARSEC_BUILD_INPLACE}>:${CMAKE_CURRENT_SOURCE_DIR}>)
target_ptg_sources(reallocate_tile_example PRIVATE "reallocate_tile_example.jdf")
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.

2 participants