mumu-gpu 0.1.0

GPU/Vulkan matrix and tensor operations for the mumu/lava language
Documentation
#[cfg(debug_assertions)]
use lazy_static::lazy_static;
#[cfg(debug_assertions)]
use std::sync::Mutex;
#[cfg(debug_assertions)]
use mumu::parser::interpreter::Interpreter;
#[cfg(debug_assertions)]
use mumu::parser::types::{Value};
#[cfg(debug_assertions)]
use indexmap::IndexMap;

#[cfg(debug_assertions)]
#[derive(Clone)]
pub struct GpuCallInfo {
    pub op: String,
    pub used_gpu: bool,
}

#[cfg(debug_assertions)]
lazy_static! {
    pub static ref LAST_CALL: Mutex<GpuCallInfo> = Mutex::new(GpuCallInfo {
        op: "none".to_string(),
        used_gpu: false,
    });
}

#[cfg(debug_assertions)]
pub fn set_last_call_info(op: &str, used_gpu: bool) {
    let mut lock = LAST_CALL.lock().unwrap();
    lock.op = op.to_string();
    lock.used_gpu = used_gpu;
}

#[cfg(debug_assertions)]
pub fn gpu_last_call_bridge(
    _interp: &mut Interpreter,
    _args: Vec<Value>
) -> Result<Value, String> {
    let info = LAST_CALL.lock().unwrap().clone();
    let mut map = IndexMap::new();
    map.insert("op".to_string(), Value::SingleString(info.op));
    map.insert("used_gpu".to_string(), Value::Bool(info.used_gpu));
    Ok(Value::KeyedArray(map))
}