E6030
E6030 — Aspawnregion on a device hands out a tensor it makes, which the host could not free. The compiler makes such a tensor before the region instead, in the device's memory, when the region hands it out as a variable created withTensor<..>(..),::new()or::uninit(), with no type annotation, a size that uses nothing the region computes, and a name nothing outside the region already uses.
What the compiler reports
Error[E6030] at 29:5:
Error[E6030] at 39:5:
Error[E6030] at 48:5:
Error[E6030] at 56:5:
The fragments the test suite holds the compiler to. An ellipsis marks text the test does not constrain; the emitted message also carries a source location.
A program that triggers it
//
// Part of the Vx Project, under the Apache License v2.0 with LLVM Exceptions.
// See LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// A `spawn` region on the GPU that hands out a tensor it creates normally has that tensor
// created before the region, in GPU memory, so the function can free it. Each region below
// stops that, and gets E6030:
//
// - `annotated`: the tensor has a type annotation;
// - `sized_inside`: its size is computed inside the region;
// - `name_in_use`: a variable named `x` already exists outside the region;
// - `computed`: the region hands out a tensor that is not in a variable.
// COUNT-COUNT-4: Error[E6030]
// COUNT-NOT: Error[
fn annotated() -> i32 {
let t = spawn on(Topology::GPU) {
let x : Tensor<f32, [4]> = Tensor<f32, [4]>::new();
x
};
let h = transfer(t, Memory::CPU_DRAM);
return h[0] as i32;
}
fn sized_inside(n : i32) -> i32 {
let t = spawn on(Topology::GPU) {
let m = n * 2;
let x = Tensor<f32>([m]);
x
};
let h = transfer(t, Memory::CPU_DRAM);
return h[0] as i32;
}
fn name_in_use(x : i32) -> i32 {
let t = spawn on(Topology::GPU) {
let x = Tensor<f32, [4]>::new();
x
};
let h = transfer(t, Memory::CPU_DRAM);
return h[0] as i32;
}
fn computed() -> i32 {
let t = spawn on(Topology::GPU) {
Tensor<f32, [4]>::new()
};
let h = transfer(t, Memory::CPU_DRAM);
return h[0] as i32;
}
fn main() -> i32 {
return annotated() + sized_inside(2) + name_in_use(1) + computed();
}
From tests/frontend/fail/device_region_hands_out_a_tensor_it_computes.vx, which asserts this diagnostic on every commit.
Related
Topologies and memoryThe chapter covering the rule this code enforces.
All diagnosticsEvery code the compiler can emit, grouped by stage.
E6029A pointer argument into one memory passed to a parameter that wants a pointer into another: a host
*mut f32 where *mut f32 in Memory::GPU_HBM is declared, or the reverse. The two are different types, and the C library or kernel behind the parameter reads the memory the declaration names, so the spaces must match exactly.