_mm_monitor/_mm_mwait examples

_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 ?MickalHello,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

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

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

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

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

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

Jennifer

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

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

int a=0, int b=0;
if (!c.flags) {
  _mm_monitor(&c.flags, a, b); 
  _mm_mwait(a, b);
}

Quoting prazWell, 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

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)."

Leave a Comment

Please sign in to add a comment. Not a member? Join today