DMD 1.034 and 2.018 releases

Dave Dave_member at pathlink.com
Mon Aug 11 19:03:46 PDT 2008


"Walter Bright" <newshound1 at digitalmars.com> wrote in message 
news:g7na5s$qg0$1 at digitalmars.com...
> bearophile wrote:
>> Walter Bright:
>>> If this happens, then it's worth verifying that the asm code is
>>> actually being run by inserting a printf in it.
>>
>> I presume I'll have to recompile Phobos for that.
>
> Not really, it's easier to just copy that particular function out of the
> library and paste it into your test module, that way it's easier to
> experiment with.
>
>>>> And I haven't seen yet SS2 asm in my compiled programs :-)
>>> The dmd compiler doesn't generate SS2 instructions. But the
>>> routines in internal\array*.d do.
>>
>> I know. I was talking about the parts of the code that for example
>> adds the arrays; according to the phobos source code they use SSE2
>> but in the final source code produces they are absent.
>
> I don't know what you mean. The SSE2 instructions are in 
> internal/arrayint.d, and they do get compiled in.

The SSE2 is being used, but what would be nice would be the same code that 
Burton used for his benchmarks. Is that available?

Thanks,

- Dave

import std.stdio, std.date, std.conv;

void main(string[] args)
{
    if(args.length < 3)
    {
        writefln("usage: ",args[0]," <array size> <iterations>");
        return;
    }
    auto ASIZE = toInt(args[1]);
    auto ITERS = toInt(args[2]);
    writefln("Array Size = ",ASIZE,", Iterations = ",ITERS);
    int[] ia, ib, ic;
    ia = new int[ASIZE];
    ib = new int[ASIZE];
    ic = new int[ASIZE];
    ib[] = ic[] = 10;
    double[] da, db, dc;
    da = new double[ASIZE];
    db = new double[ASIZE];
    dc = new double[ASIZE];
    db[] = dc[] = 10.0;

    {
    ia[] = 0;
    int sum = 0;
    d_time s = getUTCtime();
    for(size_t i = 0; i < ITERS; i++)
    {
        sum += aops!(int)(ia,ib,ic);
    }
    d_time e = getUTCtime();
    writefln("intaops: ",(e - s) / 1000.0," secs, sum = ",sum);
    }

    {
    ia[] = 0;
    int sum = 0;
    d_time s = getUTCtime();
    for(size_t i = 0; i < ITERS; i++)
    {
        sum += loop!(int)(ia,ib,ic);
    }
    d_time e = getUTCtime();
    writefln("intloop: ",(e - s) / 1000.0," secs, sum = ",sum);
    }

    {
    da[] = 0.0;
    double sum = 0.0;
    d_time s = getUTCtime();
    for(size_t i = 0; i < ITERS; i++)
    {
        sum += aops!(double)(da,db,dc);
    }
    d_time e = getUTCtime();
    writefln("dfpaops: ",(e - s) / 1000.0," secs, sum = ",sum);
    }

    {
    da[] = 0.0;
    double sum = 0.0;
    d_time s = getUTCtime();
    for(size_t i = 0; i < ITERS; i++)
    {
        sum += loop!(double)(da,db,dc);
    }
    d_time e = getUTCtime();
    writefln("dfploop: ",(e - s) / 1000.0," secs, sum = ",sum);
    }
}

T aops(T)(T[] a, T[] b, T[] c)
{
    a[] = b[] + c[];
    return a[$-1];
}

T loop(T)(T[] a, T[] b, T[] c)
{
    foreach(i, inout val; a) val = b[i] + c[i];
    return a[$-1];
}

C:\Zz>dmd -O -inline -release top.d

C:\Zz>top 4000 100000
Array Size = 4000, Iterations = 100000
intaops: 0.204 secs, sum = 2000000
intloop: 0.515 secs, sum = 2000000
dfpaops: 0.625 secs, sum = 2e+06
dfploop: 0.563 secs, sum = 2e+06



More information about the Digitalmars-d-announce mailing list