1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
use super::{
CudaEvent, InteropError, InteropErrorKind, PreparedTableExport, Runtime, Table, TableView,
import_table_from_prepared_export, map_cudf_error, prepare_host_table_export_from_view,
prepare_table_export_from_view, prepare_table_export_from_view_with_readiness, prepared_device_event_readiness,
table_export::{prepare_into_owned_table_root, prepare_into_owned_table_root_with_readiness},
};
impl TableView<'_> {
/// Project this low-level borrowed table view into the shared RAPIDS
/// prepared device export profile.
///
/// The returned export is producer-rooted. Consumers activate read access
/// later via [`PreparedTableExport::try_activate_read_lease`].
///
/// The export describes `self`'s device buffers without taking ownership, so
/// it cannot outlive that borrow. Returns an [`InteropError`] when a column's
/// layout falls outside the prepared device profile, its buffers are not on a
/// CUDA device, or the execution binding or producer readiness of `self`'s
/// runtime domain is unavailable.
pub fn try_prepare_device_table_export(&self) -> Result<PreparedTableExport<'_>, InteropError> {
prepare_table_export_from_view(
self,
self.execution_domain(),
None,
"interop::TableView::try_prepare_device_table_export",
)
}
/// Project this low-level borrowed table view into the shared RAPIDS
/// prepared host export profile.
///
/// This materializes each supported top-level column to owned host-visible
/// bytes and therefore is not zero-copy.
///
/// The `'static` export owns retained host copies and does not borrow `self`.
/// Returns an [`InteropError`] when a column's type or layout is not
/// supported by host export or its data cannot be copied to host memory.
pub fn try_prepare_host_table_export(&self) -> Result<PreparedTableExport<'static>, InteropError> {
prepare_host_table_export_from_view(self, None, "interop::TableView::try_prepare_host_table_export")
}
/// Project this low-level borrowed table view into the shared RAPIDS
/// prepared device export profile with producer event-ordered readiness.
///
/// This still returns a producer-rooted export; the supplied event only
/// refines the read-start fact carried by the export's shared readiness
/// contract.
pub fn try_prepare_device_table_export_with_event<'a>(
&'a self,
event: &'a CudaEvent,
) -> Result<PreparedTableExport<'a>, InteropError> {
let operation = "interop::TableView::try_prepare_device_table_export_with_event";
let (default_device, readiness) = prepared_device_event_readiness(operation, self.execution_domain(), event)?;
prepare_table_export_from_view_with_readiness(self, None, operation, default_device, readiness)
}
}
impl Table {
/// Deep-copy a shared prepared export root into an owned
/// `cudf` table inside the provided explicit runtime.
///
/// Prepared device exports activate on the destination runtime's CUDA
/// stream and perform same-device device-to-device copies for the current
/// prepared-device layout set. Prepared host exports activate
/// synchronously by return and upload their host-visible bytes into new
/// device ownership inside the destination runtime. Both paths
/// synchronize completion before returning. The producer's liveness can
/// end once the call returns.
pub fn try_import_from_prepared_table_export_into_runtime(
export: &PreparedTableExport<'_>,
runtime: &Runtime,
) -> Result<Self, InteropError> {
import_table_from_prepared_export(
export,
runtime,
"interop::Table::try_import_from_prepared_table_export_into_runtime",
)
}
/// Project this owned low-level table into the shared RAPIDS prepared
/// device export profile.
///
/// The returned export is producer-rooted. Consumers activate read access
/// later via [`PreparedTableExport::try_activate_read_lease`].
///
/// The export describes `self`'s device buffers without taking ownership, so
/// it cannot outlive that borrow. Returns an [`InteropError`] when a column's
/// layout falls outside the prepared device profile, its buffers are not on a
/// CUDA device, or the execution binding or producer readiness of `self`'s
/// runtime domain is unavailable.
pub fn try_prepare_device_table_export(&self) -> Result<PreparedTableExport<'_>, InteropError> {
let operation = "interop::Table::try_prepare_device_table_export";
let view = self.view().map_err(|error| map_cudf_error(InteropErrorKind::InvalidView, operation, error))?;
prepare_table_export_from_view(&view, self.execution_domain(), None, operation)
}
/// Move this owned low-level table into a producer-rooted shared prepared
/// device export.
///
/// This consuming variant upgrades the table itself into the prepared
/// export root. The returned export retains producer ownership. Callers
/// that need a non-owning projection use
/// [`Table::try_prepare_device_table_export`].
pub fn try_into_prepared_device_table_export(self) -> Result<PreparedTableExport<'static>, InteropError> {
prepare_into_owned_table_root(self, None, "interop::Table::try_into_prepared_device_table_export")
}
/// Project this owned low-level table into the shared RAPIDS prepared host
/// export profile.
///
/// This materializes each supported top-level column to owned host-visible
/// bytes and therefore is not zero-copy.
///
/// The `'static` export owns retained host copies and does not borrow `self`.
/// Returns an [`InteropError`] when a column's type or layout is not
/// supported by host export or its data cannot be copied to host memory.
pub fn try_prepare_host_table_export(&self) -> Result<PreparedTableExport<'static>, InteropError> {
let operation = "interop::Table::try_prepare_host_table_export";
let view = self.view().map_err(|error| map_cudf_error(InteropErrorKind::InvalidView, operation, error))?;
prepare_host_table_export_from_view(&view, None, operation)
}
/// Project this owned low-level table into the shared RAPIDS prepared
/// device export profile with producer event-ordered readiness.
pub fn try_prepare_device_table_export_with_event<'a>(
&'a self,
event: &'a CudaEvent,
) -> Result<PreparedTableExport<'a>, InteropError> {
let operation = "interop::Table::try_prepare_device_table_export_with_event";
let view = self.view().map_err(|error| map_cudf_error(InteropErrorKind::InvalidView, operation, error))?;
let (default_device, readiness) = prepared_device_event_readiness(operation, self.execution_domain(), event)?;
prepare_table_export_from_view_with_readiness(&view, None, operation, default_device, readiness)
}
/// Move this owned low-level table into a producer-rooted shared prepared
/// device export with explicit event-ordered readiness.
pub fn try_into_prepared_device_table_export_with_event(
self,
event: &CudaEvent,
) -> Result<PreparedTableExport<'static>, InteropError> {
let operation = "interop::Table::try_into_prepared_device_table_export_with_event";
let readiness = prepared_device_event_readiness(operation, self.execution_domain(), event)?.1;
prepare_into_owned_table_root_with_readiness(self, None, operation, readiness, Some(event.clone()))
}
}