# Slow Multi-thread Integrals

**URL:** <https://root-forum.cern.ch/t/slow-multi-thread-integrals/47518>\
**Category:** Newbie\
**Created:** [November 3, 2021, 10:12pm UTC](https://root-forum.cern.ch/t/slow-multi-thread-integrals/47518 "2021-11-03T22:12:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dyn0402](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dyn0402/32/27800_2.png) [@Dyn0402](https://root-forum.cern.ch/u/Dyn0402)\
**Post date:** [November 3, 2021, 10:12pm UTC](https://root-forum.cern.ch/t/slow-multi-thread-integrals/47518/1 "2021-11-03T22:12:26Z")

</div>

I’ve found that while multi-threading on Ubuntu TF1::IntegralOneDim integration slows down multi-job processes to a single thread speed. Looking further, it seems this is only true when using gsl integrators. I believe this may be due to the gsl workspace being shared between threads and creating a race condition? (I can’t post a link to stack exchange thread)

I don’t know if there is a workaround for gsl but I wanted to post for posterity that switching the default integrator to Gauss or GaussLegendre worked for me (TF1::IntegralOneDim has good documentation):

```auto
#include <Math/IntegratorOptions.h>
ROOT::Math::IntegratorOneDimOptions::SetDefaultIntegrator("Gauss");

```

* * *

_ROOT Version:_ 6.24/02  
_Platform:_ Ubuntu 20.04.3  
_Compiler:_ g++ 9.3.0

* * *

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [November 4, 2021, 10:33am UTC](https://root-forum.cern.ch/t/slow-multi-thread-integrals/47518/2 "2021-11-04T10:33:56Z")

</div>

Hi,

Thank you for your post. Do you have an example code showing this problem ? In principle, if you create integrator object in different threads, as it is done if TF1::Integral is called in separate threads, the GSL integrator workspace should not be shared.  
If you post your example code, I can investigate this issue

Best regards

Lorenzo
