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 <CL/sycl/accessor.hpp>
12 #include <CL/sycl/buffer.hpp>
14 #include <CL/sycl/handler.hpp>
16 #include <CL/sycl/range.hpp>
17 #include <CL/sycl/stream.hpp>
18 
19 #include <vector>
20 
22 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  void flush();
46 
47  size_t get_size() const;
48 
49  size_t get_max_statement_size() const;
50 
51  template <typename propertyT> bool has_property() const noexcept {
52  return PropList_.has_property<propertyT>();
53  }
54 
55  template <typename propertyT> propertyT get_property() const {
56  return PropList_.get_property<propertyT>();
57  }
58 
59 private:
60  // Size of the stream buffer
61  size_t BufferSize_;
62 
63  // Maximum number of symbols which could be streamed from the beginning of a
64  // statement till the semicolon
65  unsigned MaxStatementSize_;
66 
67  // Property list
68  property_list PropList_;
69 
70  // Additinonal memory is allocated in the beginning of the stream buffer for
71  // 2 variables: offset in the stream buffer and offset in the flush buffer.
72  static const size_t OffsetSize = 2 * sizeof(unsigned);
73 
74 };
75 
76 } // namespace detail
77 } // namespace sycl
78 } // __SYCL_INLINE_NAMESPACE(cl)
cl::sycl::detail::stream_impl
Definition: stream_impl.hpp:25
property_list.hpp
sycl
Definition: invoke_simd.hpp:68
cl::sycl::property_list
Objects of the property_list class are containers for the SYCL properties.
Definition: property_list.hpp:26
cl::sycl::detail::stream_impl::has_property
bool has_property() const noexcept
Definition: stream_impl.hpp:51
export.hpp
range.hpp
cl::sycl::accessor< char, 1, cl::sycl::access::mode::read_write, cl::sycl::access::target::global_buffer, cl::sycl::access::placeholder::false_t >
cl
We provide new interfaces for matrix muliply in this patch:
Definition: access.hpp:13
cl::sycl::handler
Command group handler class.
Definition: handler.hpp:361
accessor.hpp
handler.hpp
stream.hpp
buffer.hpp
cl::sycl::flush
constexpr stream_manipulator flush
Definition: stream.hpp:695
cl::sycl::detail::stream_impl::get_property
propertyT get_property() const
Definition: stream_impl.hpp:55
__SYCL_INLINE_NAMESPACE
#define __SYCL_INLINE_NAMESPACE(X)
Definition: defines_elementary.hpp:12