|
|
|||
File indexing completed on 2026-11-03 10:19:21
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 0015 namespace celeritas 0016 { 0017 //---------------------------------------------------------------------------// 0018 /*! 0019 * Save and restore CUDA limits inside the current scope. 0020 * 0021 * This is useful for calling poorly behaved external libraries that change 0022 * CUDA limits unexpectedly. We don't use this with HIP because it's only 0023 * needed at present for VecGeom. 0024 */ 0025 class ScopedLimitSaver 0026 { 0027 public: 0028 ScopedLimitSaver(); 0029 ~ScopedLimitSaver(); 0030 0031 //!@{ 0032 //! Prevent copying and moving for RAII class 0033 CELER_DELETE_COPY_MOVE(ScopedLimitSaver); 0034 //!@} 0035 0036 private: 0037 Array<std::size_t, 2> orig_limits_; 0038 }; 0039 0040 //---------------------------------------------------------------------------// 0041 // INLINE DEFINITIONS 0042 //---------------------------------------------------------------------------// 0043 #if !CELERITAS_USE_CUDA 0044 // Construction is a null-op since we only save with CUDA 0045 inline ScopedLimitSaver::ScopedLimitSaver() 0046 { 0047 CELER_DISCARD(orig_limits_); 0048 if constexpr (CELERITAS_USE_HIP) 0049 { 0050 CELER_NOT_IMPLEMENTED("HIP limit restoration"); 0051 } 0052 } 0053 0054 // Destruction is a null-op since we only save with CUDA 0055 inline ScopedLimitSaver::~ScopedLimitSaver() {} 0056 #endif 0057 0058 //---------------------------------------------------------------------------// 0059 } // 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 |
|