Page MenuHome

Skip building kernel_sse2 on x86_64
ClosedPublic

Authored by Thomas Dinges (dingto) on Jan 11 2014, 3:15 PM.

Details

Summary

This adds target architecture checking based on https://github.com/petroules/solar-cmake/blob/master/TargetArch.cmake.

The target architecture detection is pretty good in quality but non resistant to deliberate tempering.
WITH_CYCLES_OPTIMIZED_KERNEL still makes kernel sse2 and sse3 build.
except on x86_64 then only kernel_sse3 is build as the architecture always has sse2.

I am currently adding the same detection + behaviour to to scons.

Diff Detail

Event Timeline

Martijn Berger (juicyfruit) updated this revision to Unknown Object (????).Jan 12 2014, 7:37 PM

Removed detection and focus on just splitting WITH_CYCLES_OPTIMIZED_KERNEL into sse2 and sse3 part.
Also note that WITH_RAYOPTIMIZATION AND SUPPORT_SSE_BUILD still makes both sse2 and sse3 kernel build.

Also got some scons support for the split in.

Martijn Berger (juicyfruit) updated this revision to Unknown Object (????).Jan 12 2014, 7:51 PM

added scons config.
removed some unneeded print from cmake.

Brecht Van Lommel (brecht) requested changes to this revision.Jan 13 2014, 10:17 AM

I'm confused about this, I thought what we had discussed was different. I rather do not see this controlled by the build system or have any build system variables to configure this at all. Instead there should be e.g. a file util_optimization.h, that does something like:

#if x86_64
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41
#endif

#if x86
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#endif

And that then gets included in device_cpu and the kernel_sse*.cpp files to check which kernels to use or compiler.

@Brecht Van Lommel (brecht): Good idea, this makes it a lot easier. :)

Ill try and listen better next time.

ill add util_optimization.h in util/util_optimization.h then.
Should I keep the WITH_BF_RAYOPTIMIZATION / WITH_RAYOPTIMIZATION buildflag ?
Or just remove that and keep all logic in util_optimization.h ?

I don't think we need the "WITH_BF_RAYOPTIMIZATION" flag, this was mainly introduced for BI, so we can build BI/BVH with SSE.

If @Brecht Van Lommel (brecht) is fine with it, we can remove it for Cycles.

WITH_RAYOPTIMIZATION can be removed from cycles.

Thomas Dinges (dingto) updated this revision to Unknown Object (????).Jan 14 2014, 8:20 PM

Ok, I tried to implement your approach Brecht.

  • added util_optimization.h, which defines the flags.
  • kernel_sse*.cpp and kernel.h have this included

MSVC still links in the SSE2 kernel though for me, so either I missed something or we need a build system hook (I tried scons).

Also removed the Rayoptimization flag from cmake/scons.

ToDo: If this approach works, remove cmake/scons SSE41 compile flag, this is redundant now.

Brecht Van Lommel (brecht) requested changes to this revision.Jan 14 2014, 8:26 PM

Looks good besides the defines.

intern/cycles/kernel/kernel.cpp
88

This should be:

#if defined(__x86_64__) || defined(_M_X64)
intern/cycles/util/util_optimization.h
18–33

_M_X64 is the x86_64 define for MSVC. So I'd organize this as:

#if defined(__x86_64__) || defined(_M_X64)

/* no SSE2 kernel on x86-64, part of regular kernel */
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41

#endif

#if defined(i386) || defined(_M_IX86)

#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE2
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE3
#define WITH_CYCLES_OPTIMIZED_KERNEL_SSE41

#endif

Thanks Brecht, the defines were indeed wrong. It works now as expected. :)