Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aien-sovereign-core-mv/blob/main/crates/aien-platform/src/compute.rs # aien-sovereign-core-mv AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aien-sovereign-core-mv / crates / aien-platform / src / compute.rs` 89 lines ยท 2527 bytes Raw Blame History 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2026 Drake Stapleton (AIEN / aien-dev) 3 // 4 // Licensed under the Apache License, Version 2.0 (the "License"); 5 // you may not use this file except in compliance with the License. 6 // You may obtain a copy of the License at 7 // 8 // http://www.apache.org/licenses/LICENSE-2.0 9 // 10 // Unless required by applicable law or agreed to in writing, software 11 // distributed under the License is distributed on an "AS IS" BASIS, 12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 // See the License for the specific language governing permissions and 14 // limitations under the License. 15 16 use crate::PlatformError; 17 18 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 19 pub struct DeviceAddress(pub u64); 20 21 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 22 pub struct BufferLayout { 23 pub size: usize, 24 pub align: usize, 25 } 26 27 impl BufferLayout { 28 pub const fn new(size: usize, align: usize) -> Self { 29 Self { size, align } 30 } 31 } 32 33 pub trait UnifiedBuffer { 34 fn len(&self) -> usize; 35 fn is_empty(&self) -> bool { 36 self.len() == 0 37 } 38 fn device_address(&self) -> DeviceAddress; 39 fn as_ptr(&self) -> *const u8; 40 fn as_mut_ptr(&mut self) -> *mut u8; 41 } 42 43 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 44 pub struct Fence(pub u64); 45 46 pub struct ComputeWork<'a> { 47 pub kernel_id: u32, 48 pub input_buffer: DeviceAddress, 49 pub output_buffer: DeviceAddress, 50 pub params: &'a [u8], 51 } 52 53 #[derive(Debug, Clone, Copy, PartialEq, Eq)] 54 pub struct BufferRegion { 55 pub address: DeviceAddress, 56 pub offset: usize, 57 pub len: usize, 58 } 59 60 pub trait MemoryDevice { 61 fn copy(&self, src: BufferRegion, dst: BufferRegion) -> Result; 62 fn zero(&self, dst: BufferRegion) -> Result; 63 } 64 65 pub trait ComputeDevice { 66 type Buffer: UnifiedBuffer; 67 68 fn alloc(&self, layout: BufferLayout) -> Result; 69 fn submit(&self, work: ComputeWork<'_>) -> Result; 70 fn synchronize(&self, fence: Fence) -> Result<(), PlatformError>; 71 } 72 73 impl UnifiedBuffer for alloc::boxed::Box { 74 fn len(&self) -> usize { 75 (**self).len() 76 } 77 fn is_empty(&self) -> bool { 78 (**self).is_empty() 79 } 80 fn device_address(&self) -> DeviceAddress { 81 (**self).device_address() 82 } 83 fn as_ptr(&self) -> *const u8 { 84 (**self).as_ptr() 85 } 86 fn as_mut_ptr(&mut self) -> *mut u8 { 87 (**self).as_mut_ptr() 88 } 89 }