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
100 lines
2.5 KiB
C++
100 lines
2.5 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef MOVEONLY_H
|
|
#define MOVEONLY_H
|
|
|
|
#include <cuda/std/cstddef>
|
|
|
|
#include "test_macros.h"
|
|
// #include <functional>
|
|
|
|
class MoveOnly
|
|
{
|
|
int data_;
|
|
|
|
public:
|
|
TEST_FUNC constexpr MoveOnly(int data = 1)
|
|
: data_(data)
|
|
{}
|
|
|
|
MoveOnly(const MoveOnly&) = delete;
|
|
MoveOnly& operator=(const MoveOnly&) = delete;
|
|
|
|
TEST_FUNC constexpr MoveOnly(MoveOnly&& x)
|
|
: data_(x.data_)
|
|
{
|
|
x.data_ = 0;
|
|
}
|
|
TEST_FUNC constexpr MoveOnly& operator=(MoveOnly&& x)
|
|
{
|
|
data_ = x.data_;
|
|
x.data_ = 0;
|
|
return *this;
|
|
}
|
|
|
|
TEST_FUNC constexpr int get() const
|
|
{
|
|
return data_;
|
|
}
|
|
|
|
TEST_FUNC friend constexpr bool operator==(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ == y.data_;
|
|
}
|
|
TEST_FUNC friend constexpr bool operator!=(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ != y.data_;
|
|
}
|
|
TEST_FUNC friend constexpr bool operator<(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ < y.data_;
|
|
}
|
|
TEST_FUNC friend constexpr bool operator<=(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ <= y.data_;
|
|
}
|
|
TEST_FUNC friend constexpr bool operator>(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ > y.data_;
|
|
}
|
|
TEST_FUNC friend constexpr bool operator>=(const MoveOnly& x, const MoveOnly& y)
|
|
{
|
|
return x.data_ >= y.data_;
|
|
}
|
|
|
|
#if TEST_STD_VER > 2017 && _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
|
|
TEST_FUNC friend constexpr auto operator<=>(const MoveOnly&, const MoveOnly&) = default;
|
|
#endif // TEST_STD_VER > 2017 && _LIBCUDACXX_HAS_SPACESHIP_OPERATOR()
|
|
|
|
TEST_FUNC constexpr MoveOnly operator+(const MoveOnly& x) const
|
|
{
|
|
return MoveOnly(data_ + x.data_);
|
|
}
|
|
TEST_FUNC constexpr MoveOnly operator*(const MoveOnly& x) const
|
|
{
|
|
return MoveOnly(data_ * x.data_);
|
|
}
|
|
|
|
template <class T>
|
|
void operator,(T const&) = delete;
|
|
};
|
|
|
|
/*
|
|
template <>
|
|
struct cuda::std::hash<MoveOnly>
|
|
{
|
|
using argument_type = MoveOnly;
|
|
using result_type = size_t;
|
|
TEST_FUNC constexpr size_t operator()(const MoveOnly& x) const {return x.get();}
|
|
};
|
|
*/
|
|
|
|
#endif // MOVEONLY_H
|