Shared memory parallelism with vtkUnstructuredGrid and vtkStaticCellLocator?

I’m trying to achieve something I’m not sure is possible, but would really appreciate any ideas/ suggestions/ tips on how to try to do this…

I’m running a post-processing tool on very large vtkUnstructuredGrids (with >200 million cells) using C++. I have to run the post-processing tool over the mesh several hundred times, with random changes between each run, and I’m currently managing this using two classes;

  • A ‘simulation instance’ class manages initialisation and writing outputs, using MPI to launch;
  • ‘single run’ class which manages one simulation with specified parameters

The simulation instance can launch any number of single runs in parallel (using MPI), each running serially on one core in a high-performance cluster. Each single run makes use of two vtkUnstructuredGrid objects and two vtkStaticCellLocator objects, which it calls many times during execution (managed using vtkSmartPointers). However, these objects are never changed so, in theory, the same object could be used for every instance of ‘single run’. Each single run needs about 20GB of memory at the moment, so I’m really keen to move to a shared memory approach.

Essentially, I want to use shared memory parallelism to load each vtkUnstructuredGrid and vtkStaticCellLocator into the memory on my machine once, and then probe those objects by passing their pointers to every instance of ‘single run’.

  • Is this at all possible (however difficult), and if so does anyone have any recommendations?
  • Is it possible for multiple processes to share or call the same vtkSmartPointer in any situation? (I understand this is not the c++ standard for sharing pointers)
  • If you deem it impossible, does anyone recommend any ways to reduce the memory use of my program? Each ‘single run’ must have access to the unstructured grids and cell locators at all times and takes several days to complete. I’m not in a position to share the code in any detail at the moment, so understand providing recommendations will be difficult

I’ve spent some time working towards this already, so do understand the need for thread-safe function calls, and know that there essentially isn’t any way to achieve this which would also satisfy C++/ VTK ‘best practises’. For this project, I don’t mind about that too much.

Huuuge thanks to anyone with ideas!