MCPcopy Create free account
hub / github.com/NVIDIA/DALI / daliOutputCopySamples

Function daliOutputCopySamples

dali/c_api/c_api.cc:666–702  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

664}
665
666void daliOutputCopySamples(daliPipelineHandle_t pipe_handle, void **dsts, int output_idx,
667 device_type_t dst_type, cudaStream_t stream, unsigned int flags) {
668 dali::DomainTimeRange tr("[DALI][C API] daliOutputCopySamples", dali::DomainTimeRange::kGreen);
669
670 bool is_pinned = flags & DALI_ext_pinned;
671 bool host_sync = flags & DALI_ext_force_sync;
672 bool use_copy_kernel = flags & DALI_use_copy_kernel;
673 auto dst_mem_kind = GetMemKind(dst_type, is_pinned);
674
675 dali::Workspace *ws = &(*pipe_handle)->workspace;
676 assert(ws != nullptr);
677
678 AccessOrder wait_order = AccessOrder::host();
679 AccessOrder copy_order = AccessOrder::host();
680
681 std::optional<int> dst_dev_id;
682 if (dst_type == GPU) {
683 if (stream != 0 && stream != cudaStreamLegacy && stream != cudaStreamPerThread) {
684 dst_dev_id = dali::DeviceFromStream(stream);
685 }
686 }
687
688 if (ws->OutputIsType<CPUBackend>(output_idx)) {
689 copy_order = dst_type == GPU ? AccessOrder(stream) : AccessOrder::host();
690 auto & src = ws->Output<CPUBackend>(output_idx);
691 CopyToExternal(dsts, dst_mem_kind, dst_dev_id, src, copy_order, use_copy_kernel);
692 if (!host_sync)
693 wait_order = src.order(); // if the copy order is host, then wait will be no-op
694 } else {
695 auto &src = ws->Output<GPUBackend>(output_idx);
696 copy_order = stream;
697 CopyToExternal(dsts, dst_mem_kind, dst_dev_id, src, copy_order, use_copy_kernel);
698 if (!host_sync)
699 wait_order = src.order();
700 }
701 wait_order.wait(copy_order);
702}
703
704
705void daliCopyTensorNTo(daliPipelineHandle_t pipe_handle, void *dst, int output_id,

Callers 1

TYPED_TESTFunction · 0.85

Calls 6

GetMemKindFunction · 0.85
DeviceFromStreamFunction · 0.85
AccessOrderFunction · 0.85
CopyToExternalFunction · 0.85
hostFunction · 0.50
waitMethod · 0.45

Tested by 1

TYPED_TESTFunction · 0.68