LCOV - code coverage report
Current view: top level - tests - mpi.cpp (source / functions) Hit Total Coverage
Test: Lunchbox Lines: 14 17 82.4 %
Date: 2016-03-29 17:09:06 Functions: 3 3 100.0 %

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2014, Carlos Duelo <cduelo@cesvima.upm.es>
       3             :  *
       4             :  * This library is free software; you can redistribute it and/or modify it under
       5             :  * the terms of the GNU Lesser General Public License version 2.1 as published
       6             :  * by the Free Software Foundation.
       7             :  *
       8             :  * This library is distributed in the hope that it will be useful, but WITHOUT
       9             :  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
      10             :  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
      11             :  * details.
      12             :  *
      13             :  * You should have received a copy of the GNU Lesser General Public License
      14             :  * along with this library; if not, write to the Free Software Foundation, Inc.,
      15             :  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      16             :  */
      17             : 
      18             : // need to include mpi.h before stdio.h to work with Intel MPI
      19             : #ifdef LUNCHBOX_USE_MPI
      20             : #  include <mpi.h>
      21             : #endif
      22             : 
      23             : #include "test.h"
      24             : 
      25             : #include <lunchbox/mpi.h>
      26             : 
      27           1 : int main( int argc, char** argv )
      28             : {
      29           1 :     lunchbox::MPI mpi1;
      30           2 :     lunchbox::MPI mpi2( argc, argv );
      31           2 :     lunchbox::MPI mpi3( mpi1 );
      32             : 
      33           1 :     TEST( mpi1.getRank() == mpi2.getRank( ));
      34           1 :     TEST( mpi1.getSize() == mpi2.getSize( ));
      35           1 :     TEST( mpi1.supportsThreads() == mpi3.supportsThreads( ));
      36           1 :     TEST( mpi1.getRank() == mpi3.getRank( ));
      37           1 :     TEST( mpi1.getSize() == mpi3.getSize( ));
      38             : 
      39             : #ifdef LUNCHBOX_USE_MPI
      40           1 :     if( mpi1.getRank() == 0 )
      41             :     {
      42           1 :         int i = 58;
      43           1 :         MPI_Bcast( &i, 1, MPI_INT, 0, MPI_COMM_WORLD);
      44             :     }
      45             :     else
      46             :     {
      47           0 :         int i = -1;
      48           0 :         MPI_Bcast( &i, 1, MPI_INT, 0, MPI_COMM_WORLD);
      49           0 :         TEST( i == 58 );
      50             :     }
      51             : #endif
      52             : 
      53           2 :     return EXIT_SUCCESS;
      54           3 : }

Generated by: LCOV version 1.11