Skip to content

Commit

Permalink
Add device memory info on debug options (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
koparasy committed Nov 9, 2023
1 parent a0d3055 commit 372239f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
6 changes: 4 additions & 2 deletions src/ml/hdcache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,11 @@ class HDCache
PERFFASPECT()
inline void _evaluate(const size_t ndata, bool *is_acceptable) const
{
if (cache_location == AMSResourceType::HOST) {
if (cache_location == AMSResourceType::DEVICE) {
#ifdef __ENABLE_CUDA__
random_uq_Device<<<1, 1>>>(is_acceptable, ndata, acceptable_error);
random_uq_device<<<1, 1>>>(is_acceptable, ndata, acceptable_error);
#else
THROW(std::runtime_error, "Random-uq is not configured to use device allocations");
#endif
} else {
random_uq_host(is_acceptable, ndata, acceptable_error);
Expand Down
39 changes: 22 additions & 17 deletions src/wf/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,28 @@ inline uint32_t getVerbosityLevel()

#define DBG(id, ...) CDEBUG(id, true, __VA_ARGS__)

#define REPORT_MEM_USAGE(id, phase) \
do { \
double vm, rs; \
size_t watermark, current_size, actual_size; \
memUsage(vm, rs); \
ams::ResourceManager::getAllocatorStats(AMSResourceType::HOST, \
watermark, \
current_size, \
actual_size); \
DBG(id, \
"Memory usage at %s is VM:%g RS:%g HWM:%lu CS:%lu AS:%lu) ", \
phase, \
vm, \
rs, \
watermark, \
current_size, \
actual_size); \
#define REPORT_MEM_USAGE(id, phase) \
do { \
double vm, rs; \
size_t watermark, current_size, actual_size; \
memUsage(vm, rs); \
DBG(id, "Memory usage at %s is VM:%g RS:%g\n", phase, \
vm, \
rs); \
\
for (int i = 0; i < AMSResourceType::RSEND; i++){ \
if ( ams::ResourceManager::isActive((AMSResourceType) i) ){ \
ams::ResourceManager::getAllocatorStats((AMSResourceType) i, \
watermark, \
current_size, \
actual_size); \
DBG(id, "Allocator: %s HWM:%lu CS:%lu AS:%lu) ", \
ams::ResourceManager::getAllocatorName((AMSResourceType) i).c_str(),\
watermark, \
current_size, \
actual_size); \
} \
} \
} while (0);

#define THROW(exception, msg) \
Expand Down
4 changes: 4 additions & 0 deletions src/wf/resource_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ class ResourceManager
RMAllocators[resource]->getName().c_str());
}

static bool isActive(AMSResourceType resource){
return RMAllocators[resource] != nullptr;
}

/** @brief Returns the memory consumption of the given resource as measured from Umpire.
* @param[in] resource The memory pool to get the consumption from.
* @param[out] wm the highest memory allocation that umpire has performed until now.
Expand Down

0 comments on commit 372239f

Please sign in to comment.