-2

I must solve the problem of division inside nested loops in order to allow to Intel Compiler vectorization (using C / C++)

My question was concentrated about the vectorization issue, and not about the essence of the division.

Please read carefully, before categorizing the question.

Nor common search on the internet, nor Intel guides can give a concrete solution to that problem

My former question was formulated like this:

'How To Divide two float numbers without using the operator '/'. The result should be the float. '

Thanks

  • I see you tagged optimization. The compiler should know how to optimize a division, it does it all the time, so don't worry about that. – Havenard Mar 19 '17 at 07:40
  • I need it for vectorization of the loops. If there is a division operation inside the loop, Intel Compiler does not vectorize it – user2174850 Mar 19 '17 at 08:03
  • `x * pow(y, -1)`? Newton's method is about the only plausible software approach on systems with floating-point equipped hardware, but even so it will be a stretch outside of special cases. – doynax Mar 19 '17 at 08:04
  • @user2174850: Then x86 architecture _does_ support vector division. Try forcing loop data and count alignment as hints to your vectorizing optimizer if it does not generate the required code. Or manually unroll the loop loop and use SIMD intrinsics (`_mm_div_ps`, or `_mm_rcp_ps` along with newton's method if exact rounding is not required). – doynax Mar 19 '17 at 08:09
  • This is a very common assignment – a simple Google search would have gotten you a lot of resources. – JJJ Mar 19 '17 at 08:34
  • @user2174850 Are the possible divisorsall compile-time constants? Are they limited to a particular numerical range? By "float", do you mean a IEEE-754 `binary32` single-precision operand? Does your processor support the fused-multiply add (FMA) operation [Haswell architecture or younger]? – njuffa Mar 19 '17 at 20:16

1 Answers1

0

For the sake of homework as a brainbuilding exercise...try to abstract what division really is.

Try to create a method that will subtract variable a from variable b and increment variable c until it cannot subtract anymore and then for the remainder you could do the same on 1/10 of variable a to create decimal values until you reach the desired precision.

Var a=divisor

Var b=divided number

Var c=number of times a goes into b