FPU problems (again)

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

FPU problems (again)

Post 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? :oops:
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?
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: FPU problems (again)

Post 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...
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

Re: FPU problems (again)

Post 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...
Cjreek
Member
Member
Posts: 70
Joined: Thu May 28, 2009 2:41 pm
Location: Germany

Re: FPU problems (again)

Post by Cjreek »

I don't know which detail I can provide.
Your initialization code might be useful :roll:
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FPU problems (again)

Post 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?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

Re: FPU problems (again)

Post 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! :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FPU problems (again)

Post 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 :wink:.

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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

Re: FPU problems (again)

Post 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 :wink:.

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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FPU problems (again)

Post 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?"
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

Re: FPU problems (again)

Post 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
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: FPU problems (again)

Post by gerryg400 »

Did you do an

Code: Select all

fninit
on the ap core
If a trainstation is where trains stop, what is a workstation ?
matute81
Member
Member
Posts: 33
Joined: Tue Sep 28, 2010 2:47 am

Re: FPU problems (again)

Post by matute81 »

gerryg400 wrote:Did you do an

Code: Select all

fninit
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
#-o
So I asked some help here...not because I don't want to resolve it myself!
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: FPU problems (again)

Post by JamesM »

matute81 wrote:
gerryg400 wrote:Did you do an

Code: Select all

fninit
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
#-o
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.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: FPU problems (again)

Post 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 ?
If a trainstation is where trains stop, what is a workstation ?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: FPU problems (again)

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply