Commit eb8b40dc authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

MPI: added function for timing Allreduce operations

parent 0742d2a2
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include "MPI/DummyDefs.h"
#include "MPI/getDataType.h"
#include "MPI/Profiling.h"
#include "MPI/selectGPU.h"
#include "MPI/Wrappers.h"
#include "MPI/Utils.h"
+25 −0
Original line number Diff line number Diff line
/***************************************************************************
                          MPI/Profiling.h  -  description
                             -------------------
    begin                : Jan 1, 2021
    copyright            : (C) 2021 by Tomas Oberhuber et al.
    email                : tomas.oberhuber@fjfi.cvut.cz
 ***************************************************************************/

/* See Copyright Notice in tnl/Copyright */

#pragma once

#include <TNL/Timer.h>

namespace TNL {
namespace MPI {

inline Timer& getTimerAllreduce()
{
   static Timer t;
   return t;
}

} // namespace MPI
} // namespace TNL
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@

#include <TNL/Assert.h>
#include "getDataType.h"
#include "Profiling.h"

namespace TNL {
namespace MPI {
@@ -278,7 +279,9 @@ void Allreduce( const T* data,
{
#ifdef HAVE_MPI
   TNL_ASSERT_NE( group, NullGroup(), "Allreduce cannot be called with NullGroup" );
   getTimerAllreduce().start();
   MPI_Allreduce( (const void*) data, (void*) reduced_data, count, getDataType<T>(), op, group );
   getTimerAllreduce().stop();
#else
   std::memcpy( (void*) reduced_data, (const void*) data, count * sizeof(T) );
#endif
@@ -293,7 +296,9 @@ void Allreduce( T* data,
{
#ifdef HAVE_MPI
   TNL_ASSERT_NE( group, NullGroup(), "Allreduce cannot be called with NullGroup" );
   getTimerAllreduce().start();
   MPI_Allreduce( MPI_IN_PLACE, (void*) data, count, getDataType<T>(), op, group );
   getTimerAllreduce().stop();
#endif
}