Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /acts/Plugins/Gnn/src/printCudaMemInfo.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/Logger.hpp"
0012 #ifndef ACTS_GNN_CPUONLY
0013 #include <ActsPlugins/Gnn/detail/CudaUtils.hpp>
0014 #endif
0015 
0016 #ifndef ACTS_GNN_CPUONLY
0017 #include <cuda_runtime_api.h>
0018 #endif
0019 
0020 namespace {
0021 
0022 inline void printCudaMemInfo(const Acts::Logger& logger) {
0023 #ifndef ACTS_GNN_CPUONLY
0024   if (logger.level() == Acts::Logging::VERBOSE) {
0025     constexpr float kb = 1024;
0026     constexpr float mb = kb * kb;
0027 
0028     int device{};
0029     std::size_t free{}, total{};
0030     ACTS_CUDA_CHECK(cudaMemGetInfo(&free, &total));
0031     ACTS_CUDA_CHECK(cudaGetDevice(&device));
0032 
0033     ACTS_VERBOSE("Current CUDA device: " << device);
0034     ACTS_VERBOSE("Memory (used / total) [in MB]: " << (total - free) / mb
0035                                                    << " / " << total / mb);
0036   } else {
0037     ACTS_VERBOSE("No memory info, CUDA disabled");
0038   }
0039 #else
0040   ACTS_VERBOSE("No memory info, CUDA disabled");
0041 #endif
0042 }
0043 
0044 }  // namespace