//! Shared MSL kernel sources for benchmarks
#![allow(dead_code)]

pub const SAXPY: &str = r#"
    #include <metal_stdlib>
    using namespace metal;
    kernel void saxpy(device const float *x buffer(0),
                      device float *y       buffer(1),
                      constant float &a     buffer(2),
                      uint id thread_position_in_grid) {
        y[id] = a * x[id] + y[id];
    }
"#;

pub const NOOP: &str = r#"
    #include <metal_stdlib>
    using namespace metal;
    kernel void noop(device float *a buffer(0),
                     uint id thread_position_in_grid) {
        a[id] = a[id] + 1.0;
    }
"#;

pub const TRIANGLE: &str = r#"
    #include <metal_stdlib>
    using namespace metal;
    vertex float4 vmain(uint vid vertex_id) {
        float2 v[3] = { float2(-1,-1), float2(1,-1), float2(0,1) };
        return float4(v[vid], 0.0, 1.0);
    }
    fragment float4 fmain() { return float4(1.0); }
"#;

Homonyms

trident/src/gpu/shaders.rs

Graph