![]() |
|
|||
File indexing completed on 2025-09-17 08:54:09
0001 //------------------------------- -*- C++ -*- -------------------------------// 0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details 0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0004 //---------------------------------------------------------------------------// 0005 //! \file corecel/sys/ScopedLimitSaver.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <cstddef> 0010 0011 #include "corecel/Assert.hh" 0012 #include "corecel/Macros.hh" 0013 #include "corecel/cont/Array.hh" 0014 #include "corecel/io/Logger.hh" 0015 0016 namespace celeritas 0017 { 0018 //---------------------------------------------------------------------------// 0019 /*! 0020 * Save and restore CUDA limits inside the current scope. 0021 * 0022 * This is useful for calling poorly behaved external libraries that change 0023 * CUDA limits unexpectedly. We don't use this with HIP because it's only 0024 * needed at present for VecGeom. 0025 */ 0026 class ScopedLimitSaver 0027 { 0028 public: 0029 ScopedLimitSaver(); 0030 ~ScopedLimitSaver(); 0031 0032 //!@{ 0033 //! Prevent copying and moving for RAII class 0034 CELER_DELETE_COPY_MOVE(ScopedLimitSaver); 0035 //!@} 0036 0037 private: 0038 Array<std::size_t, 2> orig_limits_; 0039 }; 0040 0041 //---------------------------------------------------------------------------// 0042 // INLINE DEFINITIONS 0043 //---------------------------------------------------------------------------// 0044 #if !CELERITAS_USE_CUDA 0045 // Construction is a null-op since we only save with CUDA 0046 inline ScopedLimitSaver::ScopedLimitSaver() 0047 { 0048 CELER_DISCARD(orig_limits_); 0049 if constexpr (CELERITAS_USE_HIP) 0050 { 0051 CELER_NOT_IMPLEMENTED("HIP limit restoration"); 0052 } 0053 } 0054 0055 // Destruction is a null-op since we only save with CUDA 0056 inline ScopedLimitSaver::~ScopedLimitSaver() {} 0057 #endif 0058 0059 //---------------------------------------------------------------------------// 0060 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |