Commit 8a1d5730 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Added MPISupportMissing exception.

Code refactoring.
parent ea92aee6
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
SET( headers MpiCommunicator.h
             NoDistrCommunicator.h )
             MpiDefs.h             
             NoDistrCommunicator.h 
    )

INSTALL( FILES ${headers} DESTINATION ${TNL_TARGET_INCLUDE_DIRECTORY}/Communicators )
+42 −35
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@

#include <TNL/String.h>
#include <TNL/Logger.h>
#include <TNL/Communicators/MpiDefs.h>
#include <TNL/Config/ConfigDescription.h>
#include <TNL/Exceptions/MPISupportMissing.h>

namespace TNL {
namespace Communicators {
@@ -138,8 +140,7 @@ class MpiCommunicator
        TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
        return MPI::COMM_WORLD.Get_rank();
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
        return 0;
        throw Exceptions::MPISupportMissing();
#endif
      };

@@ -149,8 +150,7 @@ class MpiCommunicator
        TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
        return MPI::COMM_WORLD.Get_size();
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
        return 0;
        throw Exceptions::MPISupportMissing();
#endif
      };

@@ -185,7 +185,7 @@ class MpiCommunicator
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
            MPI::COMM_WORLD.Barrier();;
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
            throw Exceptions::MPISupportMissing();
#endif     
        };

@@ -196,8 +196,7 @@ class MpiCommunicator
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
            return MPI::COMM_WORLD.Isend((void*) data, count, MPIDataType(data) , dest, 0);
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
        return 0;
            throw Exceptions::MPISupportMissing();
#endif  
        }    

@@ -208,8 +207,7 @@ class MpiCommunicator
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
            return MPI::COMM_WORLD.Irecv((void*) data, count, MPIDataType(data) , src, 0);
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
        return 0;
            throw Exceptions::MPISupportMissing();
#endif  
        }

@@ -219,9 +217,8 @@ class MpiCommunicator
            TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
            MPI::Request::Waitall(length, reqs);
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
            throw Exceptions::MPISupportMissing();
#endif

        };

        template< typename T > 
@@ -231,7 +228,7 @@ class MpiCommunicator
        TNL_ASSERT_TRUE(IsInitialized(), "Fatal Error - MPI communicator is not inicialized");
        MPI::COMM_WORLD.Bcast((void*) &data, count,  MPIDataType(data), root);
#else
        TNL_ASSERT_TRUE(false, "Fatal Error - MPI in not compiled");
        throw Exceptions::MPISupportMissing();
#endif  
        }

@@ -241,9 +238,14 @@ class MpiCommunicator
                               int count,
                               const MPI_Op &op )
        {
#ifdef HAVE_MPI
            MPI::COMM_WORLD.Allreduce( (void*) data, (void*) reduced_data,count,MPIDataType(data),op);
#else
            throw Exceptions::MPISupportMissing();
#endif            
        };


         template< typename T >
         static void Reduce( T* data,
                    T* reduced_data,
@@ -251,9 +253,14 @@ class MpiCommunicator
                    MPI_Op &op,
                    int root)
         {
#ifdef HAVE_MPI
            MPI::COMM_WORLD.Reduce( (void*) data, (void*) reduced_data,count,MPIDataType(data),op,root);
#else
            throw Exceptions::MPISupportMissing();
#endif
        };


      static void writeProlog( Logger& logger ) 
      {
         if( isDistributed() )
+15 −0
Original line number Diff line number Diff line
/***************************************************************************
                          MpiCommunicator.h  -  description
                             -------------------
    begin                : 2005/04/23
    copyright            : (C) 2005 by Tomas Oberhuber
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

#pragma once

#ifndef HAVE_MPI
enum MPI_Op { MPI_SUM, MPI_MAX };
#endif
 No newline at end of file
+1 −2
Original line number Diff line number Diff line
@@ -11,11 +11,10 @@
#pragma once

#include <TNL/Logger.h>
#include <TNL/Communicators/MpiDefs.h>

#ifdef HAVE_MPI
#include <mpi.h>
#else
enum MPI_Op { MPI_SUM, MPI_MAX };
#endif

namespace TNL {
+2 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ SET( headers CudaBadAlloc.h
             CudaRuntimeError.h
             CudaSupportMissing.h
             MICBadAlloc.h
             MICSupportMissing.h )
             MICSupportMissing.h
             MPISupportMissing.h )

INSTALL( FILES ${headers} DESTINATION ${TNL_TARGET_INCLUDE_DIRECTORY}/Exceptions )
Loading