@@ -160,14 +160,35 @@ void ArbLattice::readFromCxn(const std::string& cxn_path) {
160160 });
161161 for (size_t i = 0 ; i != labels.size (); ++i) label_to_ind_map.emplace (labels[i], i);
162162
163- // Nodes header
164- process_section (" NODES" , [&](size_t num_nodes_global) {
163+ // Optional CUTS section - check at the next word to see if it's CUTS or NODES
164+ bool has_cuts = false ;
165+ {
166+ file >> word;
167+ check_file_ok (" Failed to read section header: expected CUTS or NODES" );
168+ if (word == " CUTS" ) {
169+ size_t n_cuts{};
170+ file >> n_cuts;
171+ check_file_ok (" Failed to read CUTS size" );
172+ if (n_cuts != 26 ) throw std::logic_error (wrap_err_msg (" Expected CUTS 26, got CUTS " + std::to_string (n_cuts)));
173+ has_cuts = true ;
174+ file >> word;
175+ check_file_ok (" Failed to read section header: NODES" );
176+ }
177+ check_expected_word (" NODES" , word);
178+ }
179+
180+ // Nodes
181+ {
182+ size_t num_nodes_global{};
183+ file >> num_nodes_global;
184+ check_file_ok (" Failed to read section size: NODES" );
185+
165186 // Compute the current rank's offset and number of nodes to read
166187 const auto chunk_offsets = computeInitialNodeDist (num_nodes_global, static_cast <size_t >(comm_size));
167188 const auto chunk_begin = static_cast <size_t >(chunk_offsets[comm_rank]), chunk_end = static_cast <size_t >(chunk_offsets[comm_rank + 1 ]);
168189 const auto num_nodes_local = chunk_end - chunk_begin;
169190
170- connect = ArbLatticeConnectivity (chunk_begin, chunk_end, num_nodes_global, Q);
191+ connect = ArbLatticeConnectivity (chunk_begin, chunk_end, num_nodes_global, Q, has_cuts );
171192 connect.grid_size = grid_size;
172193
173194 // Skip chunk_begin + 1 (header) newlines
@@ -192,15 +213,17 @@ void ArbLattice::readFromCxn(const std::string& cxn_path) {
192213 auto & zone = connect.zones .emplace_back ();
193214 file >> zone;
194215 }
195-
196- for (size_t d = 0 ; d != 26 ; ++d) {
197- auto & cut = connect.cut_distance (d, local_node_ind);
198- file >> cut;
216+
217+ if (has_cuts) {
218+ for (size_t d = 0 ; d != 26 ; ++d) {
219+ auto & cut = connect.cut_distance (d, local_node_ind);
220+ file >> cut;
221+ }
199222 }
200223
201224 check_file_ok (" Failed to read node data" );
202225 }
203- });
226+ }
204227}
205228
206229void ArbLattice::partition () {
@@ -299,7 +322,11 @@ void ArbLattice::allocDeviceMemory() {
299322 sizes.coords_pitch = local_sz;
300323 coords_device = cudaMakeUnique2D<real_t >(sizes.coords_pitch , 3 );
301324 sizes.cuts_pitch = local_sz;
302- cut_distances_device = cudaMakeUnique2D<cut_t >(sizes.cuts_pitch , 26 );
325+ if (connect.has_cuts ) {
326+ cut_distances_device = cudaMakeUnique2D<cut_t >(sizes.cuts_pitch , 26 );
327+ } else {
328+ cut_distances_device.reset ();
329+ }
303330 sizes.snaps_pitch = local_sz + ghost_nodes.size () + 1 ;
304331 snaps_device = cudaMakeUnique2D<storage_t >(sizes.snaps_pitch , sizes.snaps * NF );
305332 node_types_device = cudaMakeUnique<flag_t >(local_sz);
@@ -411,8 +438,10 @@ void ArbLattice::initDeviceData(pugi::xml_node arb_node, const std::map<std::str
411438 copyVecToDeviceAsync (neighbors_device.get (), nbrs, inStream);
412439 const auto coords = computeCoords ();
413440 copyVecToDeviceAsync (coords_device.get (), coords, inStream);
414- const auto cuts = computeCutDistances ();
415- copyVecToDeviceAsync (cut_distances_device.get (), cuts, inStream);
441+ if (connect.has_cuts ) {
442+ const auto cuts = computeCutDistances ();
443+ copyVecToDeviceAsync (cut_distances_device.get (), cuts, inStream);
444+ }
416445 CudaStreamSynchronize (inStream);
417446}
418447
@@ -424,7 +453,7 @@ void ArbLattice::initContainer() {
424453#endif
425454 launcher.container .nbrs = neighbors_device.get ();
426455 launcher.container .coords = coords_device.get ();
427- launcher.container .Q = cut_distances_device.get ();
456+ launcher.container .Q = connect. has_cuts ? cut_distances_device.get () : nullptr ;
428457 launcher.container .cuts_pitch = sizes.cuts_pitch ;
429458 launcher.container .node_types = node_types_device.get ();
430459 launcher.container .nbrs_pitch = sizes.neighbors_pitch ;
0 commit comments