DPC++ Runtime
Runtime libraries for oneAPI DPC++
stream_impl.hpp
Go to the documentation of this file.
1 //==----------------- stream_impl.hpp - SYCL standard header file ----------==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #pragma once
10 
11 #include <sycl/accessor.hpp>
12 #include <sycl/buffer.hpp>
13 #include <sycl/detail/export.hpp>
14 #include <sycl/handler.hpp>
15 #include <sycl/property_list.hpp>
16 #include <sycl/range.hpp>
17 #include <sycl/stream.hpp>
18 
19 #include <vector>
20 
21 namespace sycl {
23 namespace detail {
24 
25 class __SYCL_EXPORT stream_impl {
26 public:
27  // TODO: This constructor is unused.
28  // To be removed when API/ABI changes are allowed.
29  stream_impl(size_t BufferSize, size_t MaxStatementSize, handler &CGH);
30 
31  stream_impl(size_t BufferSize, size_t MaxStatementSize,
32  const property_list &PropList);
33 
34  // Method to provide an access to the global stream buffer
35  GlobalBufAccessorT accessGlobalBuf(handler &CGH);
36 
37  // Method to provide an accessor to the global flush buffer
38  GlobalBufAccessorT accessGlobalFlushBuf(handler &CGH);
39 
40  // Method to provide an atomic access to the offset in the global stream
41  // buffer and offset in the flush buffer
42  GlobalOffsetAccessorT accessGlobalOffset(handler &CGH);
43 
44  // Enqueue task to copy stream buffer to the host and print the contents
45  // The host task event is then registered for post processing in the
46  // LeadEvent as well as in queue LeadEvent associated with.
47  void flush(const EventImplPtr &LeadEvent);
48 
49  // Enqueue task to copy stream buffer to the host and print the contents
50  // Remove during next ABI breaking window
51  void flush();
52 
53  size_t get_size() const;
54 
55  size_t get_max_statement_size() const;
56 
57  template <typename propertyT> bool has_property() const noexcept {
58  return PropList_.has_property<propertyT>();
59  }
60 
61  template <typename propertyT> propertyT get_property() const {
62  return PropList_.get_property<propertyT>();
63  }
64 
65 private:
66  // Size of the stream buffer
67  size_t BufferSize_;
68 
69  // Maximum number of symbols which could be streamed from the beginning of a
70  // statement till the semicolon
71  unsigned MaxStatementSize_;
72 
73  // Property list
74  property_list PropList_;
75 
76  // Additinonal memory is allocated in the beginning of the stream buffer for
77  // 2 variables: offset in the stream buffer and offset in the flush buffer.
78  static const size_t OffsetSize = 2 * sizeof(unsigned);
79 };
80 
81 } // namespace detail
82 } // __SYCL_INLINE_VER_NAMESPACE(_V1)
83 } // namespace sycl
The file contains implementations of accessor class.
propertyT get_property() const
Definition: stream_impl.hpp:61
bool has_property() const noexcept
Definition: stream_impl.hpp:57
Command group handler class.
Definition: handler.hpp:310
Objects of the property_list class are containers for the SYCL properties.
#define __SYCL_INLINE_VER_NAMESPACE(X)
std::shared_ptr< event_impl > EventImplPtr
Definition: cg.hpp:42
constexpr stream_manipulator flush
Definition: stream.hpp:694
---— Error handling, matching OpenCL plugin semantics.
Definition: access.hpp:14