• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daisytuner / docc / 26463753889

26 May 2026 05:18PM UTC coverage: 60.864% (-0.02%) from 60.886%
26463753889

Pull #719

github

web-flow
Merge 0b90ddd88 into 707dadcf8
Pull Request #719: Libnode ptr edges

961 of 1749 new or added lines in 52 files covered. (54.95%)

90 existing lines in 29 files now uncovered.

35222 of 57870 relevant lines covered (60.86%)

11043.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.74
/opt/src/transformations/offloading/cuda_transform.cpp
1
#include "sdfg/transformations/offloading/cuda_transform.h"
2

3
#include <unordered_set>
4

5
#include "sdfg/structured_control_flow/block.h"
6
#include "sdfg/targets/cuda/cuda_data_offloading_node.h"
7
#include "sdfg/transformations/transformation.h"
8
#include "symengine/symengine_rcp.h"
9

10
namespace sdfg {
11
namespace cuda {
12

13
std::string CUDATransform::name() const { return "CUDATransform"; }
3✔
14

15
void CUDATransform::add_device_buffer(
16
    builder::StructuredSDFGBuilder& builder,
17
    std::string host_arg_name,
18
    std::string device_arg_name,
19
    symbolic::Expression arg_size
20
) {
3✔
21
    // Allocate device pointer
22
    auto& sdfg = builder.subject();
3✔
23
    auto& type = sdfg.type(host_arg_name);
3✔
24
    auto new_type = type.clone();
3✔
25
    new_type->storage_type(global_device_storage_type(arg_size));
3✔
26
    builder.add_container(device_arg_name, *new_type);
3✔
27
}
3✔
28

29
void CUDATransform::allocate_device_arg(
30
    builder::StructuredSDFGBuilder& builder,
31
    Block& alloc_block,
32
    std::string host_arg_name,
33
    std::string device_arg_name,
34
    symbolic::Expression arg_size,
35
    symbolic::Expression page_size
36
) {
×
37
    auto& sdfg = builder.subject();
×
38
    if (!builder.subject().exists(device_arg_name)) {
×
39
        auto& type = sdfg.type(host_arg_name);
×
40
        auto new_type = type.clone();
×
41
        new_type->storage_type(global_device_storage_type(arg_size));
×
42
        new_type->storage_type().allocation(types::StorageType::AllocationType::Unmanaged);
×
43
        new_type->storage_type().deallocation(types::StorageType::AllocationType::Unmanaged);
×
44
        new_type->storage_type().allocation_size(SymEngine::null);
×
45

46
        std::unordered_set<std::string> container_set(sdfg.containers().begin(), sdfg.containers().end());
×
47
        if (container_set.find(device_arg_name) == container_set.end()) {
×
48
            builder.add_container(device_arg_name, *new_type);
×
49
        }
×
50
    }
×
51

NEW
52
    auto& out_type = builder.subject().type(device_arg_name);
×
53

NEW
54
    offloading::add_offloading_node<CUDADataOffloadingNode>(
×
NEW
55
        builder,
×
56
        alloc_block,
×
NEW
57
        host_arg_name,
×
NEW
58
        device_arg_name,
×
NEW
59
        offloading::DataTransferDirection::NONE,
×
NEW
60
        offloading::BufferLifecycle::ALLOC,
×
NEW
61
        out_type,
×
NEW
62
        out_type,
×
63
        this->map_.debug_info(),
×
64
        arg_size,
×
NEW
65
        symbolic::zero()
×
66
    );
×
UNCOV
67
}
×
68

69
void CUDATransform::deallocate_device_arg(
70
    builder::StructuredSDFGBuilder& builder,
71
    Block& dealloc_block,
72
    std::string device_arg_name,
73
    symbolic::Expression arg_size,
74
    symbolic::Expression page_size
75
) {
×
NEW
76
    auto& free_type = builder.subject().type(device_arg_name);
×
NEW
77
    offloading::add_offloading_node<CUDADataOffloadingNode>(
×
NEW
78
        builder,
×
79
        dealloc_block,
×
NEW
80
        device_arg_name,
×
NEW
81
        device_arg_name,
×
NEW
82
        offloading::DataTransferDirection::NONE,
×
NEW
83
        offloading::BufferLifecycle::FREE,
×
NEW
84
        free_type,
×
NEW
85
        free_type,
×
86
        this->map_.debug_info(),
×
87
        arg_size,
×
NEW
88
        symbolic::zero()
×
89
    );
×
UNCOV
90
}
×
91

92
void CUDATransform::copy_to_device(
93
    builder::StructuredSDFGBuilder& builder,
94
    const std::string host_arg_name,
95
    std::string device_arg_name,
96
    symbolic::Expression size,
97
    symbolic::Expression page_size,
98
    Block& copy_block
99
) {
×
NEW
100
    offloading::add_offloading_node<CUDADataOffloadingNode>(
×
NEW
101
        builder,
×
102
        copy_block,
×
NEW
103
        host_arg_name,
×
NEW
104
        device_arg_name,
×
NEW
105
        offloading::DataTransferDirection::H2D,
×
NEW
106
        offloading::BufferLifecycle::NO_CHANGE,
×
NEW
107
        builder.subject().type(host_arg_name),
×
NEW
108
        builder.subject().type(device_arg_name),
×
109
        this->map_.debug_info(),
×
110
        size,
×
NEW
111
        symbolic::integer(0)
×
112
    );
×
UNCOV
113
}
×
114

115
void CUDATransform::copy_to_device_with_allocation(
116
    builder::StructuredSDFGBuilder& builder,
117
    const std::string host_arg_name,
118
    std::string device_arg_name,
119
    symbolic::Expression size,
120
    symbolic::Expression page_size,
121
    Block& copy_block
122
) {
4✔
123
    offloading::add_offloading_node<CUDADataOffloadingNode>(
4✔
124
        builder,
4✔
125
        copy_block,
4✔
126
        host_arg_name,
4✔
127
        device_arg_name,
4✔
128
        offloading::DataTransferDirection::H2D,
4✔
129
        offloading::BufferLifecycle::ALLOC,
4✔
130
        builder.subject().type(host_arg_name),
4✔
131
        builder.subject().type(device_arg_name),
4✔
132
        this->map_.debug_info(),
4✔
133
        size,
4✔
134
        symbolic::integer(0)
4✔
135
    );
4✔
136
}
4✔
137

138
void CUDATransform::copy_from_device(
139
    builder::StructuredSDFGBuilder& builder,
140
    Block& copy_out_block,
141
    const std::string host_arg_name,
142
    std::string device_arg_name,
143
    symbolic::Expression size,
144
    symbolic::Expression page_size
145
) {
×
NEW
146
    offloading::add_offloading_node<CUDADataOffloadingNode>(
×
NEW
147
        builder,
×
148
        copy_out_block,
×
NEW
149
        host_arg_name,
×
NEW
150
        device_arg_name,
×
NEW
151
        offloading::DataTransferDirection::D2H,
×
NEW
152
        offloading::BufferLifecycle::NO_CHANGE,
×
NEW
153
        builder.subject().type(host_arg_name),
×
NEW
154
        builder.subject().type(device_arg_name),
×
155
        this->map_.debug_info(),
×
156
        size,
×
NEW
157
        symbolic::integer(0)
×
158
    );
×
UNCOV
159
}
×
160

161
void CUDATransform::copy_from_device_with_free(
162
    builder::StructuredSDFGBuilder& builder,
163
    Block& copy_out_block,
164
    const std::string host_arg_name,
165
    std::string device_arg_name,
166
    symbolic::Expression size,
167
    symbolic::Expression page_size
168
) {
4✔
169
    offloading::add_offloading_node<CUDADataOffloadingNode>(
4✔
170
        builder,
4✔
171
        copy_out_block,
4✔
172
        host_arg_name,
4✔
173
        device_arg_name,
4✔
174
        offloading::DataTransferDirection::D2H,
4✔
175
        offloading::BufferLifecycle::FREE,
4✔
176
        builder.subject().type(host_arg_name),
4✔
177
        builder.subject().type(device_arg_name),
4✔
178
        this->map_.debug_info(),
4✔
179
        size,
4✔
180
        symbolic::integer(0)
4✔
181
    );
4✔
182
}
4✔
183

184
void CUDATransform::to_json(nlohmann::json& j) const {
1✔
185
    std::string loop_type;
1✔
186
    if (dynamic_cast<structured_control_flow::Map*>(&map_)) {
1✔
187
        loop_type = "map";
1✔
188
    } else {
1✔
189
        throw std::runtime_error("Unsupported loop type for serialization of loop: " + map_.indvar()->get_name());
×
190
    }
×
191

192
    j["transformation_type"] = this->name();
1✔
193
    j["subgraph"] = {{"0", {{"element_id", this->map_.element_id()}, {"type", loop_type}}}};
1✔
194
    j["parameters"] = {{"block_size", block_size_}};
1✔
195
};
1✔
196

197
CUDATransform CUDATransform::from_json(builder::StructuredSDFGBuilder& builder, const nlohmann::json& desc) {
1✔
198
    auto loop_id = desc["subgraph"]["0"]["element_id"].get<size_t>();
1✔
199
    size_t block_size = desc["parameters"]["block_size"].get<size_t>();
1✔
200
    auto element = builder.find_element_by_id(loop_id);
1✔
201
    if (!element) {
1✔
202
        throw transformations::
×
203
            InvalidTransformationDescriptionException("Element with ID " + std::to_string(loop_id) + " not found.");
×
204
    }
×
205
    auto map = dynamic_cast<structured_control_flow::Map*>(element);
1✔
206

207
    return CUDATransform(*map, block_size);
1✔
208
};
1✔
209

210

211
} // namespace cuda
212
} // namespace sdfg
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc