ObitCC
  • Obit: Community Cloud
  • For Research
    • Creating your first Workload
    • Workload Types
      • WebLLM
      • WGSL
      • Transformers
      • ONNX Training
      • More ONNX Workloads
    • Entitlements
  • For server owners
    • Setting Up
    • Creating a Shop
    • Profit Sharing
    • FAQ
Powered by GitBook
On this page
  • Feature support
  • Example
  1. For Research
  2. Workload Types

WGSL

PreviousWebLLMNextTransformers

Last updated 9 months ago

This workload does not support batching

Some people may find it advantageous to use raw WGSL code in their project. We support these projects, but recommend for ease of use that you use a different workload type if you are running a common workload.

Feature support

All language features are supported. There are some limitations on the way you can use a user's device:

  • All code must be thoroughly tested for GPU crashes (you can use your own computer, and we also have containers we can provide for testing)

  • You may need depending on how you use the user's computer

Example

A basic function to take the exponent of a base and a number repeatedly. BUFFER_SIZE is typically set to the maximum of 134217728 bytes, or 128MB to prevent crashes. It is replaced at runtime.

@group(0) @binding(0)
var<storage, read_write> output: array<f32>;

@compute @workgroup_size(64)
fn main(
  @builtin(global_invocation_id)
  global_id : vec3u,

  @builtin(local_invocation_id)
  local_id : vec3u,
) {
  // Avoid accessing the buffer out of bounds
  if (global_id.x >= ${BUFFER_SIZE}) {
    return;
  }

  output[global_id.x] =
    ldexp(f32(global_id.x), i32(local_id.x));
}

Entitlements