Thread overview
Array Operations
Aug 19, 2010
Michael Parrott
Aug 19, 2010
Michael Parrott
Aug 20, 2010
Michael Parrott
Aug 20, 2010
Iain Buclaw
August 19, 2010
I have been trying to add the SSE2 array operation code to the compilation, but it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
Thank you,
JC
August 19, 2010
Jonathan Crapuchettes Wrote:

> I have been trying to add the SSE2 array operation code to the compilation, but
> it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
> Thank you,
> JC

Did you set DFLAGS before running configure? If you didn't, that might be why.

Example:

DFLAGS="-g"
export DFLAGS
../configure --enable-languages=d .....
make
sudo make install

Something like that should work.
August 19, 2010
I followed the example in issue #30: http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates

DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d --disable-multilib --disable-shared

Is this wrong?
JC

Michael Parrott wrote:
> Jonathan Crapuchettes Wrote:
>
>> I have been trying to add the SSE2 array operation code to the compilation, but
>> it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
>> Thank you,
>> JC
>
> Did you set DFLAGS before running configure? If you didn't, that might be why.
>
> Example:
>
> DFLAGS="-g"
> export DFLAGS
> ../configure --enable-languages=d .....
> make
> sudo make install
>
> Something like that should work.
August 19, 2010
Jonathan Crapuchettes Wrote:

> I followed the example in issue #30: http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates
> 
> DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d --disable-multilib --disable-shared
> 
> Is this wrong?
> JC
> 
> Michael Parrott wrote:
> > Jonathan Crapuchettes Wrote:
> >
> >> I have been trying to add the SSE2 array operation code to the compilation, but
> >> it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
> >> Thank you,
> >> JC
> >
> > Did you set DFLAGS before running configure? If you didn't, that might be why.
> >
> > Example:
> >
> > DFLAGS="-g"
> > export DFLAGS
> > ../configure --enable-languages=d .....
> > make
> > sudo make install
> >
> > Something like that should work.

No, that should be fine.

What is wrong when you do that? Are there errors when you build? Does Phobos not seem to be taking advantage of the SSE operations?

In phobos/internal/array{byte, double, float, int, short}.d, you need to uncomment the sections labelled "version (D_InlineAsm_X86)" to enable the ASM code.
August 19, 2010
Michael Parrott wrote:
> Jonathan Crapuchettes Wrote:
>
>> I followed the example in issue #30:
>> http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates
>>
>> DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d
>> --disable-multilib --disable-shared
>>
>> Is this wrong?
>> JC
>>
>> Michael Parrott wrote:
>>> Jonathan Crapuchettes Wrote:
>>>
>>>> I have been trying to add the SSE2 array operation code to the compilation, but
>>>> it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
>>>> Thank you,
>>>> JC
>>>
>>> Did you set DFLAGS before running configure? If you didn't, that might be why.
>>>
>>> Example:
>>>
>>> DFLAGS="-g"
>>> export DFLAGS
>>> ../configure --enable-languages=d .....
>>> make
>>> sudo make install
>>>
>>> Something like that should work.
>
> No, that should be fine.
>
> What is wrong when you do that? Are there errors when you build? Does Phobos not seem to be taking advantage of the SSE operations?
>
> In phobos/internal/array{byte, double, float, int, short}.d, you need to uncomment the sections labelled "version (D_InlineAsm_X86)" to enable the ASM code.

I did uncommented the version sections, but thank you for the reminder.

I can tell that the SSE code is not being used because I compared two pieces of code:

for (int i = 0; i < a.length; i++)
    c[i] = a[i] / 1000;

and

c[] = a[] / 1000;

They should produce the same result and they do, but the array operation code should be much faster. I base this assumption off of the same speed test using DMD. The execution time for the two code segments, produced by GDC, are about the same. I also compared the assembly for the objects created by GDC and DMD. The GDC code is not using the SSE code as specified in the arrayDouble.d file, but the DMD code is.

If you have suggestions, I am all ears.
Thank you for taking the time to help me,
JC
August 20, 2010
Jonathan Crapuchettes Wrote:

> Michael Parrott wrote:
> > Jonathan Crapuchettes Wrote:
> >
> >> I followed the example in issue #30: http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates
> >>
> >> DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d --disable-multilib --disable-shared
> >>
> >> Is this wrong?
> >> JC
> >>
> >> Michael Parrott wrote:
> >>> Jonathan Crapuchettes Wrote:
> >>>
> >>>> I have been trying to add the SSE2 array operation code to the compilation, but
> >>>> it seems like the DFLAGS variable isn't being used. Can you offer any suggestions?
> >>>> Thank you,
> >>>> JC
> >>>
> >>> Did you set DFLAGS before running configure? If you didn't, that might be why.
> >>>
> >>> Example:
> >>>
> >>> DFLAGS="-g"
> >>> export DFLAGS
> >>> ../configure --enable-languages=d .....
> >>> make
> >>> sudo make install
> >>>
> >>> Something like that should work.
> >
> > No, that should be fine.
> >
> > What is wrong when you do that? Are there errors when you build? Does Phobos not seem to be taking advantage of the SSE operations?
> >
> > In phobos/internal/array{byte, double, float, int, short}.d, you need to uncomment the sections labelled "version (D_InlineAsm_X86)" to enable the ASM code.
> 
> I did uncommented the version sections, but thank you for the reminder.
> 
> I can tell that the SSE code is not being used because I compared two pieces of code:
> 
> for (int i = 0; i < a.length; i++)
>      c[i] = a[i] / 1000;
> 
> and
> 
> c[] = a[] / 1000;
> 
> They should produce the same result and they do, but the array operation code should be much faster. I base this assumption off of the same speed test using DMD. The execution time for the two code segments, produced by GDC, are about the same. I also compared the assembly for the objects created by GDC and DMD. The GDC code is not using the SSE code as specified in the arrayDouble.d file, but the DMD code is.
> 
> If you have suggestions, I am all ears.
> Thank you for taking the time to help me,
> JC

Well, off the top of my head I can't think of anything else other than just trying to install GDC again. Perhaps you are giving the wrong -march option? (Maybe something other than pentium3?)
August 20, 2010
== Quote from Jonathan Crapuchettes (jcrapuchettes@gmail.com)'s article
> Michael Parrott wrote:
> > Jonathan Crapuchettes Wrote:
> >
> >> I followed the example in issue #30: http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates
> >>
> >> DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d --disable-multilib --disable-shared
> >>
> >> Is this wrong?
> >> JC
> >>
> >> Michael Parrott wrote:
> >>> Jonathan Crapuchettes Wrote:
> >>>
> >>>> I have been trying to add the SSE2 array operation code to the
compilation, but
> >>>> it seems like the DFLAGS variable isn't being used. Can you offer any
suggestions?
> >>>> Thank you,
> >>>> JC
> >>>
> >>> Did you set DFLAGS before running configure? If you didn't, that might be
why.
> >>>
> >>> Example:
> >>>
> >>> DFLAGS="-g"
> >>> export DFLAGS
> >>> ../configure --enable-languages=d .....
> >>> make
> >>> sudo make install
> >>>
> >>> Something like that should work.
> >
> > No, that should be fine.
> >
> > What is wrong when you do that? Are there errors when you build? Does Phobos
not seem to be taking advantage of the SSE operations?
> >
> > In phobos/internal/array{byte, double, float, int, short}.d, you need to
uncomment the sections labelled "version (D_InlineAsm_X86)" to enable the ASM
code.
> I did uncommented the version sections, but thank you for the reminder.
> I can tell that the SSE code is not being used because I compared two pieces
of
> code:
> for (int i = 0; i < a.length; i++)
>      c[i] = a[i] / 1000;
> and
> c[] = a[] / 1000;
> They should produce the same result and they do, but the array operation code
> should be much faster. I base this assumption off of the same speed test using
> DMD. The execution time for the two code segments, produced by GDC, are about
> the same. I also compared the assembly for the objects created by GDC and DMD.
> The GDC code is not using the SSE code as specified in the arrayDouble.d file,
> but the DMD code is.
> If you have suggestions, I am all ears.
> Thank you for taking the time to help me,
> JC

That's because the function called to perform the operation (_arraySliceExpDivSliceAssign_i) is not implemented in phobos - so a stock function is generated by the compiler instead.

Regards
August 20, 2010
Jonathan Crapuchettes wrote:
> Michael Parrott wrote:
>> Jonathan Crapuchettes Wrote:
>>
>>> I followed the example in issue #30:
>>> http://bitbucket.org/goshawk/gdc/issue/30/d_inlineasm-updates
>>>
>>> DFLAGS='-O2 -g -frelease -march=pentium3' ../configure --enable-languages=d
>>> --disable-multilib --disable-shared
>>>
>>> Is this wrong?
>>> JC
>>>
>>> Michael Parrott wrote:
>>>> Jonathan Crapuchettes Wrote:
>>>>
>>>>> I have been trying to add the SSE2 array operation code to the compilation,
>>>>> but
>>>>> it seems like the DFLAGS variable isn't being used. Can you offer any
>>>>> suggestions?
>>>>> Thank you,
>>>>> JC
>>>>
>>>> Did you set DFLAGS before running configure? If you didn't, that might be why.
>>>>
>>>> Example:
>>>>
>>>> DFLAGS="-g"
>>>> export DFLAGS
>>>> ../configure --enable-languages=d .....
>>>> make
>>>> sudo make install
>>>>
>>>> Something like that should work.
>>
>> No, that should be fine.
>>
>> What is wrong when you do that? Are there errors when you build? Does Phobos
>> not seem to be taking advantage of the SSE operations?
>>
>> In phobos/internal/array{byte, double, float, int, short}.d, you need to
>> uncomment the sections labelled "version (D_InlineAsm_X86)" to enable the ASM
>> code.
>
> I did uncommented the version sections, but thank you for the reminder.
>
> I can tell that the SSE code is not being used because I compared two pieces of
> code:
>
> for (int i = 0; i < a.length; i++)
> c[i] = a[i] / 1000;
>
> and
>
> c[] = a[] / 1000;
>
> They should produce the same result and they do, but the array operation code
> should be much faster. I base this assumption off of the same speed test using
> DMD. The execution time for the two code segments, produced by GDC, are about
> the same. I also compared the assembly for the objects created by GDC and DMD.
> The GDC code is not using the SSE code as specified in the arrayDouble.d file,
> but the DMD code is.
>
> If you have suggestions, I am all ears.
> Thank you for taking the time to help me,
> JC

Michael and Iain,
Thank you for your input. I just realized what my mistake was and now feel like I have wasted you time. The issue was that I was compiling the compiler as x86_64, which I need, and the version tag for the SSE2 is D_InlineAsm_X86 not D_InlineAsm_X86_64.

I'm thinking that I might play with converting the code in arrayDouble.d to x86_64, but I wouldn't hold my breath.

Thank you again for your help,
JC