Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pollution of CPP #define namespace #40

Closed
citibeth opened this issue Dec 4, 2018 · 4 comments
Closed

Pollution of CPP #define namespace #40

citibeth opened this issue Dec 4, 2018 · 4 comments
Labels
bug Something isn't working

Comments

@citibeth
Copy link
Collaborator

citibeth commented Dec 4, 2018

I got the error below:

[ 98%] Building Fortran object model/lipluggable/tests/CMakeFiles/tests.dir/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/include/driver.F90.o
/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/include/driver.F90:253.34:

         allocate(context, source=newMpiContext())
                                  1
Error: Function 'newmpicontext' at (1) has no IMPLICIT type

This is caused by a comedy of errors. driver.F90 has an "#ifdef USE_MPI" in it. I don't know where USE_MPI was supposed to be defined. This installed version of pFUnit was built with -DMPI=NO, so it was NOT supposed to be defined:

==> 'cmake' '/home2/rpfische/spack6/var/spack/stage/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/pFUnit-3.2.9' '-G' 'Unix Makefiles' '-DCMAKE_INSTALL_PREFIX:PATH=/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel' '-DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo' '-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON' '-DCMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL=FALSE' '-DCMAKE_INSTALL_RPATH:STRING=/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/lib;/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/lib64' '-DCMAKE_PREFIX_PATH:STRING=/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/python-3.5.2-o4sbclg3sf5uuroc53qpu4axrvr62ar5;/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/cmake-3.11.1-joeqauye6ejnz5j3lahtwbpdgc6fpgwa' '-DPYTHON_EXECUTABLE=/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/python-3.5.2-o4sbclg3sf5uuroc53qpu4axrvr62ar5/bin/python3.5' '-DBUILD_SHARED=YES' '-DCMAKE_Fortran_MODULE_DIRECTORY=/home2/rpfische/spack6/opt/spack/linux-centos7-x86_64/gcc-4.9.3/pfunit-3.2.9-lefpp6xzvqfxyixvfjo3gcdrwugtgyel/include' '-DBUILD_DOCS=NO' '-DOPENMP=NO' '-DMPI=NO'

However... my project defines its own USE_MPI. And it becomes a problem because my project compiles the driver.F90 source code, which then mis-interprets my project's USE_MPI definition as its own.

Given that pFUnit source code is compiled by the user, the solution would be to use longer/more obscure preprocessor symbols. Eg: USE_MPI -> _PFUNIT_USE_MPI.

@citibeth citibeth added the bug Something isn't working label Dec 4, 2018
@tclune
Copy link
Member

tclune commented Dec 4, 2018

@citibeth The conflict in the CPP token is unfortunate. With a serial build you should indeed not be setting it when compiling driver.F90. Because the compilation of driver.F90 is in user space, you ought to be able to control what flags are sent to it. I could add a new token along the lines you suggest, but to delete the other one would break every one else's build that does use MPI

Perhaps you could just create and maintain a copy of driver.F90 in your own source tree? It really won't be changing until 4.0 is out in which case this issue will hopefully evaporate.

I'm open to any suggestion for the current version that does not break the builds of others.

@citibeth
Copy link
Collaborator Author

citibeth commented Dec 4, 2018 via email

@tclune
Copy link
Member

tclune commented Dec 4, 2018

Apparently not. :-(

There really is not much to it though.

First, within the build of the library itself the flag is used to export the MPI specific extensions of pFUnit in pFUnit_mod and whether or not pFUnit's init/finalize trigger MPI's init/finalize. Of course in this context the CPP token is controlled by the build process, not by the user.

Then in driver.F90 it is used to (a) include 'mpif.h' (which may not even be necessary any more) and (b) to have the runner use an MpiContext for controlling resources available to the test runner. The default is a serial context.

Basically if you build the library with -DMPI=YES then you should compile the driver with -DUSE_MPI, and otherwise you should not. Previously there were two separate drivers, which avoided this issue, but resulted in significant code duplication. In 4.0 the duplicated code will have been refactored into the framework, leaving the driver as a very simple entity. The MPI logic is compiled into a separate library , and MPI is enabled by the user by linking with"-lpfunit -lfunit", while a serial test suite is compiled by linking with just "-lfunit". (At least I think this will work - I've only done a small bit of testing thus far.)

@tclune
Copy link
Member

tclune commented Dec 4, 2018

It may also be worth pointing out that, so long as you have MPI in your environment anyway, then it is perfectly sensible to use a parallel build of pFUnit for serial tests. Depending on the flavor of MPI you may need to launch the test with mpirun -np 1 ... , but many flavors allow a 1 PE launch without mpirun.

@tclune tclune closed this as completed Sep 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants