Git Product home page Git Product logo

Comments (4)

mppf avatar mppf commented on June 12, 2024 1

In terms of what ought to happen, IMO the original case should not get the extra copy:

proc ArrayWrapper.init(in a: [?d] ?t) {
    this.etype = t;
    this.rank = d.rank;
    this.shape = d.shape;
    this.a = a;

    writeln(d); // it's not referring to 'a' so 'a' should be copy elided
}

In contrast, this pattern should disable copy elision:

proc ArrayWrapper.init(in a: [?d] ?t) {
    this.etype = t;
    this.rank = d.rank;
    this.shape = d.shape;
    this.a = a;

    writeln(a.domain); // it's mentioning 'a' so should disable copy elision for 'a'
}

I suspect that the current situation here is largely due to how the production compiler represents d in this function.

from chapel.

mppf avatar mppf commented on June 12, 2024 1

@benharsh - one way would be for the normalization to introduce const ref tmp = a._dom near the beginning of the function, since it's using it to replace something from a formal. (And then use that instead of d).

Another strategy would be to wait for the dyno implementation of split init / copy elision, which will happen pre-normalization.

from chapel.

benharsh avatar benharsh commented on June 12, 2024

This appears to be related to an intersection between the "normalization" of d and our split-init implementation.

The writeln(d) call is transformed during normalization into a call to a._dom, which from the compiler's perspective is indistinguishable from a user-specified reference to a.

The elideCopies mini-pass in splitInit.cpp is the part that's actually responsible for getting rid of the extra init-copy for the array a. When it sees the reference to a after the init-copy, it gives up and decides not to remove the copy. For some more context, the line for this.a = a looks more like:

var a_temp = formal_a;
move(a, a_temp);

@mppf , do you have any insight as to how we might make this work within the rules of split init?

from chapel.

benharsh avatar benharsh commented on June 12, 2024

I believe I have a solution here: #24416

from chapel.

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.