interplane.Get Omega
Read in your language

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

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
16use crate::PlatformError;
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
19pub struct DeviceAddress(pub u64);
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub struct BufferLayout {
23 pub size: usize,
24 pub align: usize,
25}
26
27impl BufferLayout {
28 pub const fn new(size: usize, align: usize) -> Self {
29 Self { size, align }
30 }
31}
32
33pub 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)]
44pub struct Fence(pub u64);
45
46pub 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)]
54pub struct BufferRegion {
55 pub address: DeviceAddress,
56 pub offset: usize,
57 pub len: usize,
58}
59
60pub trait MemoryDevice {
61 fn copy(&self, src: BufferRegion, dst: BufferRegion) -> Result<Fence, PlatformError>;
62 fn zero(&self, dst: BufferRegion) -> Result<Fence, PlatformError>;
63}
64
65pub trait ComputeDevice {
66 type Buffer: UnifiedBuffer;
67
68 fn alloc(&self, layout: BufferLayout) -> Result<Self::Buffer, PlatformError>;
69 fn submit(&self, work: ComputeWork<'_>) -> Result<Fence, PlatformError>;
70 fn synchronize(&self, fence: Fence) -> Result<(), PlatformError>;
71}
72
73impl<T: ?Sized + UnifiedBuffer> UnifiedBuffer for alloc::boxed::Box<T> {
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}