Reference documentation for deal.II version 9.0.0
task_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2018 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 at
12 // the top level of the deal.II distribution.
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/exceptions.h>
22 #include <deal.II/base/memory_consumption.h>
23 #include <deal.II/base/index_set.h>
24 #include <deal.II/base/utilities.h>
25 #include <deal.II/base/tensor.h>
26 #include <deal.II/base/thread_management.h>
27 #include <deal.II/base/vectorization.h>
28 #include <deal.II/lac/dynamic_sparsity_pattern.h>
29 
30 
31 DEAL_II_NAMESPACE_OPEN
32 
33 
34 
35 namespace internal
36 {
44  {
45  public:
46  virtual ~MFWorkerInterface() {}
47 
49  virtual void vector_update_ghosts_start() = 0;
50 
52  virtual void vector_update_ghosts_finish() = 0;
53 
55  virtual void vector_compress_start() = 0;
56 
58  virtual void vector_compress_finish() = 0;
59 
62  virtual void zero_dst_vector_range(const unsigned int range_index) = 0;
63 
66  virtual void cell(const std::pair<unsigned int,unsigned int> &cell_range) = 0;
67 
70  virtual void face(const std::pair<unsigned int,unsigned int> &face_range) = 0;
71 
74  virtual void boundary(const std::pair<unsigned int,unsigned int> &face_range) = 0;
75  };
76 
77 
78 
79  namespace MatrixFreeFunctions
80  {
81  // forward declaration of internal data structure
82  template <typename Number> struct ConstraintValues;
83 
91  struct TaskInfo
92  {
93  // enum for choice of how to build the task graph. Odd add versions with
94  // preblocking and even versions with postblocking. partition_partition
95  // and partition_color are deprecated but kept for backward
96  // compatibility.
97  enum TasksParallelScheme {none,
98  partition_partition,
99  partition_color,
100  color
101  };
102 
106  TaskInfo ();
107 
112  void clear ();
113 
117  void loop(MFWorkerInterface &worker) const;
118 
123  void collect_boundary_cells (const unsigned int n_active_cells,
124  const unsigned int n_active_and_ghost_cells,
125  const unsigned int vectorization_length,
126  std::vector<unsigned int> &boundary_cells);
127 
164  void
165  create_blocks_serial (const std::vector<unsigned int> &boundary_cells,
166  const std::vector<unsigned int> &cells_close_to_boundary,
167  const unsigned int dofs_per_cell,
168  const std::vector<unsigned int> &cell_vectorization_categories,
169  const bool cell_vectorization_categories_strict,
170  std::vector<unsigned int> &renumbering,
171  std::vector<unsigned char> &incompletely_filled_vectorization);
172 
190  void
191  initial_setup_blocks_tasks (const std::vector<unsigned int> &boundary_cells,
192  std::vector<unsigned int> &renumbering,
193  std::vector<unsigned char> &incompletely_filled_vectorization);
194 
201  void guess_block_size (const unsigned int dofs_per_cell);
202 
234  void
236  std::vector<unsigned int> &renumbering,
237  std::vector<unsigned char> &irregular_cells,
238  const bool hp_bool);
239 
272  void
273  make_thread_graph_partition_partition (const std::vector<unsigned int> &cell_active_fe_index,
274  DynamicSparsityPattern &connectivity,
275  std::vector<unsigned int> &renumbering,
276  std::vector<unsigned char> &irregular_cells,
277  const bool hp_bool);
278 
302  void
303  make_thread_graph (const std::vector<unsigned int> &cell_active_fe_index,
304  DynamicSparsityPattern &connectivity,
305  std::vector<unsigned int> &renumbering,
306  std::vector<unsigned char> &irregular_cells,
307  const bool hp_bool);
308 
314  (const std::vector<unsigned char> &irregular_cells,
315  const DynamicSparsityPattern &connectivity_cells,
316  DynamicSparsityPattern &connectivity_blocks) const;
317 
323  (const DynamicSparsityPattern &connectivity,
324  const unsigned int partition,
325  const std::vector<unsigned int> &cell_partition,
326  const std::vector<unsigned int> &partition_list,
327  const std::vector<unsigned int> &partition_size,
328  std::vector<unsigned int> &partition_color_list);
329 
335  (const DynamicSparsityPattern &connectivity,
336  const std::vector<unsigned int> &cell_active_fe_index,
337  const unsigned int partition,
338  const unsigned int cluster_size,
339  const bool hp_bool,
340  const std::vector<unsigned int> &cell_partition,
341  const std::vector<unsigned int> &partition_list,
342  const std::vector<unsigned int> &partition_size,
343  std::vector<unsigned int> &partition_partition_list,
344  std::vector<unsigned char> &irregular_cells);
345 
365  void
366  make_partitioning (const DynamicSparsityPattern &connectivity,
367  const unsigned int cluster_size,
368  std::vector<unsigned int> &cell_partition,
369  std::vector<unsigned int> &partition_list,
370  std::vector<unsigned int> &partition_size,
371  unsigned int &partition) const;
372 
377  void
378  update_task_info (const unsigned int partition);
379 
383  void create_flow_graph();
384 
388  std::size_t memory_consumption () const;
389 
394  template <typename StreamType>
395  void print_memory_statistics (StreamType &out,
396  std::size_t data_length) const;
397 
402  unsigned int n_active_cells;
403 
408  unsigned int n_ghost_cells;
409 
413  unsigned int vectorization_length;
414 
418  unsigned int block_size;
419 
423  unsigned int n_blocks;
424 
428  TasksParallelScheme scheme;
429 
436  std::vector<unsigned int> partition_row_index;
437 
444  std::vector<unsigned int> cell_partition_data;
445 
453  std::vector<unsigned int> face_partition_data;
454 
462  std::vector<unsigned int> boundary_partition_data;
463 
472  std::vector<unsigned int> ghost_face_partition_data;
473 
483  std::vector<unsigned int> refinement_edge_face_partition_data;
484 
489  std::vector<unsigned int> partition_evens;
490 
495  std::vector<unsigned int> partition_odds;
496 
501  std::vector<unsigned int> partition_n_blocked_workers;
502 
507  std::vector<unsigned int> partition_n_workers;
508 
513  unsigned int evens;
514 
519  unsigned int odds;
520 
525  unsigned int n_blocked_workers;
526 
530  unsigned int n_workers;
531 
536  std::vector<unsigned char> task_at_mpi_boundary;
537 
541  MPI_Comm communicator;
542 
546  unsigned int my_pid;
547 
551  unsigned int n_procs;
552  };
553 
557  DEAL_II_DEPRECATED
558  typedef TaskInfo SizeInfo;
559 
560  } // end of namespace MatrixFreeFunctions
561 } // end of namespace internal
562 
563 DEAL_II_NAMESPACE_CLOSE
564 
565 #endif
std::vector< unsigned int > ghost_face_partition_data
Definition: task_info.h:472
virtual void cell(const std::pair< unsigned int, unsigned int > &cell_range)=0
void loop(MFWorkerInterface &worker) const
Definition: task_info.cc:324
void guess_block_size(const unsigned int dofs_per_cell)
Definition: task_info.cc:945
std::vector< unsigned int > partition_row_index
Definition: task_info.h:436
std::vector< unsigned int > partition_n_workers
Definition: task_info.h:507
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:444
void make_connectivity_cells_to_blocks(const std::vector< unsigned char > &irregular_cells, const DynamicSparsityPattern &connectivity_cells, DynamicSparsityPattern &connectivity_blocks) const
Definition: task_info.cc:1345
std::vector< unsigned int > partition_n_blocked_workers
Definition: task_info.h:501
void make_partitioning_within_partitions_post_blocked(const DynamicSparsityPattern &connectivity, const std::vector< unsigned int > &cell_active_fe_index, const unsigned int partition, const unsigned int cluster_size, const bool hp_bool, const std::vector< unsigned int > &cell_partition, const std::vector< unsigned int > &partition_list, const std::vector< unsigned int > &partition_size, std::vector< unsigned int > &partition_partition_list, std::vector< unsigned char > &irregular_cells)
Definition: task_info.cc:1387
std::vector< unsigned int > refinement_edge_face_partition_data
Definition: task_info.h:483
void make_coloring_within_partitions_pre_blocked(const DynamicSparsityPattern &connectivity, const unsigned int partition, const std::vector< unsigned int > &cell_partition, const std::vector< unsigned int > &partition_list, const std::vector< unsigned int > &partition_size, std::vector< unsigned int > &partition_color_list)
Definition: task_info.cc:1678
void make_thread_graph_partition_color(DynamicSparsityPattern &connectivity, std::vector< unsigned int > &renumbering, std::vector< unsigned char > &irregular_cells, const bool hp_bool)
Definition: task_info.cc:975
void update_task_info(const unsigned int partition)
Definition: task_info.cc:1973
std::vector< unsigned int > boundary_partition_data
Definition: task_info.h:462
void initial_setup_blocks_tasks(const std::vector< unsigned int > &boundary_cells, std::vector< unsigned int > &renumbering, std::vector< unsigned char > &incompletely_filled_vectorization)
Definition: task_info.cc:886
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
void create_blocks_serial(const std::vector< unsigned int > &boundary_cells, const std::vector< unsigned int > &cells_close_to_boundary, const unsigned int dofs_per_cell, const std::vector< unsigned int > &cell_vectorization_categories, const bool cell_vectorization_categories_strict, std::vector< unsigned int > &renumbering, std::vector< unsigned char > &incompletely_filled_vectorization)
Definition: task_info.cc:701
std::vector< unsigned char > task_at_mpi_boundary
Definition: task_info.h:536
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:453
void collect_boundary_cells(const unsigned int n_active_cells, const unsigned int n_active_and_ghost_cells, const unsigned int vectorization_length, std::vector< unsigned int > &boundary_cells)
Definition: task_info.cc:630
void make_thread_graph_partition_partition(const std::vector< unsigned int > &cell_active_fe_index, DynamicSparsityPattern &connectivity, std::vector< unsigned int > &renumbering, std::vector< unsigned char > &irregular_cells, const bool hp_bool)
Definition: task_info.cc:1284
void make_partitioning(const DynamicSparsityPattern &connectivity, const unsigned int cluster_size, std::vector< unsigned int > &cell_partition, std::vector< unsigned int > &partition_list, std::vector< unsigned int > &partition_size, unsigned int &partition) const
Definition: task_info.cc:1752
virtual void vector_compress_start()=0
Starts the communication for the vector compress operation.
std::vector< unsigned int > partition_odds
Definition: task_info.h:495
std::size_t memory_consumption() const
Definition: task_info.cc:614
std::vector< unsigned int > partition_evens
Definition: task_info.h:489
void print_memory_statistics(StreamType &out, std::size_t data_length) const
Definition: task_info.cc:599
void make_thread_graph(const std::vector< unsigned int > &cell_active_fe_index, DynamicSparsityPattern &connectivity, std::vector< unsigned int > &renumbering, std::vector< unsigned char > &irregular_cells, const bool hp_bool)
Definition: task_info.cc:1110
virtual void vector_compress_finish()=0
Finishes the communication for the vector compress operation.