Software Archive
Read-only legacy content
17061 ディスカッション

Computing Double/Float

Guillaume_S_
ビギナー
577件の閲覧回数

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 件の賞賛
3 返答(返信)
TimP
名誉コントリビューター III
577件の閲覧回数

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.

McCalpinJohn
名誉コントリビューター III
577件の閲覧回数

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.

Guillaume_S_
ビギナー
577件の閲覧回数

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

返信