Test that compiling and linking of AVX works
authorRoland Schulz <roland@utk.edu>
Sun, 11 Nov 2012 22:52:17 +0000 (17:52 -0500)
committerRoland Schulz <roland@utk.edu>
Mon, 12 Nov 2012 23:34:04 +0000 (18:34 -0500)
Older assemblers don't have support for AVX

Related to #1021

Change-Id: If8da47f9458c592d5408c7322280ffacce81145d

CMakeLists.txt
cmake/TestAVX.c [new file with mode: 0644]

index 3262247f85a43222e0daf343eff51f45a241b3b7..04ed33cd29b7672782144fc8be88f9fdd82223c5 100644 (file)
@@ -810,6 +810,15 @@ elseif(${GMX_ACCELERATION} STREQUAL "AVX_128_FMA" OR ${GMX_ACCELERATION} STREQUA
         message(FATAL_ERROR "Cannot find immintrin.h, which is required for AVX intrinsics support. Consider switching compiler.")
     endif(NOT HAVE_IMMINTRIN_H)
 
+    if(${GMX_ACCELERATION} STREQUAL "AVX_256")
+        try_compile(TEST_AVX ${CMAKE_BINARY_DIR}
+            "${CMAKE_SOURCE_DIR}/cmake/TestAVX.c"
+            COMPILE_DEFINITIONS "${GROMACS_C_FLAGS}")
+        if(NOT TEST_AVX)
+            message(FATAL_ERROR "Cannot compile AVX intrinsics. Consider switching compiler.")
+        endif()
+    endif()
+
     # GCC requires x86intrin.h for FMA support. MSVC 2010 requires intrin.h for FMA support.
     check_include_file(x86intrin.h HAVE_X86INTRIN_H ${GROMACS_C_FLAGS})
     check_include_file(intrin.h HAVE_INTRIN_H ${GROMACS_C_FLAGS})
diff --git a/cmake/TestAVX.c b/cmake/TestAVX.c
new file mode 100644 (file)
index 0000000..0878dcf
--- /dev/null
@@ -0,0 +1,8 @@
+#include <immintrin.h>
+
+int main()
+{
+    __m256 x  = _mm256_set_ps(0.5,0.5,0.5,0.5,0.5,0.5,0.5,0.5);
+    x = _mm256_rsqrt_ps(x);
+    return 0;
+}