Reference documentation for deal.II version Git f40be01994 2020-04-09 07:13:12 +0200
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
task_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_matrix_free_task_info_h
18 #define dealii_matrix_free_task_info_h
19 
20 
21 #include <deal.II/base/config.h>
22 
23 #include <deal.II/base/exceptions.h>
24 #include <deal.II/base/index_set.h>
25 #include <deal.II/base/memory_consumption.h>
26 #include <deal.II/base/tensor.h>
27 #include <deal.II/base/thread_management.h>
28 #include <deal.II/base/utilities.h>
29 #include <deal.II/base/vectorization.h>
30 
31 #include <deal.II/lac/dynamic_sparsity_pattern.h>
32 
33 
34 DEAL_II_NAMESPACE_OPEN
35 
36 
37 
38 namespace internal
39 {
47  {
48  public:
49  virtual ~MFWorkerInterface() = default;
50 
52  virtual void
54 
56  virtual void
58 
60  virtual void
62 
64  virtual void
66 
69  virtual void
70  zero_dst_vector_range(const unsigned int range_index) = 0;
71 
72  virtual void
73  cell_loop_pre_range(const unsigned int range_index) = 0;
74 
75  virtual void
76  cell_loop_post_range(const unsigned int range_index) = 0;
77 
80  virtual void
81  cell(const std::pair<unsigned int, unsigned int> &cell_range) = 0;
82 
85  virtual void
86  face(const std::pair<unsigned int, unsigned int> &face_range) = 0;
87 
90  virtual void
91  boundary(const std::pair<unsigned int, unsigned int> &face_range) = 0;
92  };
93 
94 
95 
96  namespace MatrixFreeFunctions
97  {
98  // forward declaration of internal data structure
99  template <typename Number>
100  struct ConstraintValues;
101 
109  struct TaskInfo
110  {
111  // enum for choice of how to build the task graph. Odd add versions with
112  // preblocking and even versions with postblocking. partition_partition
113  // and partition_color are deprecated but kept for backward
114  // compatibility.
115  enum TasksParallelScheme
116  {
117  none,
118  partition_partition,
119  partition_color,
120  color
121  };
122 
126  TaskInfo();
127 
132  void
133  clear();
134 
138  void
139  loop(MFWorkerInterface &worker) const;
140 
145  void
146  collect_boundary_cells(const unsigned int n_active_cells,
147  const unsigned int n_active_and_ghost_cells,
148  const unsigned int vectorization_length,
149  std::vector<unsigned int> &boundary_cells);
150 
183  void
184  create_blocks_serial(
185  const std::vector<unsigned int> &boundary_cells,
186  const unsigned int dofs_per_cell,
187  const std::vector<unsigned int> &cell_vectorization_categories,
188  const bool cell_vectorization_categories_strict,
189  std::vector<unsigned int> & renumbering,
190  std::vector<unsigned char> & incompletely_filled_vectorization);
191 
209  void
210  initial_setup_blocks_tasks(
211  const std::vector<unsigned int> &boundary_cells,
212  std::vector<unsigned int> & renumbering,
213  std::vector<unsigned char> & incompletely_filled_vectorization);
214 
221  void
222  guess_block_size(const unsigned int dofs_per_cell);
223 
250  void
251  make_thread_graph_partition_color(
252  DynamicSparsityPattern & connectivity,
253  std::vector<unsigned int> & renumbering,
254  std::vector<unsigned char> &irregular_cells,
255  const bool hp_bool);
256 
289  void
290  make_thread_graph_partition_partition(
291  const std::vector<unsigned int> &cell_active_fe_index,
292  DynamicSparsityPattern & connectivity,
293  std::vector<unsigned int> & renumbering,
294  std::vector<unsigned char> & irregular_cells,
295  const bool hp_bool);
296 
320  void
321  make_thread_graph(const std::vector<unsigned int> &cell_active_fe_index,
322  DynamicSparsityPattern & connectivity,
323  std::vector<unsigned int> & renumbering,
324  std::vector<unsigned char> & irregular_cells,
325  const bool hp_bool);
326 
331  void
332  make_connectivity_cells_to_blocks(
333  const std::vector<unsigned char> &irregular_cells,
334  const DynamicSparsityPattern & connectivity_cells,
335  DynamicSparsityPattern & connectivity_blocks) const;
336 
341  void
342  make_coloring_within_partitions_pre_blocked(
343  const DynamicSparsityPattern & connectivity,
344  const unsigned int partition,
345  const std::vector<unsigned int> &cell_partition,
346  const std::vector<unsigned int> &partition_list,
347  const std::vector<unsigned int> &partition_size,
348  std::vector<unsigned int> & partition_color_list);
349 
354  void
355  make_partitioning_within_partitions_post_blocked(
356  const DynamicSparsityPattern & connectivity,
357  const std::vector<unsigned int> &cell_active_fe_index,
358  const unsigned int partition,
359  const unsigned int cluster_size,
360  const bool hp_bool,
361  const std::vector<unsigned int> &cell_partition,
362  const std::vector<unsigned int> &partition_list,
363  const std::vector<unsigned int> &partition_size,
364  std::vector<unsigned int> & partition_partition_list,
365  std::vector<unsigned char> & irregular_cells);
366 
387  void
388  make_partitioning(const DynamicSparsityPattern &connectivity,
389  const unsigned int cluster_size,
390  std::vector<unsigned int> & cell_partition,
391  std::vector<unsigned int> & partition_list,
392  std::vector<unsigned int> & partition_size,
393  unsigned int & partition) const;
394 
399  void
400  update_task_info(const unsigned int partition);
401 
405  void
406  create_flow_graph();
407 
411  std::size_t
412  memory_consumption() const;
413 
418  template <typename StreamType>
419  void
420  print_memory_statistics(StreamType &out, std::size_t data_length) const;
421 
426  unsigned int n_active_cells;
427 
432  unsigned int n_ghost_cells;
433 
437  unsigned int vectorization_length;
438 
442  unsigned int block_size;
443 
447  unsigned int n_blocks;
448 
452  TasksParallelScheme scheme;
453 
460  std::vector<unsigned int> partition_row_index;
461 
468  std::vector<unsigned int> cell_partition_data;
469 
477  std::vector<unsigned int> face_partition_data;
478 
486  std::vector<unsigned int> boundary_partition_data;
487 
496  std::vector<unsigned int> ghost_face_partition_data;
497 
507  std::vector<unsigned int> refinement_edge_face_partition_data;
508 
513  std::vector<unsigned int> partition_evens;
514 
519  std::vector<unsigned int> partition_odds;
520 
525  std::vector<unsigned int> partition_n_blocked_workers;
526 
531  std::vector<unsigned int> partition_n_workers;
532 
537  unsigned int evens;
538 
543  unsigned int odds;
544 
549  unsigned int n_blocked_workers;
550 
554  unsigned int n_workers;
555 
560  std::vector<unsigned char> task_at_mpi_boundary;
561 
565  MPI_Comm communicator;
566 
570  unsigned int my_pid;
571 
575  unsigned int n_procs;
576  };
577 
581  using SizeInfo DEAL_II_DEPRECATED = TaskInfo;
582 
583  } // end of namespace MatrixFreeFunctions
584 } // end of namespace internal
585 
586 DEAL_II_NAMESPACE_CLOSE
587 
588 #endif
std::vector< unsigned int > ghost_face_partition_data
Definition: task_info.h:496
void loop(ITERATOR begin, typename identity< ITERATOR >::type end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
Definition: loop.h:443
virtual void cell(const std::pair< unsigned int, unsigned int > &cell_range)=0
std::vector< unsigned int > partition_row_index
Definition: task_info.h:460
std::vector< unsigned int > partition_n_workers
Definition: task_info.h:531
virtual void vector_update_ghosts_finish()=0
Finishes the communication for the update ghost values operation.
std::vector< unsigned int > cell_partition_data
Definition: task_info.h:468
std::vector< unsigned int > partition_n_blocked_workers
Definition: task_info.h:525
std::vector< unsigned int > refinement_edge_face_partition_data
Definition: task_info.h:507
std::vector< unsigned int > boundary_partition_data
Definition: task_info.h:486
virtual void zero_dst_vector_range(const unsigned int range_index)=0
virtual void boundary(const std::pair< unsigned int, unsigned int > &face_range)=0
std::vector< unsigned char > task_at_mpi_boundary
Definition: task_info.h:560
virtual void vector_update_ghosts_start()=0
Starts the communication for the update ghost values operation.
virtual void face(const std::pair< unsigned int, unsigned int > &face_range)=0
std::vector< unsigned int > face_partition_data
Definition: task_info.h:477
virtual void vector_compress_start()=0
Starts the communication for the vector compress operation.
std::vector< unsigned int > partition_odds
Definition: task_info.h:519
std::vector< unsigned int > partition_evens
Definition: task_info.h:513
virtual void vector_compress_finish()=0
Finishes the communication for the vector compress operation.