Skip to content

Commit

Permalink
Merge pull request #33 from LLNL/bugfix/UM-266-guard-usage-of-cxx_dem…
Browse files Browse the repository at this point in the history
…angle-and-add.2

Moved Replay from util library to umpire library since it uses objects
  • Loading branch information
mcfadden8 authored Dec 11, 2018
2 parents 9a968cc + 0441b7f commit 58ccc1e
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
1 change: 1 addition & 0 deletions src/umpire/Allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "umpire/ResourceManager.hpp"
#include "umpire/util/Macros.hpp"
#include "umpire/Replay.hpp"

#if defined(UMPIRE_ENABLE_STATISTICS)
#include "umpire/util/StatisticsDatabase.hpp"
Expand Down
2 changes: 2 additions & 0 deletions src/umpire/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
##############################################################################
set (umpire_headers
Allocator.hpp
Replay.hpp
ResourceManager.hpp
ResourceManager.inl
TypedAllocator.hpp
Expand All @@ -22,6 +23,7 @@ set (umpire_headers

set (umpire_sources
Allocator.cpp
Replay.cpp
ResourceManager.cpp)

if (ENABLE_FORTRAN_API OR ENABLE_C_API)
Expand Down
6 changes: 3 additions & 3 deletions src/umpire/util/Replay.cpp → src/umpire/Replay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
// For details, see https://github.com/LLNL/Umpire
// Please also see the LICENSE file for MIT license.
//////////////////////////////////////////////////////////////////////////////
#include "umpire/util/Replay.hpp"

#include <iostream> // for std::cout, std::cerr
#include <stdlib.h> // for getenv()
#include <strings.h> // for strcasecmp()
#include "umpire/Allocator.hpp"
#include "umpire/Replay.hpp"

namespace umpire {
namespace util {
namespace replay {

static const char* env_name = "UMPIRE_REPLAY";
Replay* Replay::s_Replay = nullptr;
Expand Down Expand Up @@ -76,5 +76,5 @@ std::ostream& operator<< (std::ostream& out, umpire::Allocator& alloc) {
return out;
}

} /* namespace util */
} /* namespace replay */
} /* namespace umpire */
23 changes: 20 additions & 3 deletions src/umpire/util/Replay.hpp → src/umpire/Replay.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,27 @@
#include <sstream>
#include <iostream>
#include "umpire/Allocator.hpp"
#include <cxxabi.h>

#define UMPIRE_REPLAY( msg ) \
{ \
if (umpire::replay::Replay::getReplayLogger()->replayLoggingEnabled()) { \
std::ostringstream local_msg; \
local_msg << "REPLAY," << msg; \
umpire::replay::Replay::getReplayLogger()->logMessage(local_msg.str());\
} \
}

#define UMPIRE_REPLAY_CONT( msg ) \
{ \
if (umpire::replay::Replay::getReplayLogger()->replayLoggingEnabled()) { \
std::ostringstream local_msg; \
local_msg << "," << msg; \
umpire::replay::Replay::getReplayLogger()->logMessage(local_msg.str());\
} \
}

namespace umpire {
namespace util {
namespace replay {
std::ostream& operator<< (std::ostream& out, umpire::Allocator& alloc);
class Replay {
public:
Expand Down Expand Up @@ -51,7 +68,7 @@ class Replay {
static Replay* s_Replay;
};

} /* namespace util */
} /* namespace replay */
} /* namespace umpire */

#endif /* UMPIRE_Replay_HPP */
4 changes: 3 additions & 1 deletion src/umpire/ResourceManager.inl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
#include "umpire/ResourceManager.hpp"

#include <sstream>
#include <cxxabi.h>

#include "umpire/util/Macros.hpp"
#include "umpire/Replay.hpp"
#include "umpire/strategy/AllocationTracker.hpp"

namespace umpire {
Expand All @@ -42,7 +44,7 @@ Allocator ResourceManager::makeAllocator(
<< abi::__cxa_demangle(typeid(Strategy).name(),nullptr,nullptr,nullptr)
<< "," << (introspection ? "true" : "false")
<< "," << name
<< umpire::util::Replay::printReplayAllocator(std::forward<Args>(args)...)
<< umpire::replay::Replay::printReplayAllocator(std::forward<Args>(args)...)
);

if (isAllocator(name)) {
Expand Down
6 changes: 2 additions & 4 deletions src/umpire/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ set (umpire_util_headers
Exception.hpp
Logger.hpp
Macros.hpp
Platform.hpp
Replay.hpp)
Platform.hpp)

if (ENABLE_STATISTICS)
set (umpire_util_headers
Expand All @@ -32,8 +31,7 @@ endif()
set (umpire_util_sources
AllocationMap.cpp
Exception.cpp
Logger.cpp
Replay.cpp)
Logger.cpp)

if (ENABLE_STATISTICS)
set (umpire_util_sources
Expand Down
19 changes: 0 additions & 19 deletions src/umpire/util/Macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,25 +119,6 @@

#endif // defined(UMPIRE_ENABLE_STATISTICS)

#include "umpire/util/Replay.hpp"
#define UMPIRE_REPLAY( msg ) \
{ \
if (umpire::util::Replay::getReplayLogger()->replayLoggingEnabled()) { \
std::ostringstream local_msg; \
local_msg << "REPLAY," << msg; \
umpire::util::Replay::getReplayLogger()->logMessage(local_msg.str());\
} \
}

#define UMPIRE_REPLAY_CONT( msg ) \
{ \
if (umpire::util::Replay::getReplayLogger()->replayLoggingEnabled()) { \
std::ostringstream local_msg; \
local_msg << "," << msg; \
umpire::util::Replay::getReplayLogger()->logMessage(local_msg.str());\
} \
}

#define UMPIRE_LOCK \
if ( !m_mutex->try_lock() ) \
m_mutex->lock();
Expand Down

0 comments on commit 58ccc1e

Please sign in to comment.