dense<f64> * scalar in arbb_random.h

dense<f64> * scalar in arbb_random.h

Hi,When I changed "fptype" from float to double in samples/finance/monte-carlo/monte-carlo.h, the compile fails because operator* doesn't support dense-float operation.See line 283, 284 in randomlib/arbb_random.harbb::dense sqlln_u1 = sqrt(arbb::log(u1) * (arbb::f32)(-2));norm = sqlln_u1 * sin(u2 * (arbb::f32)(2 * PI));I want dense::operator* to handle float as operand as plain C does.Though, a quick workaround would be changing code as follows.arbb::dense sqlln_u1 = sqrt(arbb::log(u1) * (T)(-2));norm = sqlln_u1 * sin(u2 * (T)(2 * PI));Thanks,Ken

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Best Reply

Hi Ken,

Thanks for trying out the monte-carlo code sample. The code in arbb_random.h may need some improvement to not use the hard-coded "f32" in the explicit casting. The workaround you found is correct. The code in line 283 and 284 should have been wirtten in this way.

On the other hand, it is actually NOT a bug that dense::operator* in ArBB does not perform implicit casting between f32 and f64 as what the plain C would do. Casting in the context of vectorization can be expensive. Intel ArBB decides to force programmers to always use explicit casting in code that involve mixed data types. The purpose is to discourage unncessary type casting, as well as to help reduce logical bugs that are often introduced by implicit casting.


Thanks Zhang for the explanation about casting in ArBB. That would be very helpful when I write my own program with ArBB.looking forward to the next release (beta2?).Regards,Ken

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen