qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-ppc] How to add my implementation of the fmadds instruction to


From: David Gibson
Subject: Re: [Qemu-ppc] How to add my implementation of the fmadds instruction to QEMU
Date: Tue, 27 Sep 2016 13:41:42 +1000
User-agent: Mutt/1.7.0 (2016-08-17)

On Mon, Sep 26, 2016 at 09:05:22PM -0400, G 3 wrote:
> I made my own experimental implementation of the fmadds instruction that I
> would like to add to QEMU. How would I do this?
> 
> My implementation would probably look like this:
> 
> void fmadds(float *frD, float frA, float frC, float frB)
> {
>       *frD = frA * frC + frB;
> }

So.. using a helper essentially?

You'd need to submit a patch adding the new implementation, with a
commit message which made the case for replacing the existing
implementation with yours.  So, you'd need data to suggest both that
your version generates correct results, and that it is faster or
otherwise better than the existing one.

> 
> 
> I then want to see if this implementation will make things faster. This code
> will test my implementation:
> 
> #include <stdio.h>
> #include <time.h>
> 
> /*
>     fmadds basically does this frD = frA * frC + frB
> */
> 
> int main (int argc, const char * argv[]) {
>     const int iteration_count = 100000000;
>     double iter, frD, frA, frB, frC;
>     clock_t start_time, end_time;
> 
>     frA = 10;
>     frB = 5;
>     frC = 2;
> 
>     start_time = clock();
>     for(iter = 0; iter < iteration_count; iter++)
>     {
>         asm volatile("fmadds %0, %1, %2, %3" : "=f" (frD) : "f" (frA), "f"
> (frC), "f" (frB));
>     }
>     end_time = clock();
>     printf("frD:%f frA:%f frB:%f frC:%f\n", frD, frA, frB, frC);
>     printf("Time elapsed: %0.2f seconds\n", (float)(end_time - start_time) /
> CLOCKS_PER_SEC);
> 
>     return 0;
> }
> 
> 

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]