I used intel c++ integrated with visual studio 2003 ,and compile a program. the program had been writen in visual studio 6.0 for many year,and my job now is parallelize some part of the codes. The program is very large and used many MFC classes.
I convert into intel c++ project system.compile and run the exe file without any error.
I added a openmp sections directives to parallel a three-ply loops(because in the loop have return clause,I can't use omp parallel for directive clause); I split the key calculation function which contains three-ply loops into two sub-function as fellow:
#pragma omp parallel sections
#pragma omp section
#pragma omp section
The parallelTempCalOnly function declaration is like this.
BOOL CMainFrame::ParallelTempCalOnly(int start, int end, float* Tt,CFluidParam &fluid, CThermalParam & thermal,char* attri,char *attri1, CalControl &calcontrl, CShrinkage &shrink,CENVParam &m_env,short *lh)The" Tt,dFluidP,cThermal,Att,Att1, CalCtl,shrinkage,m_ENVGolbal,LHDD"
are global variables,and dFluidP,cThermal,CalCtl,shrinkage,m_ENVGolbal are class objects.Tt,Att,Att1,LHDD are arrays,the datas that they contained are always more than 10 000 000 datas.
At first I change the parameters of start and end ,and call the function PCall1=ParallelTempCalOnly 0,LT/2,Tt,dFluidP,cThermal,Att,Att1,CalCtl,
shrinkage,m_ENVGolbal,LHDD) for two times.compile the program without
any compiler errors(had used /Qopenmp support),run the program the compiler inform can't find the libguide40.dll ,I copy the dll file form the install directory and paste it in the Debug directory,run the program without any problem.but they does not paralleled, the CPU using is %50-%65,indicated another CPU is idle.
In the sub-function,all the other global variables except the variable Tt are mostly used in the if clause like this.
do something and get a value;
Tt[i]=a value get form the above;// i is a variable for each loop
I belive that when execute the program,the threads may be access the global variables at the same time,so the can not parallelized,so I get a copy
of the other global variabe execpt Tt;and call the function like the above PCall2. however ,they also not parallelized,the CPU using is %50-%65,but they get the right results.
I want to know what problems maybe caused the codes not paralleled,the compiler? or my program? thanks.
Message Edited by chbq on 04-07-200607:00 AM