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 {
22 inline namespace _V1 {
23 namespace detail {
24 
25 class stream_impl {
26 public:
27  stream_impl(size_t BufferSize, size_t MaxStatementSize,
28  const property_list &PropList);
29 
30  // Method to provide an access to the global stream buffer
32 
33  // Method to provide an accessor to the global flush buffer
35 
36  // Method to provide an atomic access to the offset in the global stream
37  // buffer and offset in the flush buffer
39 
40  size_t size() const noexcept;
41 
42  size_t get_work_item_buffer_size() const;
43 
44  void generateFlushCommand(handler &cgh);
45 
46  const property_list &getPropList() const { return PropList_; }
47 
48 private:
49  // Size of the stream buffer
50  size_t BufferSize_;
51 
52  // Maximum number of symbols which could be streamed from the beginning of a
53  // statement till the semicolon
54  unsigned MaxStatementSize_;
55 
56  // Property list
57  property_list PropList_;
58 
59  // It's fine to store the buffers in the stream_impl itself since the
60  // underlying buffer_impls are relased in a deferred manner by scheduler.
61  // Stream buffer
62  buffer<char, 1> Buf_;
63 
64  // Global flush buffer
65  buffer<char, 1> FlushBuf_;
66 
67  // Additinonal memory is allocated in the beginning of the stream buffer for
68  // 2 variables: offset in the stream buffer and offset in the flush buffer.
69  static const size_t OffsetSize = 2 * sizeof(unsigned);
70 };
71 
72 } // namespace detail
73 } // namespace _V1
74 } // namespace sycl
The file contains implementations of accessor class.
size_t get_work_item_buffer_size() const
Definition: stream_impl.cpp:65
stream_impl(size_t BufferSize, size_t MaxStatementSize, const property_list &PropList)
Definition: stream_impl.cpp:21
void generateFlushCommand(handler &cgh)
Definition: stream_impl.cpp:69
const property_list & getPropList() const
Definition: stream_impl.hpp:46
GlobalBufAccessorT accessGlobalFlushBuf(handler &CGH)
Definition: stream_impl.cpp:49
size_t size() const noexcept
Definition: stream_impl.cpp:63
GlobalOffsetAccessorT accessGlobalOffset(handler &CGH)
Definition: stream_impl.cpp:56
GlobalBufAccessorT accessGlobalBuf(handler &CGH)
Definition: stream_impl.cpp:43
Command group handler class.
Definition: handler.hpp:467
Objects of the property_list class are containers for the SYCL properties.
Definition: access.hpp:18
_Abi const simd< _Tp, _Abi > & noexcept
Definition: simd.hpp:1324