Files
project_6/cccl_upstream/thrust/testing/mr_new.cu
EngineX CI 56fd68e7dd [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
2026-07-30 09:35:51 +00:00

38 lines
1.2 KiB
Plaintext

#include <thrust/fill.h>
#include <thrust/mr/new.h>
#include <unittest/unittest.h>
template <typename MemoryResource>
void TestAlignment(MemoryResource memres, std::size_t size, std::size_t alignment)
{
void* ptr = memres.do_allocate(size, alignment);
ASSERT_EQUAL(reinterpret_cast<std::size_t>(ptr) % alignment, 0u);
char* char_ptr = reinterpret_cast<char*>(ptr);
thrust::fill(char_ptr, char_ptr + size, char{});
memres.do_deallocate(ptr, size, alignment);
}
static const std::size_t MinTestedSize = 32;
static const std::size_t MaxTestedSize = 8 * 1024;
static const std::size_t TestedSizeStep = 1;
static const std::size_t MinTestedAlignment = 16;
static const std::size_t MaxTestedAlignment = 4 * 1024;
static const std::size_t TestedAlignmentShift = 1;
void TestNewDeleteResourceAlignedAllocation()
{
for (std::size_t size = MinTestedSize; size <= MaxTestedSize; size += TestedSizeStep)
{
for (std::size_t alignment = MinTestedAlignment; alignment <= MaxTestedAlignment;
alignment <<= TestedAlignmentShift)
{
TestAlignment(thrust::mr::new_delete_resource(), size, alignment);
}
}
}
DECLARE_UNITTEST(TestNewDeleteResourceAlignedAllocation);