Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 07:50:57

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/Plugins/ExaTrkX/detail/CudaUtils.hpp>
0012 #include <Acts/Utilities/Logger.hpp>
0013 
0014 #ifndef ACTS_EXATRKX_CPUONLY
0015 #include <cuda_runtime_api.h>
0016 #endif
0017 
0018 namespace {
0019 
0020 inline void printCudaMemInfo(const Acts::Logger& logger) {
0021 #ifndef ACTS_EXATRKX_CPUONLY
0022   if (logger.level() == Acts::Logging::VERBOSE) {
0023     constexpr float kb = 1024;
0024     constexpr float mb = kb * kb;
0025 
0026     int device{};
0027     std::size_t free{}, total{};
0028     ACTS_CUDA_CHECK(cudaMemGetInfo(&free, &total));
0029     ACTS_CUDA_CHECK(cudaGetDevice(&device));
0030 
0031     ACTS_VERBOSE("Current CUDA device: " << device);
0032     ACTS_VERBOSE("Memory (used / total) [in MB]: " << (total - free) / mb
0033                                                    << " / " << total / mb);
0034   } else {
0035     ACTS_VERBOSE("No memory info, CUDA disabled");
0036   }
0037 #else
0038   ACTS_VERBOSE("No memory info, CUDA disabled");
0039 #endif
0040 }
0041 
0042 }  // namespace