- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have written a function in that AVX2 instructions are using XMM/YMM registers. Due to use of some of these registers in this function, causing other part of application is crashing. I have observed strange behavior is that If these registers are pushed and popped as like non-volatile general purpose registers are pushed and popped.
Please help me whether, we need to push and pop the SIMD registers also. If so all XMM/YMM registers are needs to be saved and how?
Up to now I didn't read any thing about saving of the XMM/YMM registres also, but my application is working after these changes only
- Tags:
- Intel® Advanced Vector Extensions (Intel® AVX)
- Intel® Streaming SIMD Extensions
- Parallel Computing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I like Agner Fog's document describing the calling/linkage conventions here. See section 6 on register usage.
Some registers are "scratch" and are not expected to live across calls. Others, the callee (not caller) must save/restore if they want to mutate them inside the callee.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I have written a function in that AVX2 instructions are using XMM/YMM registers. Due to use of some of these registers in this function, causing other part of application is crashing. I have observed strange behavior is that If these registers are pushed and popped as like non-volatile general purpose registers are pushed and popped, It is is not crashing and it is working fine.
Please help me whether, we need to push and pop the SIMD registers also. If so all XMM/YMM registers are needs to be saved and how?
Up to now I didn't read any thing about saving of the XMM/YMM registres also, but my application is working after these changes only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean push xmm0? You can emulate this instruction with these one:
sub ebp , 16
movdqu xmmword ptr[ebp], xmm0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My main concern is - is it really requires the push XMM registers in to the stack/register at the start of function and pop it back to XMM registers from stack/register at the exit point?. I am not worrying about whether these are possible with PUSH/POP instructions or equivalent emulated instructions.
Is this mandatory to push and pop the SIMD registers when we are using these? if so performance degrades so much.
I am feeling that this is not required when comes to the SIMD registers, not like for general purpose registers usage. Please confirm. These are testing through SDE emulator. or this is an emulator issue?
part of not working code:
push rbp
mov rbp, rsp
push rsi
//initially ymm8 is having some value
mov esi, 2
movd xmm8, esi //modifying the xmm8 register value
vpbroadcastb ymm8, xmm8 //broadcasted the value
pop rsi
mov rsp, rbp
pop rbp
ret
part of working code:
push rbp
mov rbp, rsp
push rsi
//initially ymm8 is having some value
vmovdqu ymm9, ymm8 //pushing the YMM8 Initial value to YMM9
mov esi, 2
movd xmm8, esi //modifying the xmm8 register value
vpbroadcastb ymm8, xmm8 //broadcasted the value
vmovdqu ymm8, ymm9 //poping the YMM8 Initial value from YMM9 to YMM8
pop rsi
mov rsp, rbp
pop rbp
ret
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I like Agner Fog's document describing the calling/linkage conventions here. See section 6 on register usage.
Some registers are "scratch" and are not expected to live across calls. Others, the callee (not caller) must save/restore if they want to mutate them inside the callee.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Now I understand your question.
Btw, can you post the output from VS debugger where the application crashes?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In other words you're trying to compete with a modern C/C++ compiler?
A very bad idea. You'll lose in most cases.
The GNU C is much smarter than most of us!
Besides that the code is more clear and portable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mark,
Thank you very much for provided the very very useful document. Now I understand what was the problem.
>>Btw, can you post the output from VS debugger where the application crashes?
iliayapolak, the actual implementation function is part of one of multimedia applications.Just for understanding the issue I have given the esample code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>>iliayapolak, the actual implementation function is part of one of multimedia applications.Just for understanding the issue I have given the esample code>>>
Ok I thought that you could be interested in further troubleshooting.
![](/skins/images/45C6C2D737ED71F4C51F0145C8CB1E9C/responsive_peak/images/icon_anonymous_message.png)
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page