[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:
20
cccl_upstream/thrust/testing/cpp/CMakeLists.txt
Normal file
20
cccl_upstream/thrust/testing/cpp/CMakeLists.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
file(
|
||||
GLOB test_srcs
|
||||
RELATIVE "${CMAKE_CURRENT_LIST_DIR}"
|
||||
CONFIGURE_DEPENDS
|
||||
*.cu
|
||||
*.cpp
|
||||
)
|
||||
|
||||
foreach (thrust_target IN LISTS THRUST_TARGETS)
|
||||
thrust_get_target_property(config_device ${thrust_target} DEVICE)
|
||||
if (NOT config_device STREQUAL "CPP")
|
||||
continue()
|
||||
endif()
|
||||
|
||||
foreach (test_src IN LISTS test_srcs)
|
||||
get_filename_component(test_name "${test_src}" NAME_WLE)
|
||||
string(PREPEND test_name "cpp.")
|
||||
thrust_add_test(test_target ${test_name} "${test_src}" ${thrust_target})
|
||||
endforeach()
|
||||
endforeach()
|
||||
72
cccl_upstream/thrust/testing/cpp/adjacent_difference.cu
Normal file
72
cccl_upstream/thrust/testing/cpp/adjacent_difference.cu
Normal file
@@ -0,0 +1,72 @@
|
||||
#include <thrust/adjacent_difference.h>
|
||||
#include <thrust/device_free.h>
|
||||
#include <thrust/device_malloc.h>
|
||||
#include <thrust/execution_policy.h>
|
||||
|
||||
#include <unittest/unittest.h>
|
||||
|
||||
struct detect_wrong_difference
|
||||
{
|
||||
using difference_type = void;
|
||||
using value_type = long long;
|
||||
using pointer = void;
|
||||
using reference = detect_wrong_difference;
|
||||
using iterator_category = ::cuda::std::output_iterator_tag;
|
||||
|
||||
bool* flag;
|
||||
|
||||
_CCCL_HOST_DEVICE detect_wrong_difference operator++() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
_CCCL_HOST_DEVICE detect_wrong_difference operator*() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
template <typename Difference>
|
||||
_CCCL_HOST_DEVICE detect_wrong_difference operator+(Difference) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
template <typename Index>
|
||||
_CCCL_HOST_DEVICE detect_wrong_difference operator[](Index) const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
_CCCL_DEVICE void operator=(long long difference) const
|
||||
{
|
||||
if (difference != 1)
|
||||
{
|
||||
*flag = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void TestAdjacentDifferenceWithBigIndexesHelper(int magnitude)
|
||||
{
|
||||
thrust::counting_iterator<long long> begin(1);
|
||||
thrust::counting_iterator<long long> end = begin + (1ll << magnitude);
|
||||
ASSERT_EQUAL(::cuda::std::distance(begin, end), 1ll << magnitude);
|
||||
|
||||
thrust::device_ptr<bool> all_differences_correct = thrust::device_malloc<bool>(1);
|
||||
*all_differences_correct = true;
|
||||
|
||||
detect_wrong_difference out = {thrust::raw_pointer_cast(all_differences_correct)};
|
||||
|
||||
thrust::adjacent_difference(thrust::device, begin, end, out);
|
||||
|
||||
bool all_differences_correct_h = *all_differences_correct;
|
||||
thrust::device_free(all_differences_correct);
|
||||
|
||||
ASSERT_EQUAL(all_differences_correct_h, true);
|
||||
}
|
||||
|
||||
void TestAdjacentDifferenceWithBigIndexes()
|
||||
{
|
||||
TestAdjacentDifferenceWithBigIndexesHelper(30);
|
||||
TestAdjacentDifferenceWithBigIndexesHelper(31);
|
||||
TestAdjacentDifferenceWithBigIndexesHelper(32);
|
||||
TestAdjacentDifferenceWithBigIndexesHelper(33);
|
||||
}
|
||||
DECLARE_UNITTEST(TestAdjacentDifferenceWithBigIndexes);
|
||||
Reference in New Issue
Block a user