Parallelizing NavData Generation

The NavData generation system is designed to be fast enough that generation times should not represent a problem for your production workflow or pipeline, even on large terrains. However, it could always be faster! To this end, the system offers the ability to run parts of the generation process in parallel on multiple processors.

Gameware Navigation provides built-in support for generating NavData on multiple cores of the host machine, through the use of the open-source Threaded Building Blocks (TBB) libraries from Intel. If you integrate the API of the NavData generation system into your own tools, you can also extend the framework in order to make use of a different third-party utility for managing the parallel computations.

In principle, splitting the generation process over multiple cores can decrease generation time in direct proportion to the number of cores available. In practice, the real gains are somewhat less due to the pre-processing and post-processing phases of NavData generation, which are not parallelized. In any case, you should see significant gains in speed when using parallel computations, particularly for large terrains.

How to generate on multiple processors

The steps and considerations involved in using multiple processors are slightly different depending on whether you use the Navigation Lab or the API of the NavData generation system.

Using the Navigation Lab

Multi-processor generation is enabled by default in the Navigation Lab.

To enable or disable generation of NavData on multiple processors in the Navigation Lab:

  1. In the Generation window, expand the Run group.
  2. Check or uncheck the Use multi-core checkbox.

The Navigation Lab uses TBB internally to distribute NavData generation across all available processors on your computer.

Note that multi-core support is available only in Release builds of the standalone tools. Because Debug builds of TBB have been found to run very slowly, Debug builds of the standalone tools always generate NavData in sequence on a single processor without using TBB.

Using the Generator in C++, with TBB

If you have followed the instructions for integrating the API of the NavData generation system given under Integration Phase 6: Using the NavData Generation API, you should already be set up to use TBB through the TbbParallelForInterface class.

Note that:

  • The TbbParallelForInterface class only uses TBB to distribute calculations in Release builds. Because Debug builds of TBB have been found to run very slowly, the TbbParallelForInterface in Debug builds always generates NavData in sequence on a single processor without using TBB.
  • In the GeneratorRunOptions object that you can access through GeneratorInputOutput::m_runOptions, ensure that:

    • The value of the GeneratorRunOptions::m_doMultiCore class member is set to true (the default).
    • The GeneratorRunOptions is configured to not generate any intermediate files (the default). Parallelization is automatically disabled when intermediate files are requested.

Using the Generator in C++, with a custom interface

To use a custom utility for managing parallel computations:

  1. Write a custom implementation of the IParallelForInterface class. Your class will receive jobs from the Generator, and is in charge of dealing with the parallelization system to ensure that each of these jobs is carried out.

    For details, see the IParallelForInterface class description. In addition, full source code is provided for the TbbParallelForInterface implementation, so you can use this implementation as a model for your own class.

  2. In your NavData generation code, create an instance of your IParallelForInterface class before you create the Generator, and pass as a parameter when you construct the Generator.
  3. In the GeneratorRunOptions object that you can access through GeneratorInputOutput::m_runOptions, ensure that:

    • The value of the GeneratorRunOptions::m_doMultiCore class member is set to true (the default).
    • The GeneratorRunOptions is configured to not generate any intermediate files (the default). Parallelization is automatically disabled when intermediate files are requested.

It is up to you to ensure that any other requirements of your custom parallelization system are met.