MCPcopy Create free account
hub / github.com/catboost/catboost / TSingleMapping

Class TSingleMapping

catboost/cuda/cuda_lib/mapping.h:83–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 };
82
83 class TSingleMapping: public TMappingBase<TSingleMapping> {
84 protected:
85 ui64 Count = 0;
86 ui32 DeviceId = 0;
87
88 public:
89 using TMappingBase::TMeta;
90
91 explicit TSingleMapping(ui32 devId = 0, ui64 count = 0, ui64 size = 1)
92 : TMappingBase(size)
93 , Count(count)
94 , DeviceId(devId)
95 {
96 }
97
98 explicit TSingleMapping(TVector<TSlice>&& slices, ui64 singleObjectSize = 1)
99 : TMappingBase(singleObjectSize)
100 {
101 CB_ENSURE(slices.size() == NCudaLib::GetCudaManager().GetDeviceCount());
102
103 bool initDone = false;
104 for (ui32 i = 0; i < slices.size(); ++i) {
105 if (slices[i].Size()) {
106 CB_ENSURE(!initDone);
107 initDone = true;
108 DeviceId = i;
109 Count = slices[i].Size();
110 }
111 }
112 }
113
114 TSlice GetObjectsSlice() const {
115 return {0, Count};
116 }
117
118 ui64 CountAt(ui64 dev) const {
119 if (dev != DeviceId) {
120 return 0;
121 }
122 return Count;
123 }
124
125 ui32 GetDeviceId() const {
126 return DeviceId;
127 }
128
129 TSingleMapping ToLocalSlice(const TSlice& slice) const {
130 CB_ENSURE(GetObjectsSlice().Contains(slice));
131 return TSingleMapping(DeviceId, slice.Size(), SingleObjectSize());
132 }
133
134 TSlice DeviceSlice(ui64 dev) const {
135 if (dev != DeviceId) {
136 return {0, 0};
137 }
138 return {0, Count};
139 }
140

Callers 5

ToLocalSliceMethod · 0.70
RepeatOnAllDevicesMethod · 0.70
TransformMethod · 0.70
ChangeDeviceMethod · 0.70
BuildMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected