chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
11 / 15
73.3%
Branches:
19 / 44
43.2%
Functions:
1 / 1, 1 excl
100.0%

stage/views/mapping.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstdint>
5 #include <memory>
6
7 #include <dlpack/dlpack.h>
8
9 #include "chrono_batch_render/device/operation.h"
10 #include "chrono_batch_render/device/stream.h"
11 #include "chrono_batch_render/device/tensor.h"
12 #include "chrono_batch_render/export.h"
13 #include "chrono_batch_render/stage/schema/schema.h"
14
15 namespace chrono::batch_render {
16
17 class ViewState;
18
19 enum class MapAccess : uint8_t { Read, Write, ReadWrite };
20
21 class CHRONO_BATCH_RENDER_API Mapping {
22 public:
23
3/5
✓ Branch 1 taken 33 times.
✓ Branch 4 taken 33 times.
✓ Branch 7 taken 33 times.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
33 Mapping() = default;
24 Mapping(const Mapping&) = delete;
25 Mapping& operator=(const Mapping&) = delete;
26 Mapping(Mapping&& other) noexcept;
27 Mapping& operator=(Mapping&& other) noexcept;
28 ~Mapping();
29
30 3 bool Open() const {
31
2/8
✗ Branch 0 not taken.
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
3 return m_open;
32 }
33
34 MapAccess Access() const {
35 return m_access;
36 }
37
38 7 bool Aliased() const {
39
7/18
<unknown function 30>:
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
✗ Branch 2 not taken.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✓ Branch 5 taken 1 time.
✗ Branch 6 not taken.
✓ Branch 7 taken 1 time.
✗ Branch 8 not taken.
✓ Branch 9 taken 1 time.
✗ Branch 10 not taken.
✓ Branch 11 taken 1 time.
✗ Branch 12 not taken.
✓ Branch 13 taken 1 time.
chrono::batch_render::Mapping::Mapping():
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
7 return m_aliased;
40 }
41
42 23 const device::Tensor& Values() const {
43
6/9
<unknown function 30>:
✓ Branch 1 taken 1 time.
✓ Branch 4 taken 1 time.
✓ Branch 7 taken 1 time.
✓ Branch 10 taken 1 time.
✓ Branch 13 taken 1 time.
chrono::batch_render::Mapping::Mapping():
✓ Branch 1 taken 14 times.
✗ Branch 1 not taken.
✗ Branch 4 not taken.
✗ Branch 7 not taken.
22 return m_values;
44 }
45
46 ✗ const device::Tensor& Rows() const {
47
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ return m_rows;
48 }
49
50 1 const device::Tensor& Offsets() const {
51
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 time.
1 return m_offsets;
52 }
53
54 const device::Operation& Ready() const {
55 return m_ready;
56 }
57
58 DLTensor DLPack() const {
59 return m_values.DLPack();
60 }
61
62 device::Operation Close(Stream producer = Stream::None(), const DLTensor* mask = nullptr);
63
64 private:
65 friend class UntypedAttribute;
66
67 void Release() noexcept;
68
69 std::shared_ptr<ViewState> m_view;
70 ColumnRef m_column;
71 MapAccess m_access = MapAccess::Read;
72 device::Tensor m_values;
73 device::Tensor m_rows;
74 device::Tensor m_offsets;
75 device::Operation m_ready;
76 bool m_aliased = false;
77 bool m_open = false;
78 };
79
80 }
81