[ Web Proxy ]
URL:
Viewing: https://raw.githubusercontent.com/AnswerDotAI/gpu.cpp/main/tests/gpu_test.cpp [Back]  [Original]

#include "gpu.hpp"
#include "numeric_types/half.hpp"

#include 
#include 
#include 
#include 

using namespace gpu;

static constexpr auto twicePlusOne = R"(
@group(0) @binding(0) var input: array;
@group(0) @binding(1) var output: array;

@compute @workgroup_size({{workgroupSize}})
fn main(@builtin(global_invocation_id) id: vec3) {
  if (id.x < arrayLength(&input)) {
    output[id.x] = input[id.x] * 2 + 1;
  }
}
)";

static constexpr auto doubleF16 = R"(
@group(0) @binding(0) var input: array;
@group(0) @binding(1) var output: array;

@compute @workgroup_size({{workgroupSize}})
fn main(@builtin(global_invocation_id) id: vec3) {
  if (id.x < arrayLength(&input)) {
    output[id.x] = input[id.x] * 2.0;
  }
}
)";

static std::vector readSPIRV(const char *path) {
  std::ifstream file(path, std::ios::binary | std::ios::ate);
  if (!file) throw std::runtime_error("could not open assembled SPIR-V test");
  const auto bytes = file.tellg();
  if (bytes 

Web Proxy Viewer  |  New URL  |  Original Page