Skip to content

Improve build time of OTBApplicationEngine

Stéphane Albert requested to merge 1649-application-engine-refactoring into develop

Summary

Optimize build time of the OTBApplicationEngine module.

Rationale

A conversion of TInputImage into TOutputImage via a otb::ClampImageFilter is needed in order to allow in-memory chaining of OTB-Applications such as for otb::Wrapper::CompositeApplication derived classes. This involves n² complexity template-instantiations (TInputImage × TOutputImage).

This complexity could be reduced to 2.n² by using a otb::VectorImage< double, 2 > as pivot, since the otb::ClampImageFilter<> already uses an in-place conversion to an internal std::vector< double > pixel-type.

This is part of story #1649 (closed).

Implementation Details

An otb::Wrapper::CastImage< TOutputImage, TInputImage > has been developed in order to factorize code between otb::Wrapper::InputImageParameter and otb::Wrapper::OutputImageParameter and linearize the n² complexity into an 2.n complexity of template instantiations, thus reducing build time. This private helper class also uses Template Meta-Programming in order to optimize the conversion pipeline in specific cases such as:

  1. TImageTypeTImageType
  2. DoubleVectorImageTypeTOutputImageType

Moreover, since the image-type set is finite and based on GDALDataType, some extern template statements have been added for all image-type to factorize code generation between all OTB-Application modules into the OTBApplicationEngine module.

Also, some macros have been used in order to simplify code maintenance of dynamic type switching.

Additional notes

The otb::Wrapper::Application class exposes template accessors such as ::GetParameterImage<>() and ::SetParameterOutputImage<>() which could be moved into private scopre since accessors for each GDALDataType-based image-types are provided. The latter are implemented using the former. This would also allow to move the otb::Wrapper::InputImageParameter::GetImage<>() function into OTBApplicationEngine module private scope, lightening module library weight (by not exporting lors of template instantiations).

The complex image-type versions of the conversion also uses a n² complexity of template instantiations and, since they are obsolete, they should be removed, which is done by !442 (merged).

Copyright

The copyright owner is CNES and has signed the ORFEO ToolBox Contributor License Agreement.


Check before merging:

  • All discussions are resolved
  • At least 2 👍 votes from core developers, no 👎 vote.
  • The feature branch is (reasonably) up-to-date with the base branch
  • Dashboard is green
  • Copyright owner has signed the ORFEO ToolBox Contributor License Agreement
Edited by Guillaume Pasero

Merge request reports