Ginkgo  Generated from pipelines/1330831941 branch based on master. Ginkgo version 1.8.0
A numerical linear algebra library targeting many-core architectures
stream.hpp
1 // SPDX-FileCopyrightText: 2017 - 2024 The Ginkgo authors
2 //
3 // SPDX-License-Identifier: BSD-3-Clause
4 
5 #ifndef GKO_PUBLIC_CORE_BASE_STREAM_HPP_
6 #define GKO_PUBLIC_CORE_BASE_STREAM_HPP_
7 
8 
9 #include <ginkgo/core/base/executor.hpp>
10 
11 
12 namespace gko {
13 
14 
20 class cuda_stream {
21 public:
23  cuda_stream();
24 
30  cuda_stream(int device_id);
31 
33  ~cuda_stream();
34 
35  cuda_stream(const cuda_stream&) = delete;
36 
39 
40  cuda_stream& operator=(const cuda_stream&) = delete;
41 
43  cuda_stream& operator=(cuda_stream&&) = delete;
44 
49  CUstream_st* get() const;
50 
51 private:
52  CUstream_st* stream_;
53 
54  int device_id_;
55 };
56 
57 
63 class hip_stream {
64 public:
66  hip_stream();
67 
73  hip_stream(int device_id);
74 
76  ~hip_stream();
77 
78  hip_stream(const hip_stream&) = delete;
79 
82 
83  hip_stream& operator=(const hip_stream&) = delete;
84 
86  hip_stream& operator=(hip_stream&&) = delete;
87 
92  GKO_HIP_STREAM_STRUCT* get() const;
93 
94 private:
95  GKO_HIP_STREAM_STRUCT* stream_;
96 
97  int device_id_;
98 };
99 
100 
101 } // namespace gko
102 
103 
104 #endif // GKO_PUBLIC_CORE_BASE_STREAM_HPP_
gko::hip_stream::~hip_stream
~hip_stream()
Destroys the custom HIP stream, if it isn't empty.
gko::cuda_stream::~cuda_stream
~cuda_stream()
Destroys the custom CUDA stream, if it isn't empty.
gko::cuda_stream
An RAII wrapper for a custom CUDA stream.
Definition: stream.hpp:20
gko::hip_stream
An RAII wrapper for a custom HIP stream.
Definition: stream.hpp:63
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:20
gko::cuda_stream::get
CUstream_st * get() const
Returns the native CUDA stream handle.
gko::cuda_stream::cuda_stream
cuda_stream()
Creates an empty stream wrapper, representing the default stream.
gko::hip_stream::get
CUstream_st * get() const
Returns the native HIP stream handle.
gko::hip_stream::hip_stream
hip_stream()
Creates an empty stream wrapper, representing the default stream.