it does not matter but if you know it is a softprocessor on FPGA, it
does not have hardware for double precision (64bit )
so I add a custom hardware on bus of system, it gives me a lot of
speed compare to C++ library implementation of double precision
operations,
but if I dont find a good way to redirect using of my code ( which
works with that hardware) instead of C++ library code ,for double
operations , its timing overhead will compensate its speed!
difficulty of changing operations in all of my code to a new function
call is impossilbe because code is too big.
Ah, if the alternative is your compiler's non-FPU library functions,
then you might be able to provide your own implementation of the
floating-point routines, replacing the ones in the C library.
usually [ double operator*(double, double) ] does not work because
double is a predefined system type.
changing all of code manually is not a good way for me so I want to
find an automatic way.
first solution I tried was to define a class with one double variable
inside. then overload * for that class, but it is not good because it
has a lot of timing overhead ,
If "timing overhead" means it runs slower than whatever alternative
you have: are you sure this is the case, with a decent compiler with
optimization turned on? My assumption (I haven't investigated deeply)
is that you can easily get a struct Foo { double val; } to generate
code that's just as fast as a naked double.
I am sure about my timing measurement, optimization is off to exact
measurement
Then it's not surprising that your code is slower! It's the optimizer
and nothing but the optimizer which removes the overhead (e.g. by
inlining function calls).
and a hardware timer is used to measure code runtime.....
"timing overhead" means time elapsed to use my hardware, for example
writing to that new hardware and reading result or waiting for
completion of computation,
I did what you say, but I used class instead of struct, ( i will try
struct )
Struct and class is the same thing, for these purposes.
but after deeply measurement, I saw referring to a double
type is faster than a class t Foo { double val; },
is there anyway to replace library of C++ with my code? I want to
replace c++ implementation of double*double with my code, then every
thin will solve!!
Impossible to say without knowing which compiler you use. I don't even
know how gcc implements soft-float ... I only know the ancient Lattice
C compiler for the Commodore-Amiga had library routines with funny
names for operating on floats and doubles. (You could even choose
between IEEE versions and some Commodore- or Motorola-specific
representation.)
/Jorgen