title: How to have different OpenMP threads execute different tasks
body: <p>I am using open MP to speed up the flux calculation in my program. I basically want OpenMP to carry out both of these left and right flux calculations in parallel. But on the contrary, the following code takes even more time with the <code>#pragma</code> directives. What do i modify to get it right?</p>
  
  <pre><code>#pragma omp parallel num_threads(2)
  {
  
  #pragma omp single
  {//first condition
  //cerr&lt;&lt;"Executed thread 0"&lt;&lt;endl;
          if ( (fabs(lcellMach-1.0)&lt;EPSILON) || ( (lcellMach-1.0) &gt; 0.0 ) ){//purpose of Epsilon!!!!
                  FluxP[0] = rhol * vnl;
                  FluxP[1] = rhol * ul * vnl + Pl*nx;
                  FluxP[2] = rhol * vl * vnl + Pl*ny;
                  FluxP[3] = rhol * wl * vnl + Pl*nz;
                  FluxP[4] = rhol * ((GAMMA * Pl / (rhol * (GAMMA-1.0))) + ((ul*ul + vl*vl + wl*wl)/2.0)) * vnl;
          }else if ( (fabs(lcellMach+1.0)&lt;EPSILON) || ( (lcellMach+1.0) &lt; 0.0 ) ){
                  FluxP[0] = FluxP[1] = FluxP[2] = FluxP[3] = FluxP[4] = 0.0;// If flow direction is opposite the Flux + is zero
          }else {
                  double ql = (ul*ul + vl*vl + wl*wl);// how did this come
                  FluxP[0] = rhol * lcell_a * (lcellMach+1.0)*(lcellMach+1.0) / 4.0;
                  FluxP[1] = FluxP[0] * ( ul + (nx*(0.0-vnl + 2.0*lcell_a)/GAMMA) );
                  FluxP[2] = FluxP[0] * ( vl + (ny*(0.0-vnl + 2.0*lcell_a)/GAMMA) );
                  FluxP[3] = FluxP[0] * ( wl + (nz*(0.0-vnl + 2.0*lcell_a)/GAMMA) );
                  FluxP[4] = FluxP[0] * (  ((ql - vnl*vnl)/2.0) + (((GAMMA-1.0)*vnl + 2.0*lcell_a)*((GAMMA-1.0)*vnl + 2.0*lcell_a) / (2.0*(GAMMA*GAMMA-1.0)))  );
          }
  }//end of 1st
  #pragma omp single
  {//second condition
  //cerr&lt;&lt;"Executed thread 1"&lt;&lt;endl;
          if ((fabs(rcellMach+1.0)&lt;EPSILON) || ((rcellMach+1.0) &lt; 0.0)) {
                  FluxM[0] = rhor * vnr;
                  FluxM[1] = rhor * ur * vnr + Pr*nx;
                  FluxM[2] = rhor * vr * vnr + Pr*ny;
                  FluxM[3] = rhor * wr * vnr + Pr*nz;
                  FluxM[4] = rhor * ((GAMMA * Pr / (rhor * (GAMMA-1.0))) + ((ur*ur + vr*vr + wr*wr)/2.0)) * vnr;
          }else if ((fabs(rcellMach-1.0)&lt;EPSILON) || ((rcellMach-1.0) &gt; 0.0)) {
                  FluxM[0] = FluxM[1] = FluxM[2] = FluxM[3] = FluxM[4] = 0.0;
          }else {
                  tempFlux[0] = rhor * vnr;
                  tempFlux[1] = rhor * ur * vnr + Pr*nx;
                  tempFlux[2] = rhor * vr * vnr + Pr*ny;
                  tempFlux[3] = rhor * wr * vnr + Pr*nz;
                  tempFlux[4] = rhor * ((GAMMA * Pr / (rhor * (GAMMA-1.0))) + ((ur*ur + vr*vr + wr*wr)/2.0)) * vnr;
  
                  double qr = (ur*ur + vr*vr + wr*wr);
                  tempFluxP[0] = rhor * rcell_a * (rcellMach+1.0)*(rcellMach+1.0) / 4.0;
                  tempFluxP[1] = tempFluxP[0] * ( ur + (nx*(0.0-vnr + 2.0*rcell_a)/GAMMA) );
                  tempFluxP[2] = tempFluxP[0] * ( vr + (ny*(0.0-vnr + 2.0*rcell_a)/GAMMA) );
                  tempFluxP[3] = tempFluxP[0] * ( wr + (nz*(0.0-vnr + 2.0*rcell_a)/GAMMA) );
                  tempFluxP[4] = tempFluxP[0] * (  ((qr - vnr*vnr)/2.0) + (((GAMMA-1.0)*vnr + 2.0*rcell_a)*((GAMMA-1.0)*vnr + 2.0*rcell_a) / (2.0*(GAMMA*GAMMA-1.0)))  );
  
                  for (int j=0; j&lt;O; j++) FluxM[j] = tempFlux[j] - tempFluxP[j];
          }
  }
  }//pragma
  </code></pre>
  
  <p>Urgent help required. Thanks.</p>