Community
cancel
Showing results for 
Search instead for 
Did you mean: 
amgastineau1
Beginner
257 Views

_mm_monitor/_mm_mwait examples

Hello,
I'm developping a very fine-grained parallel application. To synchronize my threads which performs the same computation, I use spin-loops using the following style "while(value!=1) {};" to minimize the execution time.
I see that SSE3 provides the _mm_monitor/_mm_mwait intrinsics.
Are these intrinsics available at the user space (not ring 0)?
But I didn't find any example on how I can use these statements.
Does someone have a small example?
Does someone have some benchmarks about these intrinsics ?
The documentation says "CPUID allows for the determination of the exact length of the triggering area".
In which field can I find this size ?
Mickal
Hello,I'm developping a very fine-grained parallel application. To synchronize my threads which performs the same computation, I use spin-loops using the following style "while(value!=1) {};" to minimize the execution time.I see that SSE3 provides the _mm_monitor/_mm_mwait intrinsics.Are these intrinsics available at the user space (not ring 0)?But I didn't find any example on how I can use these statements.Does someone have a small example?Does someone have some benchmarks about these intrinsics ?The documentation says "CPUID allows for the determination of the exact length of the triggering area".In which field can I find this size ?Mickal
0 Kudos
7 Replies
Aubrey_W_
New Contributor I
257 Views

Hello Mickal,

Which complier are you using? It might be best for us to move your question to the appropriate compiler forum, to see if our technical consulting engineers can answer it.

Best regards,

==
Aubrey W.
Intel Software Network Support

amgastineau1
Beginner
257 Views

hello,
I use the intel compiler c++ 11.1. Yes, you can move it to the correct forum.
Best regards,
Mickal
JenniferJ
Moderator
257 Views

Please check this article - http://software.intel.com/en-us/articles/use-the-monitor-and-mwait-streaming-simd-extensions-3-instr...to see if it provides you enough info.

The reference link at the bottom points you to the comprehensive doc.

Jennifer
amgastineau1
Beginner
257 Views

This documentation is clear but it does not specify if that instruction is available at user ring level.
Clear explanations are available in the section "Checking for SSE3 Support" of the manual "IA-32 Intel Architecture Software Developers Manual Volume 1 Basic Architecture".
Does linux support this type of instruction at the user application level ?
Does someone perform a benchmark of this instructions against spin-loop, such as "while (*address!=1) {}" ?
I want to use these instructions to synchronize threads in a N-body problem with N is very small.
Mickal
P_V__Hariprasad
Beginner
257 Views

Well, is there someone that used these instructions? With a simple test it gives me "Illegal Instruction".
[cpp]int a=0, int b=0;
if (!c.flags) {
  _mm_monitor(&c.flags, a, b); 
  _mm_mwait(a, b);
}[/cpp]
SergeyKostrov
Valued Contributor II
257 Views

Quoting praz
Well, is there someone that used these instructions? With a simple test it gives me "Illegal Instruction"...

You need to verify ifMONITOR and MWAIT instructions aresupported on your CPU and if they could be executed
at a privilege level 3. Please take a look at IntelInstruction Set Reference volume 2A ( A-M ). A CPUID instriction
has to be used for verifications.

Best regards,
Sergey
P_V__Hariprasad
Beginner
257 Views

I don't haveantiques, so yes, it's supported. I've found the info inIntelInstruction Set Referencevolume 2B:
"MONITOR may be executed only at privilege level 0 (use atany other privilege level results in an invalid-opcode exception)."
Reply