[INFRA] Import NVIDIA/CCCL upstream as optimization reference library
CCCL (CUDA C++ Core Libraries) provides: - CUB: device/block/warp-level GPU primitives (reduce, scan, sort, topk) - Thrust: high-level parallel algorithms (transform_reduce, sort, scan) - libcudacxx: CUDA C++ standard library (atomics, barriers, memory) - cudax: experimental features (memory resources, allocators) - Tuning policies: per-SM hardware-specific algorithm parameters Competition optimization vectors mapped to CCCL: - Output TPS (83% weight): warp_reduce, block_reduce, device_topk - Input TPS (14% weight): device_scan, block_load, prefetch - Cache TPS (3% weight): prefix caching strategy patterns - Memory (0.9 util): pooled/cached/buddy allocators Source: https://github.com/NVIDIA/cccl (shallow clone, HEAD only) License: Apache-2.0
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
libcudacxx_add_pretty_printer_test(
|
||||
NAME memory_resource
|
||||
SOURCES source.cu
|
||||
CASES
|
||||
# gersemi: off
|
||||
--case inspect_device 1 memory_resource.device device_resource
|
||||
--case inspect_host_device 1 memory_resource.host_device host_device_resource
|
||||
--case inspect_alias 1 memory_resource.alias aliased_resource
|
||||
# gersemi: on
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
=============== memory_resource.device begin ===============
|
||||
cuda::mr::any_resource<cuda::mr::device_accessible> @ <address>
|
||||
=============== memory_resource.device end ===============
|
||||
=============== memory_resource.host_device begin ===============
|
||||
cuda::mr::any_resource<cuda::mr::device_accessible, cuda::mr::host_accessible> @ <address>
|
||||
=============== memory_resource.host_device end ===============
|
||||
=============== memory_resource.alias begin ===============
|
||||
cuda::mr::any_resource<cuda::mr::device_accessible> @ <address>
|
||||
=============== memory_resource.alias end ===============
|
||||
@@ -0,0 +1,9 @@
|
||||
=============== memory_resource.device begin ===============
|
||||
(const device_resource_type) cuda::mr::any_resource<cuda::mr::device_accessible> @ <address>
|
||||
=============== memory_resource.device end ===============
|
||||
=============== memory_resource.host_device begin ===============
|
||||
(const host_device_resource_type) cuda::mr::any_resource<cuda::mr::device_accessible, cuda::mr::host_accessible> @ <address>
|
||||
=============== memory_resource.host_device end ===============
|
||||
=============== memory_resource.alias begin ===============
|
||||
(const resource_alias) cuda::mr::any_resource<cuda::mr::device_accessible> @ <address>
|
||||
=============== memory_resource.alias end ===============
|
||||
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
#include <cuda/memory_resource>
|
||||
|
||||
template <class T>
|
||||
[[gnu::noinline]] void keep_for_debugger(const T& value)
|
||||
{
|
||||
asm volatile("" : : "g"(&value) : "memory");
|
||||
}
|
||||
|
||||
using device_resource_type = cuda::mr::any_resource<cuda::mr::device_accessible>;
|
||||
using host_device_resource_type = cuda::mr::any_resource<cuda::mr::device_accessible, cuda::mr::host_accessible>;
|
||||
using resource_alias = device_resource_type;
|
||||
|
||||
[[gnu::noinline]] void inspect_device(const device_resource_type& resource)
|
||||
{
|
||||
keep_for_debugger(resource);
|
||||
}
|
||||
|
||||
[[gnu::noinline]] void inspect_host_device(const host_device_resource_type& resource)
|
||||
{
|
||||
keep_for_debugger(resource);
|
||||
}
|
||||
|
||||
[[gnu::noinline]] void inspect_alias(const resource_alias& resource)
|
||||
{
|
||||
keep_for_debugger(resource);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
using adapted_resource = cuda::mr::synchronous_resource_adapter<cuda::mr::legacy_managed_memory_resource>;
|
||||
const adapted_resource managed_resource{cuda::mr::legacy_managed_memory_resource{}};
|
||||
const device_resource_type device_resource{managed_resource};
|
||||
const host_device_resource_type host_device_resource{managed_resource};
|
||||
const resource_alias aliased_resource{managed_resource};
|
||||
|
||||
inspect_device(device_resource);
|
||||
inspect_host_device(host_device_resource);
|
||||
inspect_alias(aliased_resource);
|
||||
}
|
||||
Reference in New Issue
Block a user