Software Archive
Read-only legacy content
17061 Discussions

Computing Double/Float

Guillaume_S_
Beginner
573 Views

Hello,

 

I'm doing some financial computations (Monte Carlo, massively parralel algorithm) in a benchmark case and I wanted to analyze the potential difference of time computation between the use of single and double precision. My problem is that I don't observe at all any difference between float and double. So my question is is there a real difference ? Or I'm just doing something wrong ?

 

Computations are done on Server and on Xeon-Phi. I got the same results in term of performance: float ~ double. Loops are vectorised + OpenMP. I'm doing computation over large aligned arrays (few arithmetic operations + one exp per iteration..)

 

I'm using Intel compiler v15 updt 1. MPSS 3.2.1

 

Thanks

0 Kudos
3 Replies
TimP
Honored Contributor III
573 Views

You would want expf() in place of exp() (and check for auto-vectorization) to give float data types a chance at performance in C or C++.  Fortran generic exp() of course should choose precision automatically.  I'd hate to guess at further relevant details which you've omitted.

0 Kudos
McCalpinJohn
Honored Contributor III
573 Views

If the arrays are larger than the caches, then a computation that does a few arithmetic operations plus an exponential function could easily be memory-bandwidth-limited.  In that case I would expect float to be faster than double simply because there are twice as many floats in a cache line as there are doubles.  

In addition to double-checking the precision of the functions being used, it would be a good idea to look at the vector exponential functions in the Intel MKL library:   https://software.intel.com/sites/products/documentation/doclib/mkl_sa/112/vml/functions/exp.html

For these functions performance depends on the requested accuracy as well as the native data size (float vs double).  For a statistical technique like Monte Carlo the slightly increased errors of the "Enhanced Performance" mode are probably tolerable.

0 Kudos
Guillaume_S_
Beginner
573 Views

Hey,

 

Thank you for your replies both of you. I tried with "expf" function and yes I can observe a difference something almost equal to a factor of 2.

I will have a look at the vector exponential from the MKL library (arrays are ~ 6 M numbers).

 

Thank you

0 Kudos
Reply