www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linker error with array expressions

reply Clemens <eriatarka84 gmail.com> writes:
Hey all,

I've run across a bizarre linker error when using array expressions of the form

buf1[] = buf1[] + 0.5f * buf2[];

The linker gives me errors like this one:

OPTLINK (R) for Win32  Release 8.00.2
Copyright (C) Digital Mars 1989-2009  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
Test.obj(Test)  Offset 0037AH Record Type 00C3
 Error 1: Previous Definition Different :
__arraySliceSliceExpMulAddSliceAssign_f
--- errorlevel 2

This however only occurs under certain circumstances; I don't want to repeat
the details, they are in

http://d.puremagic.com/issues/show_bug.cgi?id=3683

I've only tested this with DMD on Windows for D1 so far, so it would be
interesting to know if the attached example gives the same error with D2.

In short, has anyone seen this before and knows of a workaround? Of course I
could rewrite the array expressions as loops, but I seem to recall Walter
mentioning that array expressions are optimized using SIMD operations. Is that
true? If so, I'm hesitant to throw that overboard since performance is an issue
(realtime audio synthesis).

Thanks,
Clemens
Jan 07 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Clemens:
 In short, has anyone seen this before and knows of a workaround? Of course I
could rewrite the array expressions as loops, but I seem to recall Walter
mentioning that array expressions are optimized using SIMD operations. Is that
true? If so, I'm hesitant to throw that overboard since performance is an issue
(realtime audio synthesis).<
If you care for performance then *always* time your code (in this case the two alternative versions with and without array ops), because what Walter and docs say is always less important that what the reality is. I've yet to find situations where array expressions have given me a speed-up over the normal code generated by LDC (if performance is quite important then don't use DMD). Also note that currently array ops are quite buggy and slow when the arrays are short. Bye, bearophile
Jan 07 2010
next sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
bearophile wrote:
 Also note that currently array ops are quite buggy
Is this in bugzilla?
Jan 07 2010
parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter Bright:
 Is this in bugzilla?
I think most of them are already in bugzilla. I'll put some bugs there. Bye, bearophile
Jan 07 2010
parent reply Clemens <eriatarka84 gmail.com> writes:
bearophile Wrote:

 Walter Bright:
 Is this in bugzilla?
I think most of them are already in bugzilla. I'll put some bugs there. Bye, bearophile
FWIW, I just reported another, particularly nasty one where the array operations stomps over the memory lying after the array: http://d.puremagic.com/issues/show_bug.cgi?id=3687 Clemens
Jan 07 2010
parent reply Clemens <eriatarka84 gmail.com> writes:
Clemens Wrote:

 bearophile Wrote:
 
 Walter Bright:
 Is this in bugzilla?
I think most of them are already in bugzilla. I'll put some bugs there. Bye, bearophile
FWIW, I just reported another, particularly nasty one where the array operations stomps over the memory lying after the array: http://d.puremagic.com/issues/show_bug.cgi?id=3687 Clemens
I now posted a patch to this ticket, though actually it's against druntime. To patches against druntime go on Bugzilla or on the druntime space on dsource? The latter seems pretty deserted. Anyway I wasn't sure, so I posted to both, sorry. Clemens
Jan 08 2010
parent Don <nospam nospam.com> writes:
Clemens wrote:
 Clemens Wrote:
 
 bearophile Wrote:

 Walter Bright:
 Is this in bugzilla?
I think most of them are already in bugzilla. I'll put some bugs there. Bye, bearophile
FWIW, I just reported another, particularly nasty one where the array operations stomps over the memory lying after the array: http://d.puremagic.com/issues/show_bug.cgi?id=3687 Clemens
I now posted a patch to this ticket, though actually it's against druntime. To patches against druntime go on Bugzilla or on the druntime space on dsource? The latter seems pretty deserted. Anyway I wasn't sure, so I posted to both, sorry.
It should go in Bugzilla.
Jan 08 2010
prev sibling parent Clemens <eriatarka84 gmail.com> writes:
bearophile Wrote:

 
 If you care for performance then *always* time your code (in this case the two
alternative versions with and without array ops), because what Walter and docs
say is always less important that what the reality is.
Of course I would time the code; as it stands though, the version with array operations doesn't even compile (or link, rather), due to the bug I reported.
I've yet to find situations where array expressions have given me a speed-up
over the normal code generated by LDC (if performance is quite important then
don't use DMD).
I would like to use LDC, but my main target platform is Windows, and consensus seems to be that LDC isn't usable there. Or is it possible to use it if I don't need exception handling? Can it generate DLLs? In any case, no LDC binaries for Windows seem to be available. What's the status with GDC? I think it was resurrected a while back; is there a current version available? Again, Windows? As far as I can tell at this point, I'm stuck with DMD for Windows development, for better or for worse. For now, I'll probably revert to loops for the offending code sections and replace them with hand-written inline SSE assembly if profiling shows a need for this. The simple loops I'm using here shouldn't be hard to write by hand. Still, it would be great if at some point DMD could do it by itself. Probably a distant dream at this point... Clemens
Jan 07 2010