How to utilize multi-core/thread to speed up the simulation?

Dear FLUKA experts,

I read it in other topics that people are talking about using Flair to run multiple cycle at once. However, I failed to find a detailed guide on how to achieve this. Therefore, I would like to know if anyone could guide me through this process and I think it will also be beneficial to other new beginners like me.

Thanks in advance,

Martin

2 Likes

Dear Martin,

Once you’ve set up your input file, go to the Run tab and click “add” to add a new run:

Give it the name e.g. “myrun”. Select the number of cycles (e.g. 5) and primaries (e.g. 1000):

Then click on the grey rectangle in column “Spawn”:

…and proceed to enter the number of CPUs at your disposal, for the sake of argument 8. If you then click on the “+” symbol next to “myrun” you’ll see a list unfold with the 8 prepared input files that will run concurrently:

Flair takes care to set different random seeds for each of the 8 spawned cases.

Keeping the top level “myrun” selected as in the screenshot, you can click the “Start” button. You should see that, for each cycle, 8 concurrent runs are happily running in independent threads. The processing stage should take care to merge all 5 cycles (each with its respective 8 contributions).

Hopefully this (or a minor variation thereof) helps!

Cheers,

Cesc

2 Likes

Dear Francesc,

Thank you for your time and detailed explanation.

Martin

Hi dear Francesc,

Is is possible to do parallel runs with different input file at the same time?

I tried to several time but to no avail. It seems that Flair only wants to run the single project.

Thanks in advance.

Martin

Dear Martin,

Not in a general sense, i.e. you can’t throw in two completely unrelated input files. However, if the different cases you need to consider imply changes on certain aspects (different beam, different geometry, different scoring, different biasing, etc.), you can exploit the FLUKA preprocessor instructions in your input file:

  • #define A
  • #ifdef A
  • (a first block of input cards)
  • #else
  • (a second block of input cards)
  • #endif

If you leave the #define card in (uncommented) then the first block of input cards will be active. If you comment it out (effectively NOT defining A) then the second block will be active. E.g. if you want to switch between a photon and an e- beam:

If you then go to the Run tab, and add a run called “myrun” as in the reply above, you’ll see the following:

Note the checkbox with the label A. If you leave it checked, when issuing a run, Flair will leave A defined, and therefore the first block (photon beam) will hold.

Click on the “Clone” button (next to “Add”), call the other run “noA”, and leave the checkbox unselected. Flair then prepares an input file with “#define A” uncommented (effectively not defining A) and therefore the second block (electron beam) will hold.

Thus, if your input files differ only in certain sections, you can exploit this method to effectively handle two different input files in the same Flair project. You can include further #define’s to increase the number of cases.

By the way, for each of the runs you can use the same Spawn magic discussed above. Note however that if you run both cases, each spawning Ncpu cases (where Ncpu is the number of CPUs) you would have 2*Ncpu concurrent processes… So it would then make sense to either halve Ncpu or run one case after the other.

Cheers,

Cesc

3 Likes

Dear Francesc,

Thank you so much for your time to put together this detailed explanation. This is really helpful to speed things up.

Martin

Martin,

you can run more than one instance of Flair on your computer and in each instance, calculate on a different input file, possibly even on parallel threads. My experience shows that you can go to as many threads over all Flair-instances as you have physical cores on your computer. Using virtual cores does not bring a speed gain.

Best regards, Thomas

1 Like

Hi Thomas,

Thank you for sharing your invaluable experience. This would save me a lot of time.

Best regards,

Martin

2 Likes