[vector] Non capturing lambda
Viswanathan, Sandhya
sandhya.viswanathan at intel.com
Fri Mar 1 05:57:26 UTC 2019
The corresponding webrev is at:
http://cr.openjdk.java.net/~sviswanathan/vectorIntrinsics/Brian/zero/webrev.03/
Best Regards,
Sandhya
-----Original Message-----
From: Viswanathan, Sandhya
Sent: Thursday, February 28, 2019 9:40 PM
To: 'Vladimir Ivanov' <vladimir.x.ivanov at oracle.com>; panama-dev at openjdk.java.net
Cc: Brian Goetz <brian.goetz at oracle.com>; John Rose <john.r.rose at oracle.com>
Subject: RE: [vector] Non capturing lambda
Hi Vladimir,
No worries, I have pushed the phase 1 changes:
http://hg.openjdk.java.net/panama/dev/rev/568ed3b9098b
All the tests continue to pass.
Please take a look, specifically the VectorIntrinsics.broadcastCoereced()/load()/loadWithMap() changes to use species and their uses in XxxVector.java and XxxNnnVector.java.
Best Regards,
Sandhya
-----Original Message-----
From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com]
Sent: Thursday, February 28, 2019 2:48 PM
To: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; panama-dev at openjdk.java.net
Cc: Brian Goetz <brian.goetz at oracle.com>; John Rose <john.r.rose at oracle.com>
Subject: Re: [vector] Non capturing lambda
> Your second suggestion looks appealing to me, I will incorporate that and push the changes before any other changes to the API needing me to remerge.
Sorry for the inconveniences caused by the new check. I would've waited
until the refactoring lands first and address it myself (as I did with
existing cases of capturing) if I knew it is affected.
Best regards,
Vladimir Ivanov
> -----Original Message-----
> From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com]
> Sent: Wednesday, February 27, 2019 7:47 PM
> To: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; panama-dev at openjdk.java.net
> Cc: Brian Goetz <brian.goetz at oracle.com>; John Rose <john.r.rose at oracle.com>
> Subject: Re: [vector] Non capturing lambda
>
>
>> The whole of work suggested by Brian to make Species more as values is dependent on this e.g. moving the fromByteArray, fromArray etc methods from XxxNnnSpecies to XxxVector (Int128Species to IntVector as an example). The methods cannot be moved to XxxNnnVector as the concrete classes are not to be made visible to the user.
> It can be fixed either by introducing a package-private method on
> XxxSpecies:
>
> public static IntVector fromArray(IntSpecies species, int[] a, int i) {
> return species.*fromArrayInternal*(a, i);
> }
>
> or adding a new argument to VectorIntrinsics.load() and
> VectorIntrinsics.LoadOperation:
>
> public static IntVector fromArray(IntSpecies species, int[] a, int i){
> ...
> return VectorIntrinsics.load(...,
> a, i, *species*,
> (c, idx, *s*) -> s.op(n -> c[idx + n]));
> }
>
> I'm fine with both.
>
>> Is this a requirement that the lambda be non capturing? I know you added this check recently. What are the downsides? There must be some way, there always is usually :).
>
> As previous experience showed, capturing from default implementaiont
> easily breaks vector box elimination by accessing vector box instance.
> (It's not the case in this particular case though, but I couldn't come
> up with a better way to check there's no vector box access happening.)
>
> Best regards,
> Vladimir Ivanov
>
>> -----Original Message-----
>> From: Vladimir Ivanov [mailto:vladimir.x.ivanov at oracle.com]
>> Sent: Wednesday, February 27, 2019 5:08 PM
>> To: Viswanathan, Sandhya <sandhya.viswanathan at intel.com>; panama-dev at openjdk.java.net
>> Cc: Brian Goetz <brian.goetz at oracle.com>; John Rose <john.r.rose at oracle.com>
>> Subject: Re: [vector] Non capturing lambda
>>
>> Hi Sandhya,
>>
>>> The question I have is why is the following lambda considered a
>>> capturing lambda? The "species" is a parameter so cannot be
>>> capturing, am I correct? The rest of the lambda is as before.
>>>
>>> (c, idx) -> species.op(n ->
>>> c[idx
>>> + n])
>>
>> 'species' isn't a lambda parameter. It's a part of context and has to be captured, since it is used in the lambda body.
>>
>> In order to keep lambdas which represents default implementations non-capturing, only its arguments and static fields are allowed to be used.
>>
>> I don't see an easy way to fix that without introducing new VectorIntrinsics variants to pass 'species' instance into default implementation.
>>
>> I suggest to move the implementation back to Species and call it from XxxVector instead.
>>
>> Best regards,
>> Vladimir Ivanov
>>
More information about the panama-dev
mailing list