Giter Club home page Giter Club logo

Comments (3)

jafingerhut avatar jafingerhut commented on June 28, 2024 1

@kfcripps This behavior has existed in p4c for quite some time. I will send links to some other p4c issues that I am aware of from years back with some discussion on the topic, but if I am recalling correctly, the reason that p4c internally takes one action and makes multiple copies of it, one for each table it is used within, has its motivation in allowing each of those copies to be optimized independently of each other, based upon the context in which the table invoking it is applied.

Here is the oldest issue I could find with the most discussion on it:

Here are some later issues, where either other people rediscovered this, or a similar thing, or in some case I probably forgot about the old one and filed another. As one of my comments in the first issue linked below says, I would love it if we could get all the stakeholders involved into a discussion with the goal of coming up with an answer to this.

There is also a PR that started with one potential change, and I believe the discussion on it led to a proposal for a different approach, one which would be a small p4c change, but I haven't thought about the details in a while to have a good evaluation of either of those proposed changes at this moment:

from p4c.

kfcripps avatar kfcripps commented on June 28, 2024

Similarly, the following P4 program:

header h_t {
    bit<8> f;
}

control C() {
    action bar() {
    }

    table t {
        actions = { bar; }
        default_action = bar;
    }

    table t2 {
        actions = { bar; }
        default_action = bar;
    }

    apply {
        t.apply();
        t2.apply();
    }
}

control proto();
package top(proto p);

top(C()) main;

gets transformed into:

header h_t {
    bit<8> f;
}

control C() {
    @name("C.bar") action bar() {
    }
    @name("C.bar") action bar_1() {
    }
    @name("C.t") table t_0 {
        actions = {
            bar();
        }
        default_action = bar();
    }
    @name("C.t2") table t2_0 {
        actions = {
            bar_1();
        }
        default_action = bar_1();
    }
    apply {
        t_0.apply();
        t2_0.apply();
    }
}

control proto();
package top(proto p);
top(C()) main;

so we end up with two actions defined in the same scope that have the same local name (C.bar). Is this a bug per the spec?

from p4c.

kfcripps avatar kfcripps commented on June 28, 2024

@jphurl @oleg-ran-amd @rsmith-pensando

from p4c.

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.