Fading Coder

One Final Commit for the Last Sprint

Home > Tools > Content

Setting Up a VTK Development Environment with Backend Parallel Acceleration on Ubuntu Linux

Tools 1

VTK Parallel Acceleration Methods

VTK (Visualization Toolkit) supports multiple parallel computing backends for performance optimization:

  • Distributed Memory Parallelism: Enable VTK_USE_MPI during compilation to use vtkMultiProcessController for multi-node rendering and data partitioning.
  • Shared Memory Parallelism: Configure VTK_SMP_IMPLEMENTATION_TYPE in CMake to select TBB (preferred), STDThread, OpenMP, or Sequential (default). TBB with Intel oneAPI offers optimal load balancing.
  • GPU Acceleration: Leverage OpenGL backend for GPU-based depth testing, instanced rendering, and CUDA-accelerated volume rendering.
  • Multithreaded Rendering: Use vtkThreadedCompositePolyDataMapper (VTK 9.x+) to split geometry pipelines across threads for large mesh rendering.

For enhanced shared memory parallelism, combine TBB with hwloc to optimize task scheduling using CPU/NUMA topology awareness.

Version Selection

VTK 9.2.6

  • Stable release with comprehensive 3D visualization features.
  • Extensive documentation and community support for debugging.
  • Verified compatibility with oneTBB for parallel backend integration.

oneTBB 2021.13

  • Performance improvements with backward compatibility.
  • Supports Ubuntu 24.04.3 LTS and multiple compilers.
  • Provides parallel algorithms and data structures for compute-intensive tasks.

hwloc 2.10.0

  • Mature libray for system topology discovery (CPU cores, NUMA nodes, caches).
  • API for resource allocation optimization in HPC scenarios.
  • Compatible with VTK and oneTBB for workload distribution.

Build Configuration

hwloc 2.10.0 Installation

git clone https://github.com/open-mpi/hwloc.git
cd hwloc
git checkout tags/v2.10.0
./autogen.sh
./configure --prefix=/opt/hwloc --enable-shared
make -j$(nproc)
sudo make install

oneTBB 2021.13 Setup

git clone https://github.com/oneapi-src/oneTBB.git
cd oneTBB
git checkout v2021.13
make -j$(nproc)
sudo make install prefix=/opt/oneTBB

Verify hwloc linkage:

ldd /opt/oneTBB/lib/libtbbbind_2_5_debug.so | grep hwloc

VTK 9.2.6 Compilation

wget https://www.vtk.org/files/release/9.2/VTK-9.2.6.tar.gz
tar -xzf VTK-9.2.6.tar.gz
cd VTK-9.2.6
mkdir build && cd build
cmake .. \
  -DVTK_SMP_IMPLEMENTATION_TYPE=TBB \
  -DTBB_DIR=/opt/oneTBB \
  -DCMAKE_INSTALL_PREFIX=/opt/vtk-9.2.6
make -j$(nproc)
sudo make install

Validation Tests

hwloc Verification

lstopo-no-graphics

Output system topology confirms successful installation.

oneTBB Functionality Test

Test Code (tbb_demo.cpp):

#include <tbb/parallel_for.h>
#include <iostream>

int main() {
  tbb::parallel_for(0, 8, [](int idx) {
    std::cout << "Thread " << idx << " active\n";
  });
  return 0;
}

Compile & Run:

g++ tbb_demo.cpp -o tbb_demo -L/opt/oneTBB/lib -ltbb
./tbb_demo

Multi-threaded output validates installation.

VTK Parallel Backend Test

Test Code (vtk_parallel_test.cpp):

#include <vtkSMPTools.h>
#include <thread>
#include <iostream>

int main() {
  vtkSMPTools::SetBackend("TBB");
  vtkSMPTools::SetNestedParallelism(true);
  
  unsigned int core_count = std::thread::hardware_concurrency();
  unsigned int target_threads = core_count; // Adjust as needed
  vtkSMPTools::Initialize(target_threads);
  
  std::cout << "Detected cores: " << core_count << "\n"
            << "Configured threads: " << target_threads << "\n"
            << "Active VTK threads: " << vtkSMPTools::GetEstimatedNumberOfThreads() << "\n"
            << "Backend: " << vtkSMPTools::GetBackend() << "\n";
  return 0;
}

Compile & Execute:

g++ vtk_parallel_test.cpp -o vtk_test \
  -I/opt/vtk-9.2.6/include/vtk-9.2 \
  -L/opt/vtk-9.2.6/lib \
  -lvtkCommonCore-9.2 -lvtkCommonSystem-9.2
./vtk_test

Output confirms TBB backend activation and thread configuration.

Tags

["VTK", "Ubuntu", "Parallel Computing", "TBB", "hwloc", "CMake", "C++", "High Performance Visualization"]

Related Articles

Efficient Usage of HTTP Client in IntelliJ IDEA

IntelliJ IDEA incorporates a versatile HTTP client tool, enabling developres to interact with RESTful services and APIs effectively with in the editor. This functionality streamlines workflows, replac...

Installing CocoaPods on macOS Catalina (10.15) Using a User-Managed Ruby

System Ruby on macOS 10.15 frequently fails to build native gems required by CocoaPods (for example, ffi), leading to errors like: ERROR: Failed to build gem native extension checking for ffi.h... no...

Resolve PhpStorm "Interpreter is not specified or invalid" on WAMP (Windows)

Symptom PhpStorm displays: "Interpreter is not specified or invalid. Press ‘Fix’ to edit your project configuration." This occurs when the IDE cannot locate a valid PHP CLI executable or when the debu...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.