|
||||
File indexing completed on 2025-01-18 09:54:47
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file corecel/data/ParamsDataInterface.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/Assert.hh" 0011 #include "corecel/Macros.hh" 0012 #include "corecel/Types.hh" 0013 0014 #include "Ref.hh" 0015 0016 namespace celeritas 0017 { 0018 //---------------------------------------------------------------------------// 0019 /*! 0020 * Interface class for accessing parameter data. 0021 */ 0022 template<template<Ownership, MemSpace> class P> 0023 class ParamsDataInterface 0024 { 0025 public: 0026 //!@{ 0027 //! \name Type aliases 0028 using HostRef = HostCRef<P>; 0029 using DeviceRef = DeviceCRef<P>; 0030 //!@} 0031 0032 //! Reference CPU geometry data 0033 virtual HostRef const& host_ref() const = 0; 0034 0035 //! Reference managed GPU geometry data 0036 virtual DeviceRef const& device_ref() const = 0; 0037 0038 // Dispatch a "ref" call to host or device data 0039 template<MemSpace M> 0040 inline P<Ownership::const_reference, M> const& ref() const; 0041 0042 protected: 0043 // Protected destructor prevents deletion of pointer-to-interface 0044 ~ParamsDataInterface() = default; 0045 0046 // Prohibit copy/move beween interface classes 0047 ParamsDataInterface() = default; 0048 CELER_DEFAULT_COPY_MOVE(ParamsDataInterface); 0049 }; 0050 0051 //---------------------------------------------------------------------------// 0052 // INLINE DEFINITIONS 0053 //---------------------------------------------------------------------------// 0054 /*! 0055 * Dispatch a "ref" call to host or device data. 0056 */ 0057 template<template<Ownership, MemSpace> class P> 0058 template<MemSpace M> 0059 P<Ownership::const_reference, M> const& ParamsDataInterface<P>::ref() const 0060 { 0061 // Note: CUDA 11.4.2 + GCC 11.2.0 doesn't support 'if constexpr' 0062 return get_ref<M>(*this); 0063 } 0064 0065 //---------------------------------------------------------------------------// 0066 } // 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 |