Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Omp parallel sections failed,why?

chbq
Beginner
173 Views
hello,I am sorry to submit a C++ problem here,becaue I think here have much users than the Intel C++ community.maybe I can get more help form others.
I can parallel a simple program and get the accelerate rate about 1.4 or more on my computer,my computer information is :
Pentium 3.00, support Hyper-Threading technology,1G memory,
window xp sp2 operation system.
the serial way
sum=ParallelFun(0,LL,LL,MM,NN);
and the parallel way :
#pragma omp parallel sections
{
#pragma omp section
sum1=ParallelFun(0,LL/2,LL,MM,NN);
#pragma omp section
sum2=ParallelFun(LL/2,LL,LL,MM,NN);
}
the ParallelFun is here:
double ParallelFun(int start,int end,int L,int M,int N)
{
double temp1,temp2,temp3;
double temp=0;
double t;
int i,j,k;
for(i=start;ifor (j=0;jfor(k=0;k{
temp1=i*M*N;
temp2=j*N;
temp3=k*L;
t=sin(temp1)+cos(temp2)+tan(temp3+temp2+temp1);
temp+=t;

}
return temp;
}
However ,when I using such ways to parallelize another program,I am failed,
thefunction isabout 5KB,it is very long,and involved many large data, the following is part of the function:
bool CMainFarme::TemperatureCalculation()
{
....
memcpy(Tn,Tt,(long)LT*MT*NT*4);
for(i=0;ifor(j=0;jfor(k=0;k{
first=(long)i*MNT+(long)j*NT+k;//***
if((int)Att[first]!=1 && (int)Att1[first]!=103)
{
if(Att[first]==Att[first+MNT])
Axr=cThermal.Htcf[Att[first]];
else
{
if(Att1[first+MNT]==103)
Axr=0;
else
Axr=2.0/(Htcf0[Att[first]]+Htcf0[Att[first+MNT]]+2.0/ (dFluidP.ST*cThermal.Fhm[Att[first]][Att[first+MNT]]));
}
if(...)
.....
else
....
.......
if(...)
return FALSE;
......
return TRUE;
}
}
the LT*MT*NT is always more than 1 000 000 or more ,the other globalvariables such as Att,Att1 are also as large as Tn and Tt,and the functioncontain many if-else clausesstruct as list above(about to 10 if-else clauses). I use the same way to split the function into two sub-function(because they have return false in function,can't use omp parallel for clause) as fellow:
declaration in MainFrame.h :
public:
BOOL ParallelTempCalOnly(int start, int end, int LT, int MT, int NT, float* Tn, float* Tt,float *Htcf0);
call in a function :
BOOL CMainFrame::TempCalOnly()
{
...
#pragma omp parallel sections
{
#pragma omp section
ParallelTempC alOnly(0,LT/2,LT,MT,NT,Tn,Tt,Htcf0);
#pragma omp section
ParallelTempCalOnly(LT/2,LT,LT,MT,NT,Tn,Tt,Htcf0);
}
...
}
compile the program and execute the exe file,It's output the right result as the serial one,but they does not parallelized, the CPU using is about %50,indicate that another CPU is idle, while I execute the above simple program ,the CPU using is %100 when execute the parallel part of the program.
my platform is Visual studio 2003+intel c++ 9.0. I want to know why it is not parallel ,is the function too long? or the variable int the function contains too much data ? thanks
0 Kudos
0 Replies
Reply