E6033
E6033 — An index into a tensor in ascope: threadspace that is not known when compiling. Such a tensor stays in registers, and a register has no address. So each index must be a constant, or made of constants and the variables offorloops with constant bounds, at most 1024 passes each. The code generator unrolls those loops.
What the compiler reports
Error[E6033] at 22:6: the register tensor 'acc' needs an index that is known when compiling: 'n' is not a constant or the variable of a `for` loop. A tensor in a `scope: thread` space stays in registers, which have no address
Error[E6033] at 28:8: the register tensor 'acc' needs an index that is known when compiling: the bounds of the loop of 'i' are not constants, so the compiler cannot unroll it
Error[E6033] at 35:8: the register tensor 'acc' needs an index that is known when compiling: the loop of 'i' has 2000 passes, and the compiler unrolls at most 1024
Error[E6033] at 41:6: the register tensor 'acc' needs an index that is known when compiling: the index uses a value that is not a constant or a loop variable
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 tensor in `Memory::REG` (`scope: thread`) stays in registers, so each index must be known
// when compiling. Each function below indexes one with something else.
//
fn three() on Topology::Device -> i32 {
return 3;
}
fn with_a_parameter(acc : &mut Tensor<f32, [32], Memory::REG>, n : i32) on Topology::Device -> void {
acc[n] = 1.0;
return;
}
fn with_loop_bounds_not_known(acc : &mut Tensor<f32, [32], Memory::REG>, n : i32) on Topology::Device -> void {
for i in 0..n {
acc[i] = 1.0;
}
return;
}
fn with_a_long_loop(acc : &mut Tensor<f32, [32], Memory::REG>) on Topology::Device -> void {
for i in 0..2000 {
acc[i % 32] = 1.0;
}
return;
}
fn with_a_call(acc : &mut Tensor<f32, [32], Memory::REG>) on Topology::Device -> void {
acc[three()] = 1.0;
return;
}
fn main() -> i32 {
return 0;
}
From tests/frontend/fail/register_tensor_indexes_not_known_when_compiling.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.
E6031A tensor shape that folds to a negative extent, or whose size is more than 2^63 - 1 bytes, the most an allocation can ask for. The size is known, and it is not one the generated code can allocate: it would wrap.
E6034An
aligned(N) in a tensor type that the compiler cannot give: the space is not one whose storage the compiler lays out (scope: sm, cta or thread), or N is less than the alignment: of the space, which every tensor there has.