Comments (4)
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.
@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.
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.
I believe I have a solution here: #24416
from chapel.
Related Issues (20)
- [Bug]: Rexported symbols like `sqrt` cause issues when imported using `.{..}` HOT 4
- chpl__init_ModuleName(int64_t _ln, int32_t _fn) has mystery parameters HOT 1
- should identifier matches against the enclosing module name be considered if there are other matches? HOT 6
- Performance delta between Chapel and CUDA for `tanh` HOT 2
- `make test-cls` fails in quickstart config on M1 mac
- [Documentation]: Improve GPU Setup Documentation for CHPL_LOCALE_MODEL=gpu HOT 1
- Standalone Arkouda `ContrivedConstructor` caused compiler to throw unreasonable promotion/parameness error HOT 1
- [Feature Request]: Chapel OS packages with GPU support
- Add chpl-language-server documentation for vim and emacs HOT 6
- [Bug]: problems in LLVM or C codegen
- [Documentation]: Should we move the documentation on syntax highlighting into the online documentation? HOT 1
- [Feature Request]: Add support for DuckDB HOT 1
- Compiler LLVM fatal errors aren't very helpful without CHPL_DEVELOPER right now HOT 1
- [Feature Request]: support autocompletion for fish HOT 1
- Dyno: named declarations should report their indentation separately from their name locations
- Remove/Retire 'numa' locale model
- [Feature Request]: Lint rule for extra parentheses HOT 3
- [Feature Request]: Lint rule for line length HOT 1
- Compiling a `--library` with GPU support (or C++) should use C linkage in the generated header
- Moving tasks to sublocales doesn't work in the library mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chapel.