Skip to content

Host-side prefetch fails to compile for targets with the hvx feature #9496

Open

Description

@abadams

Generated with GitHub Copilot CLI

Prefetches in host code fail to compile when the target has the hvx feature (e.g. host-hvx), even if nothing is offloaded with .hexagon().

Reproducer:

#include "Halide.h"
using namespace Halide;
int main() {
    Var x, y;
    ImageParam input(Int(32), 2, "input");
    Func f("f");
    f(x, y) = input(x, y) * 2;
    f.prefetch(input, y, y, 2);
    Buffer<int> in(4, 4);
    in.fill(3);
    input.set(in);
    Buffer<int> r = f.realize({4, 4});
    printf("ok %d\n", r(0, 0));
}

With HL_JIT_TARGET=host this prints ok 6. With HL_JIT_TARGET=host-hvx it fails with:

Error: Only prefetch of 1 cache line is supported.

reduce_prefetch_dimension (Prefetch.cpp) chooses Hexagon's 2D prefetch form whenever t.has_feature(Target::HVX). It runs in lower() before inject_hexagon_rpc splits off the .hexagon() loops, so prefetches that stay in host code also get the 2D form, which CodeGen_LLVM rejects. It should probably only use the 2D form when t.arch == Target::Hexagon or the prefetch is inside a DeviceAPI::Hexagon loop.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions