Re: [cmake-developers] Adding Microsoft MPI Fortran support in FindMPI

2017-04-26 Thread Christian Pfeiffer
I reckon it might be better to ignore the Fortran 90 module API for now.
Adding a function for that would mean that the linked target has to be 
visible everywhere where the MPI package is being used with Fortran. Not 
to mention that all projects using the F90 module API then would need to 
have extra code for supporting MSMPI, significantly limiting its usefulness.

Originally, I thought the mpi.f90 file just defined the MPI modules, but 
there's a few COMMON blocks that will end up as dllimport symbols and 
therefore need linking with the result, instead of it sufficing to just 
add some include directories after creating the .mod file.

Adding the Fortran 77 API isn't a problem at all on the other hand, so I 
would be leaving it at that for the time being. In case a user 
absolutely needs Fortran 90 support on MSMPI, they'd have to compile the 
file in advance, add it to the includes and the Fortran libraries. 
That's not too much trouble and imho a better way than adding a 
requirement for project code which then would need to be maintained in 
future versions, too.

- Chris

On 4/24/2017 3:06 PM, Brad King wrote:
> On 04/21/2017 05:45 PM, Christian P. wrote:
>> Is this a good/bad idea or is there any way to do this in a proper fashion?
>> The idea of adding an actual target to a Find module seems wrong to me,
>> but I’m not seeing any way of doing it otherwise.
> I think we'll have to expose this requirement to project code.  Provide
> a function the project can call to make the needed target available.  That
> way the project can control if/when it is done and what the target is
> called.
>
> -Brad
>

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


Re: [cmake-developers] Adding Microsoft MPI Fortran support in FindMPI

2017-04-24 Thread Brad King
On 04/21/2017 05:45 PM, Christian P. wrote:
> Is this a good/bad idea or is there any way to do this in a proper fashion?
> The idea of adding an actual target to a Find module seems wrong to me,
> but I’m not seeing any way of doing it otherwise.

I think we'll have to expose this requirement to project code.  Provide
a function the project can call to make the needed target available.  That
way the project can control if/when it is done and what the target is
called.

-Brad

-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers


[cmake-developers] Adding Microsoft MPI Fortran support in FindMPI

2017-04-21 Thread Christian P .
Hi folks,

I’d like to implement support for MSMPI’s Fortran API in FindMPI so that it 
could be used to build ScaLAPACK and others. However, I’m looking for a bit of 
guidance on how to do this.

The Fortran 90 interfaces are contained in a file called mpi.f90 in the MSMPI 
include folder. This file has to be built with the Fortran compiler employed by 
the user and will generate the mpi module used by MPI code (there’s no mpi_f08 
module provided). However, I don’t know how to handle this: If I add it to 
MPI::MPI_Fortran via INTERFACE_SOURCES, then it would break parallel builds as 
soon as two targets with the same module path were built, since the file could 
be overwritten at any time causing consuming build processes to read a 
partially written file.

In a way, FindMPI would need to compile the file itself as a static library and 
link the output and add the folder with the module to its includes. Yet, this 
can become a problem because of target visibility. My idea is therefore to add 
a static library in the FindMPI module containing just the mpi.f90 module and 
creating an imported target pointing to it in order to wrap up visibility.

Is this a good/bad idea or is there any way to do this in a proper fashion? The 
idea of adding an actual target to a Find module seems wrong to me, but I’m not 
seeing any way of doing it otherwise.


For reference, I’ve added the full list of steps that one needs to do for 
linking Fortran code with MSMPI below:

  1.  Add the x86/x64 include folder in the MSMPI folder containing mpifptr.h 
(not a problem at all)
  2.  Link one of msmpifec/es/mc/ms.lib – The difference between these 
libraries is that the ‘c’/’s’ versions are for Fortran implementations using 
the ‘cdecl’ and ‘stdcall’ calling conventions, respectively. The ’m’ versions 
are for Fortran implementations putting the size of a CHARACTER* argument 
immediately after the pointer in a call’s parameter list, and the ‘e’ ones for 
those that put them at the end of the parameter list.

For virtually all Fortran compilers (including PGI and Intel), the msmpifec is 
the right library and the msmpifms one is only needed for Compaq Visual Fortran 
(Intel Fortran predecessor) or when changing the default in ifort, see also 
https://software.intel.com/en-us/node/528352 for MKL’s handling of the matter.

I believe jus using the ‘ec’ version in all cases is therefore okay for CMake, 
and I wouldn’t know of a good way to otherwise detect a correct value.

  1.  (Only if the Fortran 90 mpi module is to be used. Not necessary for the 
F77 interfaces) Compile mpi.f90, link the output and include the folder 
containing the emitted Fortran module.

- Chris
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers