pub struct UnifiedAllocator<'stream> It is the C library's sz_allocator_init_unified_best behind the standard
Allocator, so Vec::new_in, a Strings and every other
allocator-aware collection places its contents there. Every block lands on the device of the
stream it borrows, the host heap for a CPU stream, and a block aligned less strictly than its
layout asks is refused.
Examples
use stringzilla::{Capabilities, LevenshteinEngine, LevenshteinSymbol, Stream, Strings, StringsView, UnifiedAllocator};
let cpu = Stream::default(Capabilities::cpu_enabled());
let stream = Stream::new(Capabilities::cuda_enabled(0)?, 0)?;
let unified = UnifiedAllocator::new(&stream);
// The host gathers the slices, which a GPU cannot read, into memory the GPU reaches.
let candidates = Strings::copy_in(StringsView::from_slices(&["sitting", "kitten"]), unified, &cpu)?;
let mut distances = Vec::new_in(unified);
distances.resize(2, 0usize);
let mut engine = LevenshteinEngine::new(&["kitten"], LevenshteinSymbol::Bytes, &stream)?;
stream.scope(|scope| engine.distances(scope, candidates.view(), None, &mut distances, 2))?;
assert_eq!(distances[..], [3, 0]);
Implements
Clone, Copy, Debug, Allocator