Multithreading Magboltz Gas File Generation

Hello all, I’m trying to multithread the generation of gas files from Magboltz by splitting the field grid in different sections.

In my program, each std::thread() creates a Garfield::MediumMagboltz object that generates a table from a different interval of the [E_min,E_max] electric field grid (I’m not simulating magnetic fields), therefore splitting the total interval throughout the N threads running. However, I’m not sure if my approach works with Garfield, as I seem to get segmentation violations seemingly in a random part of the process. (Sometimes happens as soon as I begin the process, other times I can see the MT works by looking at per-core CPU usage but it crashes at some point).

It could be my own program’s fault, but I’m not sure why if it’s the case, as all I do after creating the threads is calling thread.join() to wait for them to finish.

I attached the output from the moment Garfield takes over, for a simple test generation of a 100.0% Argon mixture, using 4 threads (besides main thread). Any help is greatly appreciated!

Output.txt (40.1 KB)

Hello,

Adding @hschindl in the loop.

Cheers,
D

Hi,
Magboltz is not thread-safe unfortunately. But what you can do is run separate jobs for different ranges of electric fields and then glue the gas files together using MergeGasFile.

Hi, thanks for the reply! Used child processes with fork(), and it worked perfectly.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.