Cycles: enable /arch:AVX in msvc 11 and later versions for avx kernel
authorSv. Lockal <lockalsash@gmail.com>
Mon, 3 Feb 2014 13:22:50 +0000 (17:22 +0400)
committerSv. Lockal <lockalsash@gmail.com>
Mon, 3 Feb 2014 13:22:50 +0000 (17:22 +0400)
This enables VEX-encoding in AVX kernel for windows msvc builds and gives 5-10% speedup for different scenes.

Reviewers: juicyfruit, dingto, brecht

Reviewed By: brecht

CC: brecht
Differential Revision: https://developer.blender.org/D284

intern/cycles/CMakeLists.txt

index f8c4ca6857260e071ed1925594914e15e10a1902..5c8d68b07eef56751e2b0ce08137b3e354771567 100644 (file)
@@ -15,17 +15,24 @@ include(cmake/external_libs.cmake)
 # todo: refactor this code to match scons
 
 if(WIN32 AND MSVC)
+       # /arch:AVX for VC2012 and above
+       if(NOT MSVC_VERSION LESS 1700)
+               set(CYCLES_AVX_ARCH_FLAGS "/arch:AVX")
+       elseif(NOT CMAKE_CL_64)
+               set(CYCLES_AVX_ARCH_FLAGS "/arch:SSE2")
+       endif()
+
        # there is no /arch:SSE3, but intrinsics are available anyway
        if(CMAKE_CL_64)
                set(CYCLES_SSE2_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
                set(CYCLES_SSE3_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
                set(CYCLES_SSE41_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
-               set(CYCLES_AVX_KERNEL_FLAGS "/fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") #/arch:AVX for VC2012 and above
+               set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
        else()
                set(CYCLES_SSE2_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
                set(CYCLES_SSE3_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
                set(CYCLES_SSE41_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")
-               set(CYCLES_AVX_KERNEL_FLAGS "/arch:SSE2 /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") #/arch:AVX for VC2012 and above
+               set(CYCLES_AVX_KERNEL_FLAGS "${CYCLES_AVX_ARCH_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-") 
        endif()
 
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast -D_CRT_SECURE_NO_WARNINGS /Gs-")