I have some simple test code which I am trying to generate AVX optimized code for using the icc v12.1 on linux Redhat 5.6. The code looks like this:
int main() {
double sum = 0.0;
for (unsigned int i = 0; i < 1024; i++) {
sum += static_cast<double>(i);
}
std::cout << "Sum: "<< sum << std::endl;
return 0;
}
And I compile it with (and the vector report says that the loop was vectorized):
icc -xavx -vec-report1 main.cpp
When I run the code I get the following error:
Fatal Error: This program was not built to run in your system.
Please verify that both the operating system and the processor support Intel(R) AVX.
I am certain that the processor is AVX-capable, but does anyone else have problem with AVX on Redhat 5.6?
The Red Hat Enterprise Linux 5.x series uses a base Linux kernel version of 2.6.18. On top of that, Red Hat backports selected patches and new functionality from later kernel versions as it sees fit over the course of a release family's lifetime. So, while the kernel is based on 2.6.18, you might see some additional features that only appeared in later mainline kernel versions.
With that said, the Linux kernel didn't support AVX until version 2.6.30 (reference), so it appears that this was not one of the features that Red Hat backported to the 5.x series. According to this post on the Portland Group (a compiler maker) forums, full support didn't appear until version 6.2 (CentOS is essentially equivalent to RHEL).