Code Monkey home page Code Monkey logo

Comments (5)

jeffsetter avatar jeffsetter commented on August 17, 2024

One solution is to make both have the same number of iterations.

Another solution is to connect a valid signal to the ren of the other producer.

from halide-to-hardware.

dillonhuff avatar dillonhuff commented on August 17, 2024

@jeffsetter maybe I'm misunderstanding, but isn't it the responsibility of the user to insert delays (using the fifo_depth scheduling directive) that synchronize the arrival times of data from different producers?

Is there a specific app where I could see an example of this problem?

from halide-to-hardware.

jeffsetter avatar jeffsetter commented on August 17, 2024

That is the case when linebuffers are used (which inherently must have some delay due to internal registers). My assumption for ROM is that there is zero delay. In fact, this is not correct, it takes a cycle, and so the thinking is the mapper will synchronize the arrival times with the actual timing.

from halide-to-hardware.

dillonhuff avatar dillonhuff commented on August 17, 2024

I think I understand. In the new CoreIR code generator I have added delay balancing for kernels with different latencies (for example because one uses a ROM and the other is all combinational logic).

Here is a test case for such a situation:

void different_latency_kernels_test() {
ImageParam input(type_of<uint8_t>(), 2);
ImageParam output(type_of<uint8_t>(), 2);
Var x("x"), y("y");
Var xi, yi, xo, yo;
Func lut("lut");
Func translated("kernel");
Func brightened("brightened");
Func diff("diff");
Func hw_input("hw_input");
Func hw_output("hw_output");
hw_input(x, y) = cast<uint8_t>(input(x, y));
lut(x) = cast<uint8_t>(Expr(x));
translated(x, y) = lut(hw_input(x, y));
brightened(x, y) = hw_input(x, y) + 10;
diff(x, y) = brightened(x, y) - translated(x, y);
hw_output(x, y) = diff(x, y);
int outTileSize = 5;
Halide::Buffer<uint8_t> inputBuf(outTileSize, outTileSize);
Halide::Runtime::Buffer<uint8_t> hwInputBuf(inputBuf.width(), inputBuf.height(), 1);
indexTestPatternRandom(inputBuf, hwInputBuf);
Halide::Runtime::Buffer<uint8_t> outputBuf(outTileSize, outTileSize);
auto cpuOutput = realizeCPU(hw_output, input, inputBuf, outputBuf);
printBuffer(cpuOutput, cout);
hw_output.compute_root();
hw_input.compute_root();
hw_output.tile(x, y, xo, yo, xi, yi, outTileSize, outTileSize)
.reorder(xi, yi, xo, yo);
lut.compute_at(hw_output, xo).unroll(x);
translated.linebuffer();
brightened.linebuffer();
diff.linebuffer();
hw_input.stream_to_accelerator();
hw_output.hw_accelerate(xi, xo);
hw_output.print_loop_nest();
auto context = hwContext();
vector<Argument> args{input};
auto m = buildModule(context, "hw_different_latencies", args, "different_latencies", hw_output);
string accelName = getInputAlias("accel_interface_info.json");
runHWKernel(accelName, m, hwInputBuf, outputBuf);
compare_buffers(outputBuf, cpuOutput);
PRINT_PASSED("Different latency kernels");
}

Is this the kind of thing you are talking about or am I misunderstanding the problem?

from halide-to-hardware.

jeffsetter avatar jeffsetter commented on August 17, 2024

This is actually dynamic instead of just static latency between producers. For example, a producer might treat the edges differently from the other.

from halide-to-hardware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.