Skip to content
Snippets Groups Projects

WIP: Explicit template instantiation of YaspGrid

Closed Simon Praetorius requested to merge feature/explicit-template-instantiation into master
1 unresolved thread

Summary

Explicit template instantiation of YaspGrid for some common template parameters.

Details

Using explicit template instantiation could reduce the overall compile time of targets significantly. YaspGrid is one of the heavy templates used in several tests and in a lot of real applications. Some initial benchmarks of the compile time for the dune-grid tests showed an improvement of 25% to up to 80%. If this instantiation technique is extended to other grid types it does not only show code errors in the templates, the overall compile time can be reduced further.

Discussion

The YaspGrid class has some problem with explicit template instantiation. This is because of the static_assertions in the constructor of the class. A workaround could be to conditionally compile the constructors only and throw an exception instead of a static assertion. An alternative would be to deactivate constructor that do not belong to the class template parameters (i.e. the coordinate types)

Changes

  • Separate declaration from definition of many YaspGrid member functions. Therefore, I have introduced the implementation file yaspgrid/yaspgrid.impl.hh
  • Remove static_assert from constructors of YaspGrid and replace with DUNE_THROW (*).
  • Add Explicit template instantiation of YaspGrid<1, C>, YaspGrid<2, C>, YaspGrid<3, C>, for ctype=double and C the various coordinate times
  • Add explicit template instantiation of BackupRestore<YaspGrid<[...]>>

(*) This change is subject of discussion, see above.

Edited by Simon Praetorius

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #if HAVE_CONFIG_H
4 #include <config.h>
5 #endif
6
7 #include <dune/grid/yaspgrid.hh>
8
9 namespace Dune {
10
11 template class YaspGrid<2, EquidistantCoordinates<double, 2>>;
  • Suggested change
    11 template class YaspGrid<2, EquidistantCoordinates<double, 2>>;
    12 template class YaspGrid<3, EquidistantCoordinates<double, 3>>;
    13 template class YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>;
    14 template class YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>;
    15 template class YaspGrid<2, TensorProductCoordinates<double, 2>>;
    16 template class YaspGrid<3, TensorProductCoordinates<double, 3>>;
    11 template class YaspGrid<1, EquidistantCoordinates<double, 1>>;
    12 template class YaspGrid<2, EquidistantCoordinates<double, 2>>;
    13 template class YaspGrid<3, EquidistantCoordinates<double, 3>>;
    14 template class YaspGrid<1, EquidistantOffsetCoordinates<double, 1>>;
    15 template class YaspGrid<2, EquidistantOffsetCoordinates<double, 2>>;
    16 template class YaspGrid<3, EquidistantOffsetCoordinates<double, 3>>;
    17 template class YaspGrid<1, TensorProductCoordinates<double, 1>>;
    18 template class YaspGrid<2, TensorProductCoordinates<double, 2>>;
    19 template class YaspGrid<3, TensorProductCoordinates<double, 3>>;
  • Please register or sign in to reply
  • There were some indications that it is (unfortunately) in general not worth the compile-time improvement and the runtime can also be negatively influenced. Thus, I will withdraw my proposal.

  • Please register or sign in to reply
    Loading