MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / copy

Function copy

src/backend/cuda/kernel/memcopy.hpp:172–207  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170
171template<typename inType, typename outType>
172void copy(Param<outType> dst, CParam<inType> src, dim_t ondims,
173 outType default_value, double factor) {
174 const size_t totalSize{dst.elements() * sizeof(outType) +
175 src.elements() * sizeof(inType)};
176 bool same_dims{true};
177 for (dim_t i{0}; i < ondims; ++i) {
178 if (src.dims[i] > dst.dims[i]) {
179 src.dims[i] = dst.dims[i];
180 } else if (src.dims[i] != dst.dims[i]) {
181 same_dims = false;
182 }
183 }
184 removeEmptyColumns(dst.dims, ondims, src.dims, src.strides);
185 ondims = removeEmptyColumns(dst.dims, ondims, dst.dims, dst.strides);
186 ondims =
187 combineColumns(dst.dims, dst.strides, ondims, src.dims, src.strides);
188
189 threadsMgt<dim_t> th(dst.dims, ondims);
190 const dim3 threads{th.genThreads()};
191 const dim3 blocks{th.genBlocks(threads, 1, 1, totalSize, sizeof(outType))};
192
193 EnqueueArgs qArgs(blocks, threads, getActiveStream());
194
195 auto copy{common::getKernel(
196 th.loop0 ? "arrayfire::cuda::scaledCopyLoop0"
197 : (th.loop2 || th.loop3) ? "arrayfire::cuda::scaledCopyLoop123"
198 : th.loop1 ? "arrayfire::cuda::scaledCopyLoop1"
199 : "arrayfire::cuda::scaledCopy",
200 {{copy_cuh_src}},
201 TemplateArgs(TemplateTypename<inType>(), TemplateTypename<outType>(),
202 TemplateArg(same_dims), TemplateArg(factor != 1.0)))};
203
204 copy(qArgs, dst, src, default_value, factor);
205
206 POST_LAUNCH_CHECK();
207}
208} // namespace kernel
209} // namespace cuda
210} // namespace arrayfire

Callers

nothing calls this directly

Calls 9

removeEmptyColumnsFunction · 0.85
combineColumnsFunction · 0.85
getActiveStreamFunction · 0.85
TemplateArgsFunction · 0.85
TemplateArgClass · 0.85
genThreadsMethod · 0.80
genBlocksMethod · 0.80
getKernelFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected