title: How to set the number of CPU cores engaged in a calculation (C++ and OpenMP)
body: <p>I'm trying to calculate Pi in Qt5 using C++ and OpenMP (with focus on reduction data clause). In this program, I provide the calculation precision and the number of CPU cores engaged.<p>
  So far, I have the following code:</p>
  
  <pre><code>    int num_steps= ui-&gt;numberStepsLineEdit-&gt;text().toInt();
      double x=0.0;
      double sum = 0.0;
      #pragma omp parallel private(i,x)
      {
          #pragma omp for reduction(+:sum) schedule(static)
          for (int i=0; i&lt;num_steps; i++)
          {
               x=(i+0.5)/(double)num_steps;
               sum = sum + 4.0/(1.0+x*x);
          }
       }
       double pi=sum/(double)num_steps;
       QString result= QString::number(pi, 'g', 10);
       ui-&gt;piLabel-&gt;setText(result);
  </code></pre>
  
  <p>The problem is that I need to specify the number of CPU cores engaged in the calculation, and I've looked on the internet for examples without success.</p>
  
  <p>How can I set the number of CPU cores engaged in the calculation? (I don't want to set the number of threads).</p>
  
  <p>Thank you a lot in advance.</p>