Page 1 of 2
FPU problems (again)
Posted: Tue Oct 19, 2010 4:03 am
by matute81
Hello,
I have another question about FPU.
Does Anybody know why the same procedure that I use for FPU initialization works for BSP core but not for AP?
I have the same control registers configuration on BSP and AP.
Another question is about Visual C++ 2008 compiler:
I developed a math library for floating point operations. If I compile this library without /QIFIST option (that will be deprecated) when I use it in a task or program I receive this linker error:
error LNK2019: riferimento al simbolo esterno __ftol2_sse non risolto nella funzione ___kernel_sin
(in english is: cannot resolve external symbol reference __ftol2_sse)
I cannot use default libraries because I'm developing a SIL4 system.
I know what is ftol2_sse but I don't know how to resolve this problem without using \QIFIST options.
Could you help me guys?
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 4:57 am
by JamesM
Does Anybody know why the same procedure that I use for FPU initialization works for BSP core but not for AP?
Because your code is broken? Seriously, that's the best answer I can give without you providing any details whatsoever...
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 5:49 am
by matute81
I don't know which detail I can provide.
Because my FPU initialization code is working on BSP, but not on AP.
When I try to execute a floating point instruction (f.e.: "float f = 0.1;") I receive an exception from AP's FPU...
I don't know what can i do to find the problem...
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 6:58 am
by Cjreek
I don't know which detail I can provide.
Your initialization code might be useful
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 7:09 am
by Combuster
The intel manuals have an exhaustive list of causes for exceptions per exception number, as well as potential exceptions per instruction. Have you looked through those?
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 7:23 am
by matute81
@Cjreek:
nasm assembly:
Code: Select all
FUNCTION SysFpuInit
push eax
mov eax, cr0
and eax, 0xfffffffb
or eax, 0x22
mov cr0, eax
clts
pop eax
ret
ENDFUNC SysFpuInit
@Combuster
I read Intel reference for FPU exception, by now I can't find any help to resolve so I try to ask here!
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 8:10 am
by Combuster
I read Intel reference for FPU exception, by now I can't find any help to resolve so I try to ask here!
You missed the point. You get an exception, that means you have an exception number, instruction causing the fault, and a CPU state. Have you gone through all the options listed under that instruction (intel 2A/B) to see what caused the fault in question? Have you gone through all the common causes for that exception (intel 3A) and eliminated them one by one?
If no, you have some work to do
.
If yes, you did something wrong. Post the state mentioned above, and the list of causes in the manual and explain to us, for each of them, why they can not be the cause. That way we can actually see the mistake and help you out.
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 9:48 am
by matute81
Combuster wrote:I read Intel reference for FPU exception, by now I can't find any help to resolve so I try to ask here!
You missed the point. You get an exception, that means you have an exception number, instruction causing the fault, and a CPU state. Have you gone through all the options listed under that instruction (intel 2A/B) to see what caused the fault in question? Have you gone through all the common causes for that exception (intel 3A) and eliminated them one by one?
If no, you have some work to do
.
If yes, you did something wrong. Post the state mentioned above, and the list of causes in the manual and explain to us, for each of them, why they can not be the cause. That way we can actually see the mistake and help you out.
Yes! I examine the exception linked with "my" status word.
When I execute this instruction "f = 5.0, where f is defined as float", I obtain 33473 in status word.
Now I'm a little confused but this value means Stack overflow exception:
Code: Select all
When the x87 FPU detects stack overflow or underflow, it sets the IE flag (bit 0) and
the SF flag (bit 6) in the x87 FPU status word to 1. It then sets condition-code flag C1
(bit 9) in the x87 FPU status word to 1 if stack overflow occurred or to 0 if stack
underflow occurred.
So I can't understand why if I execute that (or other) floating point instruction on BSP all works and on AP no!
Any help?
Re: FPU problems (again)
Posted: Tue Oct 19, 2010 2:20 pm
by Combuster
So it is a FPU stack overflow. What does that mean? Can you make one occur under any condition? What do you need to make that happen? How can you prevent that from happening?
Debugging effort is not about spending x minutes on the task and then asking, it requires that you spent at least x minutes on every clue you get. If you discover something possibly related to the problem, it means you have even more debugging to do. Unless, of course, you found the source of the problem.
Bad questions involve "I walked 10 miles, I'm bored. Can someone drive me the last two miles?", Good questions involve "I walked 10 miles but the environment looks the same, can someone come pick me up?"
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 1:19 am
by matute81
Combuster wrote:So it is a FPU stack overflow. What does that mean? Can you make one occur under any condition? What do you need to make that happen? How can you prevent that from happening?
Debugging effort is not about spending x minutes on the task and then asking, it requires that you spent at least x minutes on every clue you get. If you discover something possibly related to the problem, it means you have even more debugging to do. Unless, of course, you found the source of the problem.
Bad questions involve "I walked 10 miles, I'm bored. Can someone drive me the last two miles?", Good questions involve "I walked 10 miles but the environment looks the same, can someone come pick me up?"
Dear Combuster,
I post a question about this because is incomprehensible for me why a code that works on one core don't works for other core. If you can't or don't want to explain me why I have a stack overflow when I assign a value to a floating point variable no problem, but don't give me a life lesson ok? I'm searching for answers not unuseful lessons.
Thank you anyway
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 2:26 am
by gerryg400
Did you do an
on the ap core
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 3:58 am
by matute81
gerryg400 wrote:Did you do an
on the ap core
Sure!
The strangest thing is that the status word after initialization is not 0, like it should be after a fninit instruction (and like it is on BSP core). There must be something wrong in AP's FPU initialization but I'm not able to find what
So I asked some help here...not because I don't want to resolve it myself!
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 4:02 am
by JamesM
matute81 wrote:gerryg400 wrote:Did you do an
on the ap core
Sure!
The strangest thing is that the status word after initialization is not 0, like it should be after a fninit instruction (and like it is on BSP core). There must be something wrong in AP's FPU initialization but I'm not able to find what
So I asked some help here...not because I don't want to resolve it myself!
You can be as annoyed as you like, but you didn't mention that you'd performed an fninit before, and you didn't mention that the status word was different before.
Garbage in, Garbage out.
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 4:05 am
by gerryg400
matute81 wrote:@Cjreek:
nasm assembly:
Code: Select all
FUNCTION SysFpuInit
push eax
mov eax, cr0
and eax, 0xfffffffb
or eax, 0x22
mov cr0, eax
clts
pop eax
ret
ENDFUNC SysFpuInit
Where is the fninit ?
Re: FPU problems (again)
Posted: Wed Oct 20, 2010 4:08 am
by Combuster
matute81 wrote:Dear Combuster,
I post a question about this because is incomprehensible for me why a code that works on one core don't works for other core. If you can't or don't want to explain me why I have a stack overflow when I assign a value to a floating point variable no problem, but don't give me a life lesson ok? I'm searching for answers not unuseful lessons.
Thank you anyway
You too, young padawan, must learn that giving a fish feeds a man for a day, and teaching to fish feeds a man for a lifetime. If you know how to debug, you know how to solve most of your development problems. Just remember if you don't want my kind of help, don't give me the excuse to give my kind of help, because I will.
Now since gerry's (and mine) initial guess was wrong, show us the facts you keep hiding from us, which are incidentally the facts you should be using to make your own conclusion.