Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault in Adams2019 #8348

Open
jxl1080 opened this issue Jul 22, 2024 · 0 comments
Open

Segmentation fault in Adams2019 #8348

jxl1080 opened this issue Jul 22, 2024 · 0 comments

Comments

@jxl1080
Copy link

jxl1080 commented Jul 22, 2024

Adams2019 issues segmentation fault with Halide generator class below:

#include "Halide.h"
#include <stdio.h>
using namespace Halide;
class mMatmul_matmul_out1_fcn_halide_generator : public Halide::Generator <mMatmul_matmul_out1_fcn_halide_generator> {

public:
    Input<Buffer<uint8_t>> A1_in{"A1_in", 2};
    Input<Buffer<uint8_t>> B1_in{"B1_in", 2};
    Output<Buffer<uint16_t>> matmul_out1_fcn{"matmul_out1_fcn", 2};

    void generate() {
        RDom r(0, 81);
        matmul_out1_func(d1, d2) = sum(cast<uint16_t>(A1_in(d1, r))*cast<uint16_t>(B1_in(r, d2)));
        matmul_out1_fcn(d1, d2) = matmul_out1_func(d1, d2);
    }

    void schedule() {
    // Schedule is determined by autoscheduler. Need to set estimate on buffer
        if(using_autoscheduler()) {
            A1_in.dim(1).set_estimate(0, 81);
            A1_in.dim(0).set_estimate(0, 81);
            B1_in.dim(1).set_estimate(0, 81);
            B1_in.dim(0).set_estimate(0, 81);
            matmul_out1_fcn.set_estimate(d1, 0, 81).set_estimate(d2, 0, 81);
        }  else {
            // Default schedule
        }
    }

private:
    Var d1{"d1"};
    Var d2{"d2"};
    Func matmul_out1_func{"matmul_out1_func"};

};
HALIDE_REGISTER_GENERATOR(mMatmul_matmul_out1_fcn_halide_generator, mMatmul_matmul_out1_fcn_halide_gen)

I used binary 'Halide-18.0.0-x86-64-linux-b741d9c5b2705c45fd7c8462eb0b4bfa35a3e6d8.tar.gz' downloaded from: https://buildbot.halide-lang.org/

My command for compiling the Halide Genertor Class is:
$ g++ mMatmul_matmul_out1_fcn_halide.cpp -std=c++17 ....../Halide-18.0.0-x86-64-linux/share/Halide/tools/GenGen.cpp -L ....../Halide-18.0.0-x86-64-linux/lib -lHalide -I ....../Halide-18.0.0-x86-64-linux/include -o mMatmul_matmul_out1_fcn_halide

My command for running generator with Adams2019 is:
$ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:....../Halide-18.0.0-x86-64-linux/lib
$ ./mMatmul_matmul_out1_fcn_halide -f myPipeline -g mMatmul_matmul_out1_fcn_halide_gen -e h,o target=hexagon-32-noos-hvx-no_runtime autoscheduler.parallelism=2 autoscheduler=Adams2019 -p ....../Halide-18.0.0-x86-64-linux/lib/libautoschedule_adams2019.so -o ./

I have the following observations:

  1. If I make the RDom length and the length used in set_estimate less than or equal to 80, the segmentation fault will disappear.
  2. If I change the output buffer type from uint16_t to uint8_t and remove the two 'cast' in generate function, the segmentation fault will disappear.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant