iOpenShell » Technical questions » Unable to compile ezDyson

Unable to compile ezDyson

Moderators: kadir, krylov, piotr.

Page: 1

Author Post
Member
Registered: Feb 2010
Posts: 11
Hi all,
First off, thanks to the Krylov group for making ezDyson publicly available!

I can run the precompiled executables but I am having problems compiling ezDyson.v1 with the mk.linux makefile (see gcc output pasted below). Any help would be appreciated - I'm in the process of learning C++!

My specs are:
-bash-3.2$ gcc -v
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
Thread model: posix
gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)

The error is:

gcc -O3 -static -openmp -c cklm.C -o cklm.o
cklm.C: In member function 'void CklmCoeff::CalcCylAvgCklmSq(XYZGrid&, MolAvg, const AngleGrid&, Orbital&, double*, RadialFunction&, KLMPoints&)':
cklm.C:215: error: 'theSPH' was not declared in this scope
cklm.C: In member function 'void CklmCoeff::CalcCylAvgCklmSqXPol(XYZGrid&, MolAvg, const AngleGrid&, Orbital&, RadialFunction&, KLMPoints&)':
cklm.C:335: error: 'theSPH' was not declared in this scope
cklm.C: In member function 'void CklmCoeff::CalcGenAvgCklmSq(XYZGrid&, MolAvg, const AngleGrid&, Orbital&, double*, RadialFunction&, KLMPoints&)':
cklm.C:560: error: 'theSPH' was not declared in this scope
cklm.C: In member function 'void CklmCoeff::CalcGenAvgCklmSqXPol(XYZGrid&, MolAvg, const AngleGrid&, Orbital&, RadialFunction&, KLMPoints&)':
cklm.C:823: error: 'theSPH' was not declared in this scope
cklm.C: In member function 'void CklmCoeff::CalcCklmSq(XYZGrid&, Orbital&, double*, RadialFunction&, KLMPoints&)':
cklm.C:947: error: 'theSPH' was not declared in this scope
cklm.C: In member function 'void CklmCoeff::CalcCklmSqXPol(XYZGrid&, Orbital&, RadialFunction&, KLMPoints&)':
cklm.C:1059: error: 'theSPH' was not declared in this scope

--
Will Glover
Member
Registered: Sep 2007
Posts: 15
Here are the changes to the "makefile" you need to make:

for both g++ and gcc compilers:
(a) change "CC=icpc" to "CC=g++" OR "CC=gcc"
(b) remove "-ip" from the CCFLAGS

additionally for gcc:
(c) add "-lstdc++ -lm" to the LFLAGS, i.e. it becomes: "LFLAGS = $(LXML) -lstdc++ -lm"
(these two libraries are not linked by default when gcc is used)

after these changes are made to the "makefile", type:
make clean
make

I hope this helps, good luck!
let us know if you still have problems,
Vadim
Member
Registered: Feb 2010
Posts: 11
Thanks for the reply. I tried both g++ and gcc (adding the extra LFLAGS for gcc) and I still have the same error. To clarify, everything compiles ok up until cklm.C

Are you compiling the same version of cklm.C? Mine has a creation date of Sep 18 17:09 cklm.C

Regards,
--
Will Glover
Member
Registered: Sep 2007
Posts: 15
yep, I do have the same version, but do have any compilation problems.
Will think about it and ask others.

-vm
Member
Registered: Mar 2009
Posts: 9
Will, can you (1) check : in your sph.h, is there a "friend" before "SPH& theSPH();" ? (2) if so and still doesn't work, put "friend SPH& theSPH();" one line ahead of "public:" and delete the original line "friend SPH& theSPH();", see if works on not?
Member
Registered: Feb 2010
Posts: 11
Hi Taoliang,
(1) There was indeed a friend in front of SPH& theSPH(); in sph.h

(2) I moved friend SPH& theSPH();" one line ahead of "public:", but I still get the same error.

So Vadim and Taoliang: are you both able to compile the version of ezDyson from the website as is, with no changes to the code and no additional libraries? What platforms are you compiling on? I have tried gcc version 4.1.2 20071124 on CentOS 5.2, and gcc version 4.2.1 on Mac OS 10.6.2. Both give the same compilation error.
Member
Registered: Sep 2007
Posts: 15
Will, I got this error reproduced on my Ubuntu -- will look into it.
We have Scientific Linux (Red Hut) -- no problems there.
-vm
Member
Registered: Feb 2010
Posts: 11
Ok. So I got it to compile with the intel compiler on CentOS 5.2 8)

Not sure what was up with gcc. :?

On a side note, I get a seg fault when I run the executable compiled with the -openmp option, so I removed that option and it seems to work for now.

If I were a C++ programmer, I would dig into the code and try to see what was going on, but I'm not, so I'll stick with the version I have working.
Member
Registered: Mar 2009
Posts: 9
Will, We couldn't generate the error you have there. Let me explain something:

"static SPH *sph=&(theSPH());" in cklm.C
and
"friend SPH& theSPH();" in sph.h
and
"SPH& theSPH()
{
static SPH thesph;
return thesph;
}" in sph.C

actually perform together to have such a simple function: if you just remove those parts from sph.h and sph.C, and change "static SPH *sph=&(theSPH());" in cklm.C to (will be two lines) :

static SPH thesph;
static SPH *sph=&thesph;

As you can see, what we did here was just declare an object "thesph" of class SPH, and a pointer "*sph" that point to class SPH object. Then initialize this pointer to the address of "thesph". People defined a friend function theSPH() to translate these two lines in cklm.C. Therefore, you saw those lines in sph.h and sph.C.

Since your compiler has a problem to read this friend function theSPH() (you know we don't need here, if you just do what i said), I suggest you remove those lines in sph.h and sph.C and replace "static SPH *sph=&(theSPH());" in cklm.C with these two lines. It should work.
Member
Registered: Mar 2009
Posts: 9
Openmp is a shared-memory parallel, in order to run the executable file compiled with -openmp, you need to run it by using a script to request the number of nodes, input file name, output file name, queue name, error msg file, etc......for example, i have a Bourn shell script like :
-----------------------------------------
#!/bin/sh

# INPUT VARIABLES
QUEUE=$4
BATCHFILE=$5.batch
JOBNAME=$5
NP=1
LOGNAME=`whoami`
CWD=`pwd`

# FORM THE BATCH FILE FOR USE WITH PBS
echo "#!/bin/bash" > $BATCHFILE
echo "#PBS -r n" >> $BATCHFILE
echo "#PBS -q $QUEUE" >> $BATCHFILE
echo "#PBS -N $JOBNAME" >> $BATCHFILE
echo "#PBS -o $JOBNAME.stdout" >> $BATCHFILE
echo "#PBS -e $JOBNAME.error" >> $BATCHFILE
echo "#PBS -l nodes=$NP:ppn=4" >> $BATCHFILE
echo "#PBS -l mem=$MEM" >> $BATCHFILE
echo "#PBS -l walltime=500:00:00" >> $BATCHFILE
echo "#PBS -m abe" >> $BATCHFILE

echo " " >> $BATCHFILE

#echo "Job submitted at " `date`
echo "cd $CWD " >> $BATCHFILE

echo "$1 $2 >& $3" >> $BATCHFILE

echo " "
#echo " ** SUBMIT SCRIPT WITH qsub " $BATCHFILE " ** "
#echo " "

qsub $BATCHFILE

# REMOVE THE PBS STANDARD OUTPUT AND ERROR FILES
wait
rm $BATCHFILE
----------------------------------------
Running on single processor might not be a good idea, because it will take forever to do the integral without parallel the loops..By the way, we had a modified ezDyson which changed the numerical method and ran much faster than older one. I just finished the rewritten manual, Anna is taking a look at it. We will publish them online very soon. If you want see it right now, you can email anna asking for a copy.
Member
Registered: Mar 2009
Posts: 9
you can see from the script, since it is a shared-memory code, the number of node being request is always 1, and each node has 4 processors, therefore you request number of processors ppn=4. Those 4 processors will run multi-thread, but only use the installed memory on each node (for example 2GB). Depending on what kind of cluster you are using there, do some small modifications on this script. Then it should work fine.
Member
Registered: Feb 2010
Posts: 11
Thanks for your help. I tried your suggestions to get it to compile in gcc, but had no luck. I am happy to stick with the intel compiler and let someone more proficient in C++ figure out what is wrong with gcc. As for the OpenMP, I understand that I should submit it to a job queue, but for testing purposes, I should be able to run it interactively (that has been the case with my openmp programs in the past) and yet this code seg faults. Anyway, if you have a new version of the code that fixes these issues, I would be very interested in it, and also an updated manual. I will email Prof. Krylov and ask if I can have a copy. Thanks once again for your help!
Administrator
Registered: Aug 2007
Posts: 200
Hi Liang! The PBS script above shouldn't have anything to do with the code itself. The script is just a directive for the queuing system and PBS knows nothing about the code you are running. All it does is, it finds a node that has 4 CPUs defined in its config, that seem to be empty. Similar thing goes for the $MEM variable. It is not defined in your script, but even if it was, it doesn't mean anything to ezDyson, again it is just a PBS directive.

I never looked into the ezDyson code itself, but I think one version that somebody was running, was hard coded to use 4 shared memory CPUs (I might be wrong about this). How is the code that we distribute handling the number of CPUs?
Member
Registered: Feb 2010
Posts: 11
The code uses high-level openmp directives like:
#pragma omp parallel for
So the code itself knows nothing about the number of cpu; that is defined at runtime.
Member
Registered: Mar 2009
Posts: 9
Hi kadir, I dont know in the code, how openMP is applied, I didn't do this part. I am also confused the task and threads. please take a loot at this:

3. OpenMP Codes
Top
Interactive jobs that use OpenMP must run with the the environment variable MP_TASK_AFFINITY unset. As of August 2, 2006 (Parallel Environment 3.3.2.4) jobs run through LoadLeveler batch scripts ignore this environment variable. Make sure that you do not use the "rset" keyword to request task affinity in your batch script.

THESE SETTINGS ARE WRONG FOR OPENMP CODES. DO NOT USE FOR OPENMP CODES.
#@ rset = rset_mcm_affinity
#@ mcm_affinity_options = mcm_distribute, mcm_mem_pref, mcm_sni_none
THESE SETTINGS ARE WRONG FOR OPENMP CODES. DO NOT USE FOR OPENMP CODES.
For interactive jobs use the appropriate statement:

unsetenv MP_TASK_AFFINITY (for csh, tcsh)

unset MP_TASK_AFFINITY (for sh, ksh, bash)
The default number of OpenMP threads per task (process) is 8. If you are running a pure OpenMP code, you should run using one task per node. If you are using more than one task per node, you should reduce OMP_NUM_THREADS so that the product of tasks x threads is 8. A combination of tasks and threads significantly in exess of 8 may result in poor performance.

OpenMP code will probably performer better with the following environment variable setting:

export XLSMPTOPTS=SPINS=0;YIELDS=0 (for sh-like shells)

setenv XLSMPTOPTS 'SPINS=0;YIELDS=0' (for csh-like shells)
If you are calling malloc() or ALLOCATE in OpenMP threads, you may want to set this environment variable:

export MALLOCMULTIHEAP=true (sh-like shells)

setenv MALLOCMULTIHEAP true (csh-like shells)
Otherwise, memory allocations will be serialized on a node.
Member
Registered: Feb 2010
Posts: 11
I am still unable to get it to run with openmp (seg fault), even with the environment variables you suggest. There might be something wrong with the cluster I am using, I'll have to explore that further. In the meantime, compiling without -openmp will give me something to play with.
Member
Registered: Mar 2009
Posts: 9
hi, we posted the new manual together with the new code to calculate total cross section online. Please take a look and try
Member
Registered: Feb 2010
Posts: 11
Great!
I'll give it a try. Thanks!
Member
Registered: Feb 2010
Posts: 11
Hi taoliang,
I couldn't find the new version under downloads - it's still v1. Is it posted elsewhere?

Page: 1

iOpenShell » Technical questions » Unable to compile ezDyson