Skip to content

Vector types #34

@khyperia

Description

@khyperia

spir-v has vector types that are dramatically useful on e.g. nvidia hardware for optimizing loads/stores. At first, let's just directly expose vector types, instead of trying to do things like auto-vectorization.

  1. Rustc already has the notion of vector types, and we directly translate them to spir-v vector types. We need to investigate under what conditions rustc emits vector types, and if we can re-use the same framework.
    Abi::Vector { ref element, count } => {
    let elem_spirv = trans_scalar(cx, ty, element, None, is_immediate);
    SpirvType::Vector {
    element: elem_spirv,
    count: count as u32,
    }
    .def(cx)
    }
  2. If we cannot re-use the same framework, create an attribute to specify a type is a builtin vector, recognize the attribute in abi.rs (example for storage classes), and emit a vector type. Perhaps do a mix of the two, e.g. if rust supports f32x2 and f32x4, but not f32x3, then we need to define our own f32x3.
  3. Investigate the spec: is emitting a spir-v "OpTypeVector" enough, or are there additional decorations/etc. we need to apply to get it to be a proper "vector type"?
    SpirvType::Vector { element, count } => cx.emit_global().type_vector(element, count),
  4. Implement the above in spirv-std, adding things like swizzling ops and other shenanigans (can come later).

This seems like a good not-quite-first-but-kinda-first task for someone other than me to do. Step 2 is a little involved and will likely need some mentorship - abi.rs is hecking wild - but getting more people who know how abi.rs works would be really really good.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: simdIssues involving Single Instruction Multiple Data instructions.t: designDesign of our rust-gpu language and stdt: good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions