-
Notifications
You must be signed in to change notification settings - Fork 480
[STF] use driver's memory pool for locality domains #11202
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
base: main
Are you sure you want to change the base?
Changes from all commits
195a05c
f654606
1910450
4b99fa3
ccc4c88
ee49cc1
5d82a46
e8ae090
99f145d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,7 @@ | |
| * outside of the task-based programming model. | ||
| */ | ||
|
|
||
| #include <cuda/experimental/__places/exec/locality_domain.cuh> | ||
| #include <cuda/experimental/__places/places.cuh> | ||
|
|
||
| #include <cstdio> | ||
|
|
@@ -182,13 +183,49 @@ void test_managed_allocation() | |
| printf(" Managed allocation test PASSED\n"); | ||
| } | ||
|
|
||
| // A locality-domain data place must never change the release-threshold policy | ||
| // of the process-global device default pool. That pool is shared with every | ||
| // other `cudaMallocAsync` user in the process, so retention there is not this | ||
| // place's decision to make — most visibly on machines with no locality | ||
| // domains, where the place degrades to whole-device memory and would | ||
| // otherwise be configuring a pool it does not own. (The domain's own default | ||
| // pool is a different location and is configured by the library-wide | ||
| // accessor.) | ||
| void test_device_default_pool_policy_untouched() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win important: Mark As per coding guidelines, “Functions must be marked with Source: Coding guidelines |
||
| { | ||
| printf("Testing that a locality-domain place leaves the device default pool alone...\n"); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this print, tests are silent |
||
|
|
||
| cudaMemPool_t default_pool; | ||
| cuda_try(cudaDeviceGetDefaultMemPool(&default_pool, 0)); | ||
| cuuint64_t before = 0; | ||
| cuda_try(cudaMemPoolGetAttribute(default_pool, cudaMemPoolAttrReleaseThreshold, &before)); | ||
|
|
||
| cudaStream_t stream; | ||
| cuda_try(cudaStreamCreate(&stream)); | ||
|
|
||
| auto place = data_place::locality_domain(0, 0); | ||
| const size_t n = size_t{1} << 20; | ||
| void* ptr = place.allocate(static_cast<::std::ptrdiff_t>(n), stream); | ||
| cuda_try(cudaStreamSynchronize(stream)); | ||
| place.deallocate(ptr, n, stream); | ||
| cuda_try(cudaStreamSynchronize(stream)); | ||
|
|
||
| cuuint64_t after = 0; | ||
| cuda_try(cudaMemPoolGetAttribute(default_pool, cudaMemPoolAttrReleaseThreshold, &after)); | ||
| EXPECT(before == after); | ||
|
|
||
| cuda_try(cudaStreamDestroy(stream)); | ||
| printf(" Device default pool policy test PASSED\n"); | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| printf("=== Testing data_place direct allocation (no context) ===\n\n"); | ||
|
|
||
| test_host_allocation(); | ||
| test_device_allocation(); | ||
| test_managed_allocation(); | ||
| test_device_default_pool_policy_untouched(); | ||
|
|
||
| printf("\n=== All tests PASSED ===\n"); | ||
| return 0; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 15780
🏁 Script executed:
Repository: NVIDIA/cccl
Length of output: 29842
important: Validate
view_.domain_idbefore narrowing it tounsigned char.data_place::locality_domain(view)accepts the token without validation, and the nativelocality_domain_data_place_impluses the localized path when domains are available. Fordomain_id = 256 + k, the cast wraps tok, somem_create()orallocate()can target the wrong domain. Preserve the separateCUresultand exception contracts.