Branch data Line data Source code
1 : : // *****************************************************************************
2 : : /*!
3 : : \file src/Main/LBSwitch.hpp
4 : : \copyright 2012-2015 J. Bakosi,
5 : : 2016-2018 Los Alamos National Security, LLC.,
6 : : 2019-2021 Triad National Security, LLC.,
7 : : 2022-2025 J. Bakosi
8 : : All rights reserved. See the LICENSE file for details.
9 : : \brief Charm++ chare group for switching on/off load balancing
10 : : \details Charm++ chare group for switching on/off load balancing.
11 : : */
12 : : // *****************************************************************************
13 : : #ifndef LBSwitch_h
14 : : #define LBSwitch_h
15 : :
16 : : #include "Print.hpp"
17 : :
18 : : #include "NoWarning/lbswitch.decl.h"
19 : :
20 : : namespace tk {
21 : :
22 : : //! Load balancer switch Charm++ chare group class
23 : : //! \details Instantiations of LBSwitch comprise a processor aware
24 : : //! Charm++ chare group. When instantiated, a new object is created on each
25 : : //! PE and not more (as opposed to individual chares or chare array object
26 : : //! elements). See also the Charm++ interface file lbswitch.ci.
27 : : class LBSwitch : public CBase_LBSwitch {
28 : :
29 : : public:
30 : : //! Constructor: turn on automatic load balancing
31 : : explicit LBSwitch();
32 : :
33 : : #if defined(__clang__)
34 : : #pragma clang diagnostic push
35 : : #pragma clang diagnostic ignored "-Wundefined-func-template"
36 : : #endif
37 : : //! Migrate constructor
38 : 30 : explicit LBSwitch( CkMigrateMessage* m ) : CBase_LBSwitch( m ) {
39 [ + - ]: 30 : TurnManualLBOff();
40 [ + + ]: 30 : if (CkMyPe() == 0) Print() << "Xyst> Load balancing on\n";
41 : 30 : }
42 : : #if defined(__clang__)
43 : : #pragma clang diagnostic pop
44 : : #endif
45 : :
46 : : //! Turn off automatic load balancing
47 : : static void off();
48 : :
49 : : /** @name Charm++ pack/unpack serializer member functions */
50 : : ///@{
51 : : //! \brief Pack/Unpack serialize member function
52 : : //! \note This is a Charm++ group, pup() is thus only for
53 : : //! checkpoint/restart.
54 : 0 : void pup( PUP::er& ) override {}
55 : : //! \brief Pack/Unpack serialize operator|
56 : : //! \param[in,out] p Charm++'s PUP::er serializer object reference
57 : : //! \param[in,out] m LBSwitch object reference
58 : : friend void operator|( PUP::er& p, LBSwitch& m ) { m.pup(p); }
59 : : //@}
60 : : };
61 : :
62 : : } // tk::
63 : :
64 : : #endif // LBSwitch_h
|