Skip to content

Ramp of lanes <= 1 exception when cross-compile Halide for RISC-V #7070

@dkurt

Description

@dkurt

Tried tutorial https://halide-lang.org/tutorials/tutorial_lesson_11_cross_compilation.html on x86 host machine (Ubuntu 20.04) but for RISC-V target architecture. Unfortunately, there is an exception from IR.cpp. The exception appears only when .vectorize(x, 16) is applied, so problem is somewhere in RISC-V Vectorization support.

Internal Error at /home/dkurt/Halide/src/IR.cpp:272 triggered by user code at : Condition failed: lanes > 1: Ramp of lanes <= 1

Everything is OK locally for x86 target.

Code:

#include "Halide.h"

using namespace Halide;

int main(int argc, char** argv) {
    Func brighter;
    Var x, y;

    Param<uint8_t> offset;
    ImageParam input(type_of<uint8_t>(), 2);
    std::vector<Argument> args(2);
    args[0] = input;
    args[1] = offset;

    brighter(x, y) = input(x, y) + offset;

    brighter.bound(x, 0, 64).bound(y, 0, 64);

    brighter.vectorize(x, 16).parallel(y);

    Target target;
    target.os = Target::Linux;
    target.arch = Target::RISCV;
    target.bits = 64;

    std::vector<Target::Feature> features;
    features.push_back(Target::RVV);
    target.set_features(features);

    try {
        brighter.compile_to_static_library("compiled", args, "brighter", target);
    } catch(Halide::InternalError& ex) {
        std::cout << ex.what() << std::endl;
    }
}

Stacktrace:

__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50      ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007ffff14d1859 in __GI_abort () at abort.c:79
#2  0x00007ffff175a911 in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff176638c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#4  0x00007ffff17663f7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff176637f in std::rethrow_exception(std::__exception_ptr::exception_ptr) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6  0x00007ffff2f00062 in Halide::Internal::run_with_large_stack(std::function<void ()> const&) (action=...) at /home/dkurt/Halide/src/Util.cpp:793
#7  0x00007ffff20a2b31 in Halide::Internal::CodeGen_LLVM::compile (this=0x5555556acaf0, input=...) at /home/dkurt/Halide/src/CodeGen_LLVM.cpp:566
#8  0x00007ffff209dc94 in Halide::codegen_llvm (module=..., context=...) at /home/dkurt/Halide/src/CodeGen_LLVM.cpp:41
#9  0x00007ffff24c4cd3 in Halide::compile_module_to_llvm_module (module=..., context=...) at /home/dkurt/Halide/src/LLVM_Output.cpp:410
#10 0x00007ffff252a2cb in Halide::Module::compile (this=0x7fffffffdca8, Python Exception <class 'AttributeError'> 'NoneType' object has no attribute 'pointer': 
output_files=std::map with 2 elements) at /home/dkurt/Halide/src/Module.cpp:597
#11 0x00007ffff257049f in Halide::Pipeline::compile_to_static_library (this=0x7fffffffdd40, filename_prefix="compiled", args=std::vector of length 2, capacity 2 = {...}, 
    fn_name="brighter", target=...) at /home/dkurt/Halide/src/Pipeline.cpp:390
#12 0x00007ffff22ba02e in Halide::Func::compile_to_static_library (this=0x7fffffffddd0, filename_prefix="compiled", args=std::vector of length 2, capacity 2 = {...}, 
    fn_name="brighter", target=...) at /home/dkurt/Halide/src/Func.cpp:3325
#13 0x000055555555ab6b in main (argc=1, argv=0x7fffffffe0c8) at /home/dkurt/halide_demo/main.cpp:40

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