public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* sqrt in kernel?
@ 2001-05-20 20:33 Robert M. Love
  2001-05-20 21:33 ` Matti Aarnio
  2001-05-20 21:33 ` John Levon
  0 siblings, 2 replies; 4+ messages in thread
From: Robert M. Love @ 2001-05-20 20:33 UTC (permalink / raw)
  To: linux-kernel

hi,

is there a sqrt function in the kernel? any other math functions?

i tried finding/grepping around, and found some various arch-specific
stuff for fpu emulation... is there a general sqrt function?  is there a
single file to look through with the various math functions?

thanks,

-- 
Robert M. Love
rml@ufl.edu
rml@tech9.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sqrt in kernel?
  2001-05-20 20:33 sqrt in kernel? Robert M. Love
@ 2001-05-20 21:33 ` Matti Aarnio
  2001-05-20 23:31   ` Ingo Molnar
  2001-05-20 21:33 ` John Levon
  1 sibling, 1 reply; 4+ messages in thread
From: Matti Aarnio @ 2001-05-20 21:33 UTC (permalink / raw)
  To: Robert M. Love; +Cc: linux-kernel

On Sun, May 20, 2001 at 04:33:20PM -0400, Robert M. Love wrote:
> hi,
> 
> is there a sqrt function in the kernel? any other math functions?

	No.  (Assuming FP math sqrt function is your interest.)

	If you do scaled integers (fractions, with 2^n denominator),
	you can do newton iteration for sqrt nicely.

> i tried finding/grepping around, and found some various arch-specific
> stuff for fpu emulation... is there a general sqrt function?  is there a
> single file to look through with the various math functions?

	Yes.  Userspace.  ( <math.h> )

	As a rule:  NO FP MATH IS ALLOWED IN THE KERNEL!

	Now the question:  Why do you think you need FP math ?

	If your case is non-fast-path, you may do complete
	state save before, and restore after your FP code.


	In some cases even the fast-paths carry FP/MMX code,
	but those are cases where the save/restore overhead
	becomes negligible for all of the other processing
	that is going on.

> thanks,
> -- 
> Robert M. Love
> rml@ufl.edu
> rml@tech9.net

/Matti Aarnio

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sqrt in kernel?
  2001-05-20 20:33 sqrt in kernel? Robert M. Love
  2001-05-20 21:33 ` Matti Aarnio
@ 2001-05-20 21:33 ` John Levon
  1 sibling, 0 replies; 4+ messages in thread
From: John Levon @ 2001-05-20 21:33 UTC (permalink / raw)
  To: Robert M. Love; +Cc: linux-kernel

On 20 May 2001, Robert M. Love wrote:

> hi,
> 
> is there a sqrt function in the kernel?

no. read the FAQ.

> i tried finding/grepping around, and found some various arch-specific
> stuff for fpu emulation... is there a general sqrt function?  is there a

In general questions like this are better asked on the kernelnewbies list. Read
the FAQ.

john


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: sqrt in kernel?
  2001-05-20 21:33 ` Matti Aarnio
@ 2001-05-20 23:31   ` Ingo Molnar
  0 siblings, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2001-05-20 23:31 UTC (permalink / raw)
  To: Matti Aarnio; +Cc: Robert M. Love, linux-kernel


On Mon, 21 May 2001, Matti Aarnio wrote:

> 	In some cases even the fast-paths carry FP/MMX code,
> 	but those are cases where the save/restore overhead
> 	becomes negligible for all of the other processing
> 	that is going on.

even in that case you must make sure you dont raise any FP exceptions,
which could change the non-CPU based FPU context of the process.

	Ingo


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-05-20 23:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-20 20:33 sqrt in kernel? Robert M. Love
2001-05-20 21:33 ` Matti Aarnio
2001-05-20 23:31   ` Ingo Molnar
2001-05-20 21:33 ` John Levon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox