File indexing completed on 2025-02-22 10:31:22
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "corecel/Types.hh"
0011 #include "corecel/data/Collection.hh"
0012 #include "corecel/data/CollectionBuilder.hh"
0013 #include "corecel/sys/ThreadId.hh"
0014 #include "celeritas/Types.hh"
0015
0016 namespace celeritas
0017 {
0018 namespace detail
0019 {
0020
0021 template<MemSpace M>
0022 class CoreStateThreadOffsets;
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 template<>
0033 class CoreStateThreadOffsets<MemSpace::host>
0034 {
0035 public:
0036
0037
0038 using NativeActionThreads
0039 = Collection<ThreadId, Ownership::value, MemSpace::host, ActionId>;
0040 using HostActionThreads = NativeActionThreads;
0041
0042
0043 public:
0044 auto& host_action_thread_offsets() { return thread_offsets_; }
0045 auto const& host_action_thread_offsets() const { return thread_offsets_; }
0046 auto& native_action_thread_offsets() { return thread_offsets_; }
0047 auto const& native_action_thread_offsets() const
0048 {
0049 return thread_offsets_;
0050 }
0051
0052
0053 void resize(size_type n) { celeritas::resize(&thread_offsets_, n); }
0054
0055
0056 bool empty() const { return thread_offsets_.empty(); }
0057
0058 private:
0059 NativeActionThreads thread_offsets_;
0060 };
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 template<>
0071 class CoreStateThreadOffsets<MemSpace::device>
0072 {
0073 public:
0074
0075
0076 using NativeActionThreads
0077 = Collection<ThreadId, Ownership::value, MemSpace::device, ActionId>;
0078 using HostActionThreads
0079 = Collection<ThreadId, Ownership::value, MemSpace::mapped, ActionId>;
0080
0081
0082 public:
0083 auto& host_action_thread_offsets() { return host_thread_offsets_; }
0084 auto const& host_action_thread_offsets() const
0085 {
0086 return host_thread_offsets_;
0087 }
0088 auto& native_action_thread_offsets() { return thread_offsets_; }
0089 auto const& native_action_thread_offsets() const
0090 {
0091 return thread_offsets_;
0092 }
0093 void resize(size_type n)
0094 {
0095 celeritas::resize(&thread_offsets_, n);
0096 celeritas::resize(&host_thread_offsets_, n);
0097 }
0098
0099
0100 bool empty() const { return thread_offsets_.empty(); }
0101
0102 private:
0103 NativeActionThreads thread_offsets_;
0104 HostActionThreads host_thread_offsets_;
0105 };
0106
0107
0108 }
0109 }