Ginkgo  Generated from pipelines/2969282958 branch based on develop. Ginkgo version 2.0.0
A numerical linear algebra library targeting many-core architectures
stream.hpp
1 // SPDX-FileCopyrightText: 2017 - 2026 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 
33  cuda_stream(int device_id, bool non_blocking = false);
34 
36  ~cuda_stream();
37 
38  cuda_stream(const cuda_stream&) = delete;
39 
41  cuda_stream(cuda_stream&&) noexcept;
42 
43  cuda_stream& operator=(const cuda_stream&) = delete;
44 
46  cuda_stream& operator=(cuda_stream&&) = delete;
47 
52  CUstream_st* get() const;
53 
54 private:
55  CUstream_st* stream_;
56 
57  int device_id_;
58 };
59 
60 
66 class hip_stream {
67 public:
69  hip_stream();
70 
79  hip_stream(int device_id, bool non_blocking = false);
80 
82  ~hip_stream();
83 
84  hip_stream(const hip_stream&) = delete;
85 
87  hip_stream(hip_stream&&) noexcept;
88 
89  hip_stream& operator=(const hip_stream&) = delete;
90 
92  hip_stream& operator=(hip_stream&&) = delete;
93 
98  GKO_HIP_STREAM_STRUCT* get() const;
99 
100 private:
101  GKO_HIP_STREAM_STRUCT* stream_;
102 
103  int device_id_;
104 };
105 
106 
107 } // namespace gko
108 
109 
110 #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:66
gko
The Ginkgo namespace.
Definition: abstract_factory.hpp:19
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.