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

Method PrepareContext

catboost/cuda/cuda_util/sort.cpp:134–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132 }
133
134 THolder<TKernelContext> PrepareContext(IMemoryManager& manager) const {
135 CB_ENSURE(Keys.Size() == Keys.ObjectCount(), LabeledOutput(Keys.Size(), Keys.ObjectCount()));
136 CB_ENSURE(Keys.Size() < (static_cast<ui64>(1) << 32), LabeledOutput(Keys.Size()));
137
138 const ui32 size = Keys.Size();
139 const ui32 valueSize = Values.Size() ? sizeof(V) : 0;
140 if (valueSize) {
141 CB_ENSURE(Values.Size() == Keys.Size());
142 }
143 auto context = MakeHolder<TKernelContext>(FirstBit, LastBit, valueSize, CompareGreater);
144 context->UseExternalBufferForTempKeysAndValues = TmpKeys.Size() > 0;
145
146 if (size) {
147 //fill temp storage size by cub
148 CUDA_SAFE_CALL(NKernel::RadixSort((K*)nullptr, (TValueStorage*)nullptr, size, *context, 0));
149 if (context->UseExternalBufferForTempKeysAndValues) {
150 AllocateMemory<true>(manager, size, *context);
151 } else {
152 AllocateMemory<false>(manager, size, *context);
153 }
154 }
155 return context;
156 }
157
158 void Run(const TCudaStream& stream, TKernelContext& context) const {
159 const ui32 size = SafeIntegerCast<ui32>(Keys.Size());

Callers

nothing calls this directly

Calls 2

SizeMethod · 0.45
ObjectCountMethod · 0.45

Tested by

no test coverage detected