-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathtask_get_stream.cu
More file actions
65 lines (54 loc) · 1.51 KB
/
task_get_stream.cu
File metadata and controls
65 lines (54 loc) · 1.51 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
//===----------------------------------------------------------------------===//
//
// 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.
//
//===----------------------------------------------------------------------===//
//! \file
//!
//! \brief Test the behavior of the get_stream() method of the tasks in the different backends
#include <cuda/experimental/stf.cuh>
using namespace cuda::experimental::stf;
__global__ void dummy() {}
void test_stream()
{
// stream context
context ctx;
auto token = ctx.token();
EXPECT(token.is_void_interface());
auto t = ctx.task(token.write());
t.start();
cudaStream_t s = t.get_stream();
EXPECT(s != nullptr);
dummy<<<1, 1, 0, s>>>();
t.end();
ctx.finalize();
}
void test_graph()
{
context ctx = graph_ctx();
auto token = ctx.token();
auto t = ctx.task(token.write());
t.start();
cudaStream_t s = t.get_stream();
// We are not capturing so there is no stream associated
EXPECT(s == nullptr);
t.end();
auto t2 = ctx.task(token.rw());
t2.enable_capture();
t2.start();
cudaStream_t s2 = t2.get_stream();
// We are capturing so the stream used for capture is associated to the task
EXPECT(s2 != nullptr);
t2.end();
ctx.finalize();
}
int main()
{
test_stream();
test_graph();
return 0;
}