|
||||
File indexing completed on 2025-01-18 09:54:50
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2020-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 /*! 0007 * \file corecel/Types.hh 0008 * \brief Type definitions for common Celeritas functionality. 0009 * 0010 * This file includes types and properties particular to the build 0011 * configuration. 0012 */ 0013 //---------------------------------------------------------------------------// 0014 #pragma once 0015 0016 #include <cstddef> 0017 #include <string> 0018 0019 #include "corecel/Config.hh" 0020 0021 #include "Macros.hh" 0022 0023 namespace celeritas 0024 { 0025 //---------------------------------------------------------------------------// 0026 #if CELER_USE_DEVICE || defined(__DOXYGEN__) 0027 //! Standard type for container sizes, optimized for GPU use 0028 using size_type = unsigned int; 0029 #else 0030 using size_type = std::size_t; 0031 #endif 0032 0033 #if CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_DOUBLE 0034 //! Numerical type for real numbers 0035 using real_type = double; 0036 #elif CELERITAS_REAL_TYPE == CELERITAS_REAL_TYPE_FLOAT 0037 using real_type = float; 0038 #else 0039 using real_type = void; 0040 #endif 0041 0042 //! Equivalent to std::size_t but compatible with CUDA atomics 0043 using ull_int = unsigned long long int; 0044 0045 //---------------------------------------------------------------------------// 0046 // ENUMERATIONS 0047 //---------------------------------------------------------------------------// 0048 //! Memory location of data 0049 enum class MemSpace 0050 { 0051 host, //!< CPU memory 0052 device, //!< GPU memory 0053 mapped, //!< Unified virtual address space (both host and device) 0054 size_, 0055 #ifdef CELER_DEVICE_SOURCE 0056 native = device, //!< When included by a CUDA/HIP file; else 'host' 0057 #else 0058 native = host, 0059 #endif 0060 }; 0061 0062 //! Data ownership flag 0063 enum class Ownership 0064 { 0065 value, //!< Ownership of the data, only on host 0066 reference, //!< Mutable reference to the data 0067 const_reference, //!< Immutable reference to the data 0068 }; 0069 0070 //---------------------------------------------------------------------------// 0071 //! Unit system used by Celeritas 0072 enum class UnitSystem 0073 { 0074 none, //!< Invalid unit system 0075 cgs, //!< Gaussian CGS 0076 si, //!< International System 0077 clhep, //!< Geant4 native 0078 size_, 0079 native = CELERITAS_UNITS, //!< Compile time selected system 0080 }; 0081 0082 //---------------------------------------------------------------------------// 0083 //! Interpolation type 0084 enum class Interp 0085 { 0086 linear, 0087 log, 0088 size_ 0089 }; 0090 0091 //---------------------------------------------------------------------------// 0092 //!@{ 0093 //! \name Convenience typedefs for params and states. 0094 0095 //! Managed host memory 0096 template<template<Ownership, MemSpace> class P> 0097 using HostVal = P<Ownership::value, MemSpace::host>; 0098 //! Immutable reference to host memory 0099 template<template<Ownership, MemSpace> class P> 0100 using HostCRef = P<Ownership::const_reference, MemSpace::host>; 0101 //! Mutable reference to host memory 0102 template<template<Ownership, MemSpace> class S> 0103 using HostRef = S<Ownership::reference, MemSpace::host>; 0104 0105 //! Immutable reference to device memory 0106 template<template<Ownership, MemSpace> class P> 0107 using DeviceCRef = P<Ownership::const_reference, MemSpace::device>; 0108 //! Mutable reference to device memory 0109 template<template<Ownership, MemSpace> class S> 0110 using DeviceRef = S<Ownership::reference, MemSpace::device>; 0111 0112 //! Immutable reference to native memory 0113 template<template<Ownership, MemSpace> class P> 0114 using NativeCRef = P<Ownership::const_reference, MemSpace::native>; 0115 //! Mutable reference to native memory 0116 template<template<Ownership, MemSpace> class S> 0117 using NativeRef = S<Ownership::reference, MemSpace::native>; 0118 0119 template<class T, MemSpace M> 0120 class ObserverPtr; 0121 0122 //! Pointer to same-memory *const* collection group 0123 template<template<Ownership, MemSpace> class P, MemSpace M> 0124 using CRefPtr = ObserverPtr<P<Ownership::const_reference, M> const, M>; 0125 //! Pointer to same-memory *mutable* collection group 0126 template<template<Ownership, MemSpace> class S, MemSpace M> 0127 using RefPtr = ObserverPtr<S<Ownership::reference, M>, M>; 0128 0129 //!@} 0130 0131 //---------------------------------------------------------------------------// 0132 // HELPER FUNCTIONS (HOST) 0133 //---------------------------------------------------------------------------// 0134 0135 // Get a string corresponding to a memory space 0136 char const* to_cstring(MemSpace m); 0137 0138 // Get a string corresponding to a unit system 0139 char const* to_cstring(UnitSystem); 0140 0141 // Get a unit system corresponding to a string 0142 UnitSystem to_unit_system(std::string const& s); 0143 0144 //---------------------------------------------------------------------------// 0145 } // 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 |