pub(crate) mod capabilities;
pub(crate) mod checksum;
pub mod context;
pub(crate) mod executor;
pub(crate) mod fill;
pub(crate) mod notifications;
pub(crate) mod options;
pub(crate) mod preferences;
pub(crate) mod strategy;
pub(crate) mod validation;
#[cfg(all(test, feature = "testing-kvbm"))]
mod tests;
pub use dynamo_memory::StorageKind;
pub use capabilities::TransferCapabilities;
pub use checksum::{BlockChecksum, compute_block_checksums, compute_layer_checksums};
pub use context::{TransferCompleteNotification, TransferConfig};
pub use dynamo_memory::nixl::NixlAgent;
pub use fill::{FillPattern, fill_blocks, fill_layers};
pub use options::{TransferOptions, TransferOptionsBuilder};
#[doc(hidden)]
pub use context::TransferContext;
use crate::BlockId;
pub use crate::layout::PhysicalLayout;
pub use crate::manager::{LayoutHandle, SerializedLayout, TransferManager, WorkerAddress};
#[derive(Clone)]
pub struct BounceBuffer {
layout: LayoutHandle,
block_ids: Vec<BlockId>,
}
#[derive(Clone)]
pub struct BounceBufferInternal {
layout: PhysicalLayout,
block_ids: Vec<BlockId>,
}
impl BounceBuffer {
pub fn from_handle(layout: LayoutHandle, block_ids: Vec<BlockId>) -> Self {
Self { layout, block_ids }
}
#[doc(hidden)]
pub fn into_parts(self) -> (LayoutHandle, Vec<BlockId>) {
(self.layout, self.block_ids)
}
}
impl BounceBufferInternal {
pub fn from_layout(layout: PhysicalLayout, block_ids: Vec<BlockId>) -> Self {
Self { layout, block_ids }
}
}
use anyhow::anyhow;
use std::ops::Range;
pub(crate) fn validate_layout_compatibility(
src: &PhysicalLayout,
dst: &PhysicalLayout,
) -> anyhow::Result<()> {
let src_layout = src.layout();
let dst_layout = dst.layout();
if src_layout
.block_layout()
.requires_transform(&dst_layout.block_layout())
{
return Err(anyhow!(
"Layout transformation not supported: src={:?}, dst={:?}",
src_layout.block_layout(),
dst_layout.block_layout()
));
}
Ok(())
}
pub(crate) fn can_use_whole_block_transfer(
src: &PhysicalLayout,
dst: &PhysicalLayout,
layer_range: Option<&Range<usize>>,
) -> bool {
let is_full_block = match layer_range {
None => true,
Some(range) => range.start == 0 && range.end == src.layout().num_layers(),
};
if !is_full_block {
return false;
}
src.layout().is_fully_contiguous() && dst.layout().is_fully_contiguous()
}