forked from NVIDIA/cccl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreen_ctx_view.cuh
More file actions
77 lines (65 loc) · 1.86 KB
/
green_ctx_view.cuh
File metadata and controls
77 lines (65 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//===----------------------------------------------------------------------===//
//
// Part of CUDASTF in CUDA C++ Core Libraries,
// 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) 2022-2024 NVIDIA CORPORATION & AFFILIATES.
//
//===----------------------------------------------------------------------===//
#pragma once
#include <cuda/__cccl_config>
#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)
# pragma GCC system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)
# pragma clang system_header
#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)
# pragma system_header
#endif // no system header
/**
* @file
* @brief Implementation of green context views
*/
#include <cuda/experimental/__places/stream_pool.cuh>
#include <cuda/experimental/__stf/utility/hash.cuh>
#if _CCCL_CTK_AT_LEAST(12, 4)
namespace cuda::experimental::stf
{
// Green contexts are only supported since CUDA 12.4
/**
* @brief View of a green context and a pool of CUDA streams
*/
class green_ctx_view
{
public:
green_ctx_view(CUgreenCtx g_ctx, stream_pool pool, int devid)
: g_ctx(g_ctx)
, pool(mv(pool))
, devid(devid)
{}
CUgreenCtx g_ctx;
stream_pool pool;
int devid;
bool operator==(const green_ctx_view& other) const
{
return (g_ctx == other.g_ctx) && (devid == other.devid);
}
bool operator<(const green_ctx_view& other) const
{
if (g_ctx != other.g_ctx)
{
return g_ctx < other.g_ctx;
}
return devid < other.devid;
}
};
template <>
struct hash<cuda::experimental::stf::green_ctx_view>
{
::std::size_t operator()(const green_ctx_view& k) const
{
return hash_all(k.g_ctx, k.devid);
}
};
} // end namespace cuda::experimental::stf
#endif // _CCCL_CTK_AT_LEAST(12, 4)