March 11, 2020 Re: Aliases to mutable thread-local data not allowed [testable source code] | ||||
---|---|---|---|---|
| ||||
Posted in reply to mark | On Wednesday, 11 March 2020 at 09:29:54 UTC, mark wrote: > Hi Simen, > > I think you must have done something else but didn't mention to get it to compile. I did the exact changes you said and it wouldn't compile. Here's what I get with changes mentioned below (with new full source): Fascinating. It works just fine when compiling for 32-bit targets with DMD on Windows, but not for 64-bit targets, nor when compiling with LDC. Apparently, this difference is due to DMD supporting 80-bit reals, and thus giving a different size to Variant (VariantN!20 on DMD on Windows, VariantN!16 or VariantN!32 elsewhere). There's a bug in VariantN that then causes the compilation to fail (https://issues.dlang.org/show_bug.cgi?id=20666). The issue at hand then, is that Deb is too big until that issue if fixed. The simple solution to this is to allocate Deb on the heap with new and pass pointers instead of instances directly. Since you are already calling .dup whenever you pass a Deb somewhere, you can simply modify .dup to return a Deb* and the receive function to receive a Deb*, and I think you should be good to go. -- Simen |
March 11, 2020 Re: Aliases to mutable thread-local data not allowed [testable source code] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | On Wednesday, 11 March 2020 at 12:22:21 UTC, Simen Kjærås wrote: > On Wednesday, 11 March 2020 at 09:29:54 UTC, mark wrote: [snip] > Fascinating. It works just fine when compiling for 32-bit targets with DMD on Windows, but not for 64-bit targets, nor when compiling with LDC. Apparently, this difference is due to DMD supporting 80-bit reals, and thus giving a different size to Variant (VariantN!20 on DMD on Windows, VariantN!16 or VariantN!32 elsewhere). There's a bug in VariantN that then causes the compilation to fail (https://issues.dlang.org/show_bug.cgi?id=20666). > > The issue at hand then, is that Deb is too big until that issue if fixed. The simple solution to this is to allocate Deb on the heap with new and pass pointers instead of instances directly. Since you are already calling .dup whenever you pass a Deb somewhere, you can simply modify .dup to return a Deb* and the receive function to receive a Deb*, and I think you should be good to go. I did that and it compiles & runs, but no Debs get added to the collection. See https://github.com/mark-summerfield/d-debtest-experiment -- the 'mto' version is the one with your fixes. |
March 11, 2020 Re: Aliases to mutable thread-local data not allowed [testable source code] | ||||
---|---|---|---|---|
| ||||
Posted in reply to mark | On Wednesday, 11 March 2020 at 12:43:28 UTC, mark wrote:
> On Wednesday, 11 March 2020 at 12:22:21 UTC, Simen Kjærås wrote:
>> On Wednesday, 11 March 2020 at 09:29:54 UTC, mark wrote:
> [snip]
>> Fascinating. It works just fine when compiling for 32-bit targets with DMD on Windows, but not for 64-bit targets, nor when compiling with LDC. Apparently, this difference is due to DMD supporting 80-bit reals, and thus giving a different size to Variant (VariantN!20 on DMD on Windows, VariantN!16 or VariantN!32 elsewhere). There's a bug in VariantN that then causes the compilation to fail (https://issues.dlang.org/show_bug.cgi?id=20666).
>>
>> The issue at hand then, is that Deb is too big until that issue if fixed. The simple solution to this is to allocate Deb on the heap with new and pass pointers instead of instances directly. Since you are already calling .dup whenever you pass a Deb somewhere, you can simply modify .dup to return a Deb* and the receive function to receive a Deb*, and I think you should be good to go.
>
> I did that and it compiles & runs, but no Debs get added to the collection.
> See https://github.com/mark-summerfield/d-debtest-experiment -- the 'mto' version is the one with your fixes.
Yeah, I forgot we cast to immutable to be able to send, so receive has to receive immutable(Deb)*, after which you can call deb.dup to get a mutable copy:
receive(
(immutable(Deb)* deb) { debForName[deb.name] = deb.dup; },
(DoneMessage m) { jobs--; }
);
--
Simen
|
March 11, 2020 Re: Aliases to mutable thread-local data not allowed [testable source code] | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjærås | On Wednesday, 11 March 2020 at 14:01:13 UTC, Simen Kjærås wrote:
[snip]
> Yeah, I forgot we cast to immutable to be able to send, so receive has to receive immutable(Deb)*, after which you can call deb.dup to get a mutable copy:
>
> receive(
> (immutable(Deb)* deb) { debForName[deb.name] = deb.dup; },
> (DoneMessage m) { jobs--; }
> );
Thanks, that fixed it.
However, timing-wise the single threaded version (st) is fastest, then the task multi-threaded version (mt), and finally this version (mto).
|
Copyright © 1999-2021 by the D Language Foundation