-
Notifications
You must be signed in to change notification settings - Fork 424
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
Adjust inout to be implemented with a single argument #16180
Conversation
f0dd802
to
09cc519
Compare
f0f5785
to
78ea013
Compare
4f80b49
to
a442dff
Compare
41ccdbc
to
237cd31
Compare
18312d8
to
b81e239
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have mostly minor comments in-line. Depending on your level of confidence, you can also ask @vass to take a look, especially at the changes in wrappers.cpp. Otherwise, looks good!
|
||
if (developer == true) { | ||
retval = astr(retval, " [", istr(arg->id), "]"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for adding this
|
||
IntentTag intent = INTENT_OUT; | ||
if (outFormal->intent == INTENT_INOUT || | ||
outFormal->originalIntent == INTENT_INOUT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be nice to have a helper for checking intent
and originalIntent
as it repeats quite a few times
All this is trying to get this test ./test/arrays/ferguson/semantic-examples/4-pass-slice-inout.chpl to work
Some chpl__unref might still be called for tuples; a TODO is to investigate if that is still the case.
See e.g. test/arrays/bradc/arrOfDom/arrOfDom4.chpl
Because of the different way in which the initCopy for an iterator was being resolved, certain functions were not visible. Resolved that by adjusting fixInstantiationPointAndTryResolveBody to consider the case of a type that is not instantiated. Additionally, avoided recursion in resolving initCopy for an iterator by adding two `pragma "no copy"`s.
See e.g. classes/bradc/arrayInClass/genericArrayInClass-otharrs
See e.g. test/studies/kmeans/kmeans-blc.chpl
Per discussion in issue chapel-lang#16275 Also adds the test variants from chapel-lang#16275 to views-and-copying.chpl
The analysis in noAliasSets.cpp uses the flag FLAG_ALIASING_ARRAY to know when one array might alias another. Update rank change/reindex array types that do not alias to remove that flag.
See e.g. test/classes/initializers/promotion/test_promote_initializer_owned.chpl
For test/expressions/loop-expr/forall-over-zip-over-arrays.chpl
This reverts commit af113b3.
I created issue chapel-lang#16329 to ask if we should allow inout/out intents for extern/export.
For e.g. test/library/standard/DataFrames/psahabu/AddSeries.chpl
bc52208
to
0d30c64
Compare
Fix compilation errors with rank change/reindex privatize Follow-up to PR #16180 to fix compilation errors related to assignment between rank change / reindex arrays that differ in ownsArrInstance. These errors were coming about due to privatization support code. Trivial and not reviewed. - [x] full local testing - [x] `--no-local` testing
Fix formatting near inout intent and add discussion of iterators passing to in Follow-up to PR #16180. * fixes a few formatting errors * adds discussion of passing an iterator to an `in` intent argument Reviewed by @vasslitvinov - thanks!
Resolves #16290
Resolves #16185
Resolves #16195
Resolves #16148
Resolves #16275
Resolves #16301
Resolves #16298
Resolves #16300
Resolves #16007
This PR takes the following steps:
inout
to use a single argument instead of two argumentschpl__unref
and instead the compiler treats types that havechpl__initCopy
return a different type specially. Additionally, fordomains, instead of relying on runtime information, use compiler
analysis to identify functions that return unowned domains as with
A.domain
.chpl__initCopy
to return a different type tocoerce to that type. This allows iterators to pass to array arguments
with
in
intent (requested in issue Promoted expression cannot be passed as array argument #16007).Follow-up to PR #16143 which changed
inout
to be implemented with anin
argument and anout
argument. In reviewing that PR, Vass pointedout that there might be alternatives to the two-argument approach. Since
the copy-for-in and write-back-for-out are both now occurring at the call
site, it is possible for the function body to just accept a
ref
argument for
inout
. The function will accept the result of thecopy-for-in and then modify it. The code at the call site will do the
write-back from that to the original variable. This PR makes that change.
The implementation involved adjusting wrappers.cpp and adding a map to
track the value copied from in the
in
intent part ofinout
for use inthe
out
intent part.There is one inout behavior change:
This deinitializes
new R(20)
inside of the body ofout_inout
(insteadof transferring that responsibility to the call site). As a result, the
deinitialization order for
new R(20)
is different (20 is deinitializedbefore 10). The order of write-backs and other deinitializations at the
call site is still the same.
In the process of addressing problems with
inout
for arrays, Iidentified several issues related to array views and copy semantics such
as #16185 and #16195. This caused me to make the copy changes described
above including removing
chpl__unref
.Here is a more detailed summary of changes:
handling
getInstantiationType
that considers if the type shouldbe used for a value to be returned/stored in a variable/passed by in
intent. This calls
getCopyTypeDuringResolution
which keeps track ofresolved
initCopy
calls and the types that they return. When theresult of
initCopy
produces a different type, then the type needsspecial handling here. In particular, for example,
proc f(in arg)
called with an array view should instantiate with a non-view array
(resulting from the copy).
getCopyTypeDuringResolution
and to allowcoercion from a type to the result of
initCopy
on that type whenworking with an
in
/const in
/inout
formal argument.chpl__unalias
and mostchpl__unref
calls; replaces thesewith initCopy
A.domain
, use simplecompile-time tracking of such domains to add an
initCopy
forreturning the borrowed domain or passing it to
in
intent. AddsisCallExprTemporary
andisTemporaryFromNoCopyReturn
to implementthis analysis.
chpl__unalias
and to use the domain analysis to call it for caseslike
A.domain
A.domain
param ownsArrInstance
to distinguish between rank change/reindex arrays that own their
elements vs those that do not. Adjusted isRankChangeArrayView /
isReindexArrayView to return
false
for such arrays that own theirelements.
PRIM_SET_ALIASING_ARRAY_ON_TYPE
and uses it in rank change /reindex array views so that the
FLAG_ALIASING_ARRAY
flag on the typeis set appropriately and according to `param ownsArrInstance.
they can be used in more than one place.
FLAG_NO_COPY_RETURNS_OWNED
to work around an order-of-resolutionissue.
in updateVariableAutoDestroy.
--print-module-resolution
output to print out the path ofmodules being resolved for additional information. This is only
currently tested in the test named print-module-resolution.chpl.
functions and to copy all elements in initCopy functions
<<=
and>>=
functions to accept an integral shift amountthe way that
<<
and>>
do. This was to work around an issue thatis no longer present but seemed like an improvement.
const ref
intentfor sync/single arguments instead of
const
. This was to work aroundan issue that is no longer present but seems like an improvement.
Reviewed by @e-kayrakli - thanks!
Future work
nested call in function call returning runtime type executes twice #16316
runtime errors instead of compile-time errors. See problem with returning tuple of non-nilable owned #14942. This should
be revisited after the resolution of Should an iterator with blank yield intent yield value tuples? #16233 / Should 'ref' tuples store each component by reference? #15973.
ref
intent impactscandidate selection