| 261 | } |
| 262 | |
| 263 | void image_data_reader::do_preload_data_store() |
| 264 | { |
| 265 | auto& arg_parser = global_argument_parser(); |
| 266 | |
| 267 | int rank = m_comm->get_rank_in_trainer(); |
| 268 | |
| 269 | bool threaded = !arg_parser.get<bool>(LBANN_OPTION_DATA_STORE_NO_THREAD); |
| 270 | if (threaded) { |
| 271 | if (get_comm()->am_world_master()) { |
| 272 | std::cout << "mode: data_store_thread\n"; |
| 273 | } |
| 274 | std::shared_ptr<thread_pool> io_thread_pool = |
| 275 | construct_io_thread_pool(m_comm, false); |
| 276 | int num_threads = static_cast<int>(io_thread_pool->get_num_threads()); |
| 277 | |
| 278 | std::vector<std::unordered_set<int>> data_ids(num_threads); |
| 279 | int j = 0; |
| 280 | for (size_t data_id = 0; data_id < m_shuffled_indices.size(); data_id++) { |
| 281 | int index = m_shuffled_indices[data_id]; |
| 282 | if (m_data_store->get_index_owner(index) != rank) { |
| 283 | continue; |
| 284 | } |
| 285 | data_ids[j++].insert(index); |
| 286 | if (j == num_threads) { |
| 287 | j = 0; |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | for (int t = 0; t < num_threads; t++) { |
| 292 | if (t == io_thread_pool->get_local_thread_id()) { |
| 293 | continue; |
| 294 | } |
| 295 | else { |
| 296 | io_thread_pool->submit_job_to_work_group( |
| 297 | std::bind(&image_data_reader::load_conduit_nodes_from_file, |
| 298 | this, |
| 299 | data_ids[t])); |
| 300 | } |
| 301 | } |
| 302 | load_conduit_nodes_from_file( |
| 303 | data_ids[io_thread_pool->get_local_thread_id()]); |
| 304 | io_thread_pool->finish_work_group(); |
| 305 | } |
| 306 | else { |
| 307 | if (get_comm()->am_world_master()) { |
| 308 | std::cout << "mode: NOT data_store_thread\n"; |
| 309 | } |
| 310 | for (size_t data_id = 0; data_id < m_shuffled_indices.size(); data_id++) { |
| 311 | int index = m_shuffled_indices[data_id]; |
| 312 | if (m_data_store->get_index_owner(index) != rank) { |
| 313 | continue; |
| 314 | } |
| 315 | conduit::Node& node = m_data_store->get_empty_node(index); |
| 316 | load_conduit_node_from_file(index, node); |
| 317 | m_data_store->set_preloaded_conduit_node(index, node); |
| 318 | } |
| 319 | } |
| 320 | } |
nothing calls this directly
no test coverage detected