<div dir="ltr">Hi Satish,<div><br></div><div>Thanks, that installation worked and it's now compiling with gcc-4.9. However, I'm still having the issue that OpenMP isn't working when I'm using PETSc in the same code. I'm including this segment at the beginning of my code:</div>
<div><br></div><div><div><span class="" style="white-space:pre"> </span>int nthreads, tid;</div><div><br></div><div><span class="" style="white-space:pre"> </span>#pragma omp parallel private(nthreads, tid)</div><div> {</div>
<div><br></div><div> <span class="" style="white-space:pre"> </span>/* Obtain thread number */</div><div> <span class="" style="white-space:pre"> </span>tid = omp_get_thread_num();</div><div><br></div><div> <span class="" style="white-space:pre"> </span>printf("Hello World from thread = %d\n", tid);</div>
<div><br></div><div> <span class="" style="white-space:pre"> </span>/* Only master thread does this */</div><div> <span class="" style="white-space:pre"> </span>if (tid == 0) </div><div> <span class="" style="white-space:pre"> </span>{</div>
<div> <span class="" style="white-space:pre"> </span>nthreads = omp_get_num_threads();</div><div> <span class="" style="white-space:pre"> </span>printf("Number of threads = %d\n", nthreads);</div><div> <span class="" style="white-space:pre"> </span>}</div>
<div><br></div><div> <span class="" style="white-space:pre"> </span>} </div></div><div><br></div><div>I have no problems getting this to run outside of PETSc, with typical output as follows:</div><div>
<p class="">Hello World from thread = 0</p>
<p class="">Hello World from thread = 1</p>
<p class="">Hello World from thread = 3</p>
<p class="">Hello World from thread = 2</p>
<p class="">Number of threads = 4</p><p class=""><br></p><p class="">But when I include that snippet of code in my larger PETSc code, all I get is</p><p class="">Hello World from thread = 0</p><p class="">
</p><p class="">Number of threads = 1</p><p class=""><br></p><p class="">My makefile is just </p><p class="">ALL:</p><p class="">include ${PETSC_DIR}/conf/variables</p><p class="">include ${PETSC_DIR}/conf/rules</p><p class="">
include ${PETSC_DIR}/conf/test</p><p class=""><br></p><p class="">main: main.o</p><p class=""><span class="" style="white-space:pre"> </span>-${CLINKER} -fopenmp -o main main.o ${PETSC_LIB}</p><p class=""><span class="" style="white-space:pre"> </span>${RM} -f main.o</p>
<p class=""><br></p><p class="">I don't get any errors when compiling, as far as I can tell. This is the output when compiling:</p><p class="">gcc-4.9 -o main.o -c -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3 -fno-inline -O0 -I/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/include -I/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/arch-gcc/include -I/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/include/mpiuni -D__INSDIR__= main.c</p>
<p class="">gcc-4.9 -Wl,-multiply_defined,suppress -Wl,-multiply_defined -Wl,suppress -Wl,-commons,use_dylibs -Wl,-search_paths_first -fPIC -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -g3 -fno-inline -O0 -fopenmp -o main main.o -L/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/arch-gcc/lib -L/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/arch-gcc/lib -lpetsc -llapack -lblas -lpthread -L/usr/local/lib/gcc/x86_64-apple-darwin13.1.0/4.9.0 -L/usr/local/lib -ldl -lgfortran -lgfortran -lquadmath -lm -lm -lSystem -lgcc_ext.10.5 -ldl </p>
<p class="">
</p><p class="">/bin/rm -f -f main.o</p></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Apr 25, 2014 at 12:46 AM, Satish Balay <span dir="ltr"><<a href="mailto:balay@mcs.anl.gov" target="_blank">balay@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">if you are primarily intesrested in -fopenmp - and not mpi - just<br>
configure petsc with --with-mpi=0<br>
<br>
If you have currently working build with clang - and would<br>
like to just compile your code with gcc-4.9 - you can try:<br>
<br>
export MPICH_CC=gcc-4.9<br>
make [your-target]<br>
<br>
It might work. Or you might get link errors. [If you get<br>
errors - its best to rebuild PETSc with gcc-4.9]<br>
<br>
BTW: you can use a different PETSC_ARCH for each of your builds - so<br>
that they don't overwrite each other..<br>
<br>
./configure PETSC_ARCH=arch-gcc --with-cc=gcc-4.9 --with-cxx=0 --with-mpi=0<br>
<br>
[on osx petsc can use VecLib so --download-f-blas-lapack shouldn't be needed]<br>
<span class="HOEnZb"><font color="#888888"><br>
Satish<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Fri, 25 Apr 2014, Justin Dong wrote:<br>
<br>
> I'll leave it running for a few hours and see what happens.<br>
><br>
> In the meantime, is it possible to tell PETSc to compile a specific .c file<br>
> using gcc-4.9? Something along the lines of this:<br>
><br>
> ALL:<br>
><br>
> include ${PETSC_DIR}/conf/variables<br>
> include ${PETSC_DIR}/conf/rules<br>
> include ${PETSC_DIR}/conf/test<br>
><br>
> main: main.o<br>
> gcc-4.9 -${CLINKER} -fopenmp -o main main.o ${PETSC_LIB}<br>
> ${RM} -f main.o<br>
><br>
> The main reason I want to compile with gcc-4.9 is because I need to use<br>
> openmp for a simple parallel for loop. With the gcc compiler I have now<br>
> (clang), there's no support for openmp. I can get gcc-4.9 to work outside<br>
> of PETSc, but am not sure how to get it to work here if I want to do it for<br>
> a single example, or if that's even possible.<br>
><br>
><br>
> On Thu, Apr 24, 2014 at 10:03 PM, Barry Smith <<a href="mailto:bsmith@mcs.anl.gov">bsmith@mcs.anl.gov</a>> wrote:<br>
><br>
> ><br>
> > Leave it to run for several hours it could be that gcc-4.9 is just<br>
> > taking a very long time on mpich.<br>
> ><br>
> > Barry<br>
> ><br>
> > On Apr 24, 2014, at 8:35 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> wrote:<br>
> ><br>
> > > On Thu, Apr 24, 2014 at 9:27 PM, Justin Dong <<a href="mailto:jsd1@rice.edu">jsd1@rice.edu</a>> wrote:<br>
> > > Hi all,<br>
> > ><br>
> > > I'm trying to configure PETSc on Mac OS X with gcc-4.9. Currently, it's<br>
> > configured with gcc that comes with Xcode, but I want to use gcc-4.9 that I<br>
> > installed myself. I try:<br>
> > ><br>
> > ><br>
> > > ./configure --with-cc=gcc-4.9 --with-fc=gfortran<br>
> > --download-f-blas-lapack --download-mpich<br>
> > ><br>
> > ><br>
> > ><br>
> > > But while configuring MPICH it gets stuck indefinitely. I've included<br>
> > the output below after I terminate the process. I don't have this issue if<br>
> > I just configure with cc=gcc. Any ideas what the problem is here?<br>
> > ><br>
> > > From the stack trace, its just taking a long time. If it overruns the<br>
> > timeout, it should just die. You can try<br>
> > > running using -useThreads=0 if you suspect the timeout is not working.<br>
> > ><br>
> > > Matt<br>
> > ><br>
> > > ^CTraceback (most recent call last):<br>
> > ><br>
> > > File "./configure", line 10, in <module><br>
> > ><br>
> > > execfile(os.path.join(os.path.dirname(__file__), 'config',<br>
> > 'configure.py'))<br>
> > ><br>
> > > File "./config/configure.py", line 372, in <module><br>
> > ><br>
> > > petsc_configure([])<br>
> > ><br>
> > > File "./config/configure.py", line 287, in petsc_configure<br>
> > ><br>
> > > framework.configure(out = sys.stdout)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/framework.py",<br>
> > line 933, in configure<br>
> > ><br>
> > > child.configure()<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/package.py",<br>
> > line 558, in configure<br>
> > ><br>
> > > self.executeTest(self.configureLibrary)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/base.py",<br>
> > line 115, in executeTest<br>
> > ><br>
> > > ret = apply(test, args,kargs)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/packages/MPI.py",<br>
> > line 748, in configureLibrary<br>
> > ><br>
> > > config.package.Package.configureLibrary(self)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/package.py",<br>
> > line 486, in configureLibrary<br>
> > ><br>
> > > for location, directory, lib, incl in self.generateGuesses():<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/package.py",<br>
> > line 232, in generateGuesses<br>
> > ><br>
> > > d = self.checkDownload(1)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/packages/MPI.py",<br>
> > line 351, in checkDownload<br>
> > ><br>
> > > return config.package.Package.checkDownload(self, requireDownload)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/package.py",<br>
> > line 340, in checkDownload<br>
> > ><br>
> > > return self.getInstallDir()<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/package.py",<br>
> > line 187, in getInstallDir<br>
> > ><br>
> > > return os.path.abspath(self.Install())<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/packages/MPI.py",<br>
> > line 366, in Install<br>
> > ><br>
> > > return self.InstallMPICH()<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/config/packages/MPI.py",<br>
> > line 544, in InstallMPICH<br>
> > ><br>
> > > output,err,ret = config.base.Configure.executeShellCommand('cd<br>
> > '+mpichDir+' && ./configure '+args, timeout=2000, log = self.framework.log)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/script.py",<br>
> > line 254, in executeShellCommand<br>
> > ><br>
> > > (output, error, status) = runInShell(command, log, cwd)<br>
> > ><br>
> > > File<br>
> > "/Users/justindong/Classes/CAAMResearch/petsc-3.4.4/config/BuildSystem/script.py",<br>
> > line 243, in runInShell<br>
> > ><br>
> > > thread.join(timeout)<br>
> > ><br>
> > > File<br>
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",<br>
> > line 958, in join<br>
> > ><br>
> > > self.__block.wait(delay)<br>
> > ><br>
> > > File<br>
> > "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py",<br>
> > line 358, in wait<br>
> > ><br>
> > > _sleep(delay)<br>
> > ><br>
> > ><br>
> > > KeyboardInterrupt<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > Sincerely,<br>
> > ><br>
> > > Justin<br>
> > ><br>
> > ><br>
> > ><br>
> > ><br>
> > > --<br>
> > > What most experimenters take for granted before they begin their<br>
> > experiments is infinitely more interesting than any results to which their<br>
> > experiments lead.<br>
> > > -- Norbert Wiener<br>
> ><br>
> ><br>
><br>
<br>
</div></div></blockquote></div><br></div>