Skip to content

Commit d684dfe

Browse files
committed
tmp: hypergraph line numbers
1 parent 6ef258e commit d684dfe

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

mt-kahypar/io/hypergraph_io.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ namespace mt_kahypar::io {
128128

129129
HyperedgeReadResult readHyperedges(char* mapped_file,
130130
size_t& pos,
131+
size_t& current_line,
131132
const size_t length,
132133
const HyperedgeID num_hyperedges,
133134
const bool has_hyperedge_weights,
@@ -149,7 +150,7 @@ namespace mt_kahypar::io {
149150
// Skip Comments
150151
ASSERT(pos < length);
151152
while ( mapped_file[pos] == '%' ) {
152-
goto_next_line(mapped_file, pos, length);
153+
goto_next_line(mapped_file, pos, current_line, length);
153154
ASSERT(pos < length);
154155
}
155156

@@ -161,7 +162,7 @@ namespace mt_kahypar::io {
161162
++res.num_removed_single_pin_hyperedges;
162163
}
163164
++current_num_hyperedges;
164-
goto_next_line(mapped_file, pos, length);
165+
goto_next_line(mapped_file, pos, current_line, length);
165166

166167
// If there are enough hyperedges in the current scanned range
167168
// we store that range, which will be later processed in parallel
@@ -195,6 +196,7 @@ namespace mt_kahypar::io {
195196
tbb::parallel_for(UL(0), hyperedge_ranges.size(), [&](const size_t i) {
196197
HyperedgeRange& range = hyperedge_ranges[i];
197198
size_t current_pos = range.start;
199+
size_t current_line = 0;
198200
const size_t current_end = range.end;
199201
HyperedgeID current_id = range.start_id;
200202
const HyperedgeID last_id = current_id + range.num_hyperedges;
@@ -203,33 +205,33 @@ namespace mt_kahypar::io {
203205
// Skip Comments
204206
ASSERT(current_pos < current_end);
205207
while ( mapped_file[current_pos] == '%' ) {
206-
goto_next_line(mapped_file, current_pos, current_end);
208+
goto_next_line(mapped_file, current_pos, current_line, current_end);
207209
ASSERT(current_pos < current_end);
208210
}
209211

210212
if ( !remove_single_pin_hes || !isSinglePinHyperedge(mapped_file, current_pos, current_end, has_hyperedge_weights) ) {
211213
ASSERT(current_id < hyperedges.size());
212214
if ( has_hyperedge_weights ) {
213-
hyperedges_weight[current_id] = read_number(mapped_file, current_pos, current_end);
215+
hyperedges_weight[current_id] = read_number(mapped_file, current_pos, current_line, current_end);
214216
}
215217

216218
Hyperedge& hyperedge = hyperedges[current_id];
217219
// Note, a hyperedge line must contain at least one pin
218-
HypernodeID pin = read_number(mapped_file, current_pos, current_end);
220+
HypernodeID pin = read_number(mapped_file, current_pos, current_line, current_end);
219221
ASSERT(pin > 0, V(current_id));
220222
hyperedge.push_back(pin - 1);
221223
while ( !is_line_ending(mapped_file, current_pos) ) {
222-
pin = read_number(mapped_file, current_pos, current_end);
224+
pin = read_number(mapped_file, current_pos, current_line, current_end);
223225
ASSERT(pin > 0, V(current_id));
224226
hyperedge.push_back(pin - 1);
225227
}
226-
do_line_ending(mapped_file, current_pos);
228+
do_line_ending(mapped_file, current_pos, current_line);
227229

228230
utils::deduplicateHyperedgePins(hyperedge, res.num_duplicated_pins, res.num_hes_with_duplicated_pins);
229231
ASSERT(hyperedge.size() >= 2);
230232
++current_id;
231233
} else {
232-
goto_next_line(mapped_file, current_pos, current_end);
234+
goto_next_line(mapped_file, current_pos, current_line, current_end);
233235
}
234236
}
235237
});
@@ -277,7 +279,7 @@ namespace mt_kahypar::io {
277279

278280
// Read Hyperedges
279281
HyperedgeReadResult res =
280-
readHyperedges(handle.mapped_file, pos, handle.length, num_hyperedges,
282+
readHyperedges(handle.mapped_file, pos, current_line, handle.length, num_hyperedges,
281283
has_hyperedge_weights, hyperedges, hyperedges_weight, remove_single_pin_hes);
282284
num_hyperedges -= res.num_removed_single_pin_hyperedges;
283285
num_removed_single_pin_hyperedges = res.num_removed_single_pin_hyperedges;
@@ -288,7 +290,7 @@ namespace mt_kahypar::io {
288290
}
289291

290292
// Read Hypernode Weights
291-
readHypernodeWeights(handle.mapped_file, pos, handle.length, num_hypernodes,
293+
readHypernodeWeights(handle.mapped_file, pos, current_line, handle.length, num_hypernodes,
292294
has_vertex_weights, hypernodes_weight);
293295

294296
// Check the end of the file

0 commit comments

Comments
 (0)