39
39
#pragma once
40
40
#include " jet_defs.h"
41
41
#include " jet_config.h"
42
- #include " contract.hpp"
43
42
#include < sstream>
44
43
#include < string>
45
44
#include < iostream>
45
+ #include < fstream>
46
+ #include < iomanip>
46
47
47
48
namespace jet_partitioner {
48
49
@@ -53,7 +54,7 @@ bool load_config(jet_partitioner::config_t& c, const char* config_f) {
53
54
std::cerr << " FATAL ERROR: Could not open config file " << config_f << std::endl;
54
55
return false ;
55
56
}
56
- std::string lines[4 ];
57
+ std::string lines[5 ];
57
58
int reads = 0 ;
58
59
// you might think that reading in four lines from a simple config file could be done like:
59
60
// f >> c.coarsening_alg;
@@ -63,18 +64,19 @@ bool load_config(jet_partitioner::config_t& c, const char* config_f) {
63
64
// but that doesn't work if there are exactly 3 lines instead of 4 in the config file
64
65
// because if the last line is a float like 3.14, then c.num_iter will contain the 3
65
66
// and the c.max_imb_ratio will contain the .14
66
- for (int i = 0 ; i < 4 ; i++){
67
+ for (int i = 0 ; i < 5 ; i++){
67
68
if (f >> lines[i]) reads++;
68
69
}
69
70
f.close ();
70
- if (reads != 4 ){
71
+ if (reads < 4 ){
71
72
std::cerr << " FATAL ERROR: Config file has less than 4 lines" << std::endl;
72
73
return false ;
73
74
}
74
75
c.coarsening_alg = std::stoi (lines[0 ]);
75
76
c.num_parts = std::stoi (lines[1 ]);
76
77
c.num_iter = std::stoi (lines[2 ]);
77
78
c.max_imb_ratio = std::stod (lines[3 ]);
79
+ if (reads == 5 ) c.ultra_settings = std::stoi (lines[4 ]);
78
80
return true ;
79
81
}
80
82
@@ -241,70 +243,4 @@ part_vt load_part(ordinal_t n, const char *fname){
241
243
return part_d;
242
244
}
243
245
244
- // loads a sequence of coarse graphs and mappings between each graph from binary file
245
- // used to control for coarsening when experimenting with refinement
246
- std::list<typename jet_partitioner::contracter<matrix_t >::coarse_level_triple> load_coarse (){
247
- using coarse_level_triple = typename jet_partitioner::contracter<matrix_t >::coarse_level_triple;
248
- std::list<coarse_level_triple> levels;
249
- std::list<coarse_level_triple> error_levels;
250
- FILE* cgfp = fopen (" coarse_graphs.out" , " r" );
251
- int size = 0 ;
252
- if (fread (&size, sizeof (int ), 1 , cgfp) != 1 ) return error_levels;
253
- std::cout << " Importing " << size << " coarsened graphs" << std::endl;
254
- ordinal_t prev_n = 0 ;
255
- for (int i = 0 ; i < size; i++){
256
- coarse_level_triple level;
257
- level.level = i + 1 ;
258
- ordinal_t N = 0 ;
259
- if (fread (&N, sizeof (ordinal_t ), 1 , cgfp) != 1 ) return error_levels;
260
- edge_offset_t M = 0 ;
261
- if (fread (&M, sizeof (edge_offset_t ), 1 , cgfp) != 1 ) return error_levels;
262
- edge_vt rows (" rows" , N + 1 );
263
- auto rows_m = Kokkos::create_mirror_view (rows);
264
- if (fread (rows_m.data (), sizeof (edge_offset_t ), N + 1 , cgfp) != static_cast <size_t >(N + 1 )) return error_levels;
265
- Kokkos::deep_copy (rows, rows_m);
266
- vtx_vt entries (" entries" , M);
267
- auto entries_m = Kokkos::create_mirror_view (entries);
268
- if (fread (entries_m.data (), sizeof (ordinal_t ), M, cgfp) != static_cast <size_t >(M)) return error_levels;
269
- Kokkos::deep_copy (entries, entries_m);
270
- wgt_vt values (" values" , M);
271
- auto values_m = Kokkos::create_mirror_view (values);
272
- if (fread (values_m.data (), sizeof (value_t ), M, cgfp) != static_cast <size_t >(M)) return error_levels;
273
- Kokkos::deep_copy (values, values_m);
274
- graph_t graph (entries, rows);
275
- matrix_t g (" g" , N, values, graph);
276
- level.mtx = g;
277
- wgt_vt vtx_wgts (" vtx wgts" , N);
278
- auto vtx_wgts_m = Kokkos::create_mirror_view (vtx_wgts);
279
- if (fread (vtx_wgts_m.data (), sizeof (value_t ), N, cgfp) != static_cast <size_t >(N)) return error_levels;
280
- Kokkos::deep_copy (vtx_wgts, vtx_wgts_m);
281
- level.vtx_w = vtx_wgts;
282
- if (level.level > 1 ){
283
- vtx_vt i_entries (" entries" , prev_n);
284
- auto i_entries_m = Kokkos::create_mirror_view (i_entries);
285
- if (fread (i_entries_m.data (), sizeof (ordinal_t ), prev_n, cgfp) != static_cast <size_t >(prev_n)) return error_levels;
286
- Kokkos::deep_copy (i_entries, i_entries_m);
287
- typename jet_partitioner::contracter<matrix_t >::coarse_map i_g;
288
- i_g.coarse_vtx = N;
289
- i_g.map = i_entries;
290
- level.interp_mtx = i_g;
291
- }
292
- prev_n = N;
293
- levels.push_back (level);
294
- }
295
- fclose (cgfp);
296
- return levels;
297
- }
298
-
299
- // reads part from binary file
300
- part_vt load_coarse_part (ordinal_t n){
301
- FILE* cgfp = fopen (" coarse_part.out" , " r" );
302
- part_vt part (" part" , n);
303
- auto part_m = Kokkos::create_mirror_view (part);
304
- if (fread (part_m.data (), sizeof (part_t ), n, cgfp) != static_cast <size_t >(n)) return part;
305
- Kokkos::deep_copy (part, part_m);
306
- fclose (cgfp);
307
- return part;
308
- }
309
-
310
246
};
0 commit comments