From: Wolfgang Bangerth Date: Tue, 29 Nov 2022 22:58:05 +0000 (-0700) Subject: Run the different parts of creating VTU output in parallel. X-Git-Tag: v9.5.0-rc1~770^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F14504%2Fhead;p=dealii.git Run the different parts of creating VTU output in parallel. --- diff --git a/source/base/data_out_base.cc b/source/base/data_out_base.cc index 91d543a33e..4ebd411073 100644 --- a/source/base/data_out_base.cc +++ b/source/base/data_out_base.cc @@ -6670,23 +6670,22 @@ namespace DataOutBase return create_global_data_table(patches); }); - out << "\n"; - - //----------------------------- - out << stringize_vertex_information(); - out << stringize_cell_to_vertex_information(); - out << stringize_cell_offset_and_type_information(); - - // For what follows, we have to have the reordered data available: + // ----------------------------- + // Now finally get around to actually doing anything. Let's start with + // running the first three tasks generating the vertex and cell information: + Threads::TaskGroup mesh_tasks; + mesh_tasks += Threads::new_task(stringize_vertex_information); + mesh_tasks += Threads::new_task(stringize_cell_to_vertex_information); + mesh_tasks += Threads::new_task(stringize_cell_offset_and_type_information); + + // For what follows, we have to have the reordered data available. So wait + // for that task to conclude and get the resulting data table: const Table<2, float> data_vectors = std::move(*create_global_data_table_task.return_value()); - // then write data. the 'POINT_DATA' means: node data (as opposed to cell - // data, which we do not support explicitly here). all following data sets - // are point data - out << " \n"; - + // Then create the strings for the actual values of the solution vectors, + // again on separate tasks: + Threads::TaskGroup data_tasks; // When writing, first write out all vector and tensor data std::vector data_set_handled(n_data_sets, false); for (const auto &range : nonscalar_data_ranges) @@ -6697,19 +6696,30 @@ namespace DataOutBase for (unsigned int i = first_component; i <= last_component; ++i) data_set_handled[i] = true; - out << stringize_nonscalar_data_range(data_vectors, range); + data_tasks += Threads::new_task([&, range]() { + return stringize_nonscalar_data_range(data_vectors, range); + }); } // Now do the left over scalar data sets for (unsigned int data_set = 0; data_set < n_data_sets; ++data_set) if (data_set_handled[data_set] == false) { - out << stringize_scalar_data_set(data_vectors, data_set); + data_tasks += Threads::new_task([&, data_set]() { + return stringize_scalar_data_set(data_vectors, data_set); + }); } + // Alright, all tasks are now running. Wait for their conclusion and output + // all of the data they have produced: + out << "\n"; + for (const auto &s : mesh_tasks.return_values()) + out << s; + out << " \n"; + for (const auto &s : data_tasks.return_values()) + out << s; out << " \n"; - - // Finish up writing a valid XML file out << " \n"; // make sure everything now gets to disk