Add example for memory reallocation on GPU - #789
Open
QingleiCao wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.