Software Archive
Read-only legacy content
17061 Discussions

GCC 4.7 bug with C++11 atomics

Randolf_R_
Beginner
769 Views

We use C++11 atomics for the implementation of communication queues. With the gcc 4.7 from MPSS 3.2.1 the compiler generates following error:

{standard input}: Assembler messages:
{standard input}:5116: Error: `mfence' is not supported on `k1om'

Is this problem solved in later versions of MPSS?

 

0 Kudos
5 Replies
pbkenned1
Employee
769 Views

Example please?

Patrick

0 Kudos
Randolf_R_
Beginner
769 Views
#include <atomic>
#include <stddef.h>

std::atomic<size_t> var;

size_t load_acquire() {
  return var.load(std::memory_order_acquire);
}

It was not easy to reproduce, because the compiler does not insert mfence instructions normally. But in combination with the -mno-sse flag...

k1om-mpss-linux-g++ -std=c++0x -mno-sse -c atomics-example.cc

One does not actually need the -mno-sse flag with the KNC specific compiler. When we improved our build scripts, the problem disappeared :(

0 Kudos
pbkenned1
Employee
769 Views

Thanks for the example and your command, that explains the issue:

[dpdmic09]$ ./k1om-mpss-linux-g++ --version
k1om-mpss-linux-g++ (GCC) 4.7.0 20110509 (experimental)

[dpdmic09]$ ./k1om-mpss-linux-g++ -c -std=c++0x  -mno-sse atomics-example.cc
/tmp/ccdiVtbE.s: Assembler messages:
/tmp/ccdiVtbE.s:85: Error: `mfence' is not supported on `k1om'
/tmp/ccdiVtbE.s:89: Error: `mfence' is not supported on `k1om'
[dpdmic09]$

 

We document that -msse, -msse2, etc. are not supported for targeting MIC architecture, but nothing is said regarding the -mno-code variants.  But it seems reasonable to assume that if -mcode is not supported, that -mno-code would not be supported either.  However, the compiler only complains about -mno-sse; other -mno-code variants don't provoke errors:

[dpdmic09]$ ./k1om-mpss-linux-g++ -c -std=c++0x -mno-sse2 atomics-example.cc
[dpdmic09]$ ./k1om-mpss-linux-g++ -c -std=c++0x -mno-sse3 atomics-example.cc
[dpdmic09]$ ./k1om-mpss-linux-g++ -c -std=c++0x -mno-avx atomics-example.cc

>>>One does not actually need the -mno-sse flag with the KNC specific compiler

Why did you think that flag was needed for some non-KNC specific compiler?  I don't recall seeing that documented anywhere.  If there is some MIC documentation out there stating this, I think we need to clarify the situation. 

Indeed, it seems this could be very hard to track down.  The error message is not all that intuitive (at least to me), and if the flag is buried in a build script, all the harder to find.

Patrick

0 Kudos
Randolf_R_
Beginner
769 Views

Patrick Kennedy (Intel) wrote:

Why did you think that flag was needed for some non-KNC specific compiler?  I don't recall seeing that documented anywhere.  If there is some MIC documentation out there stating this, I think we need to clarify the situation. 

We work on operating system kernel-mode code. On other platforms, the mno-* flags seemed to be a good practice to prevent fancy compiler optimizations that modify the vector registers at unexpected places. The k1om-mpss compiler is "intelligent" enough on its own to abstain from such optimizations.

0 Kudos
pbkenned1
Employee
769 Views

Thanks for that clarification.  I was assuming that 'non-KNC specific compiler' was referring to *something* targeting MIC, perhaps an earlier implementation of the architecture, like KNF.  It didn't occur to me that you could be referring to a generic x86_64 target, such as Xeon. 

It seems like a k1om compiler bug that -mno-sse produces a comp fail, but the other -mno-code flags are quietly accepted.  Probably this will be a non-issue in a newer version of the k1om g++.  See this article.

Patrick

0 Kudos
Reply