Cycles/Tests/MSVC: cycles_denoise tests are failing #78047

Closed
opened 2020-06-19 22:38:07 +02:00 by Ray molenkamp · 12 comments
Member

System Information
Operating system: Windows
Graphics card: N/A

Blender Version
Broken: Latest master
Worked: Before C++17 switch

Short description of error

The cycles_denoise and cycles_denoise_animation are failing on SSE4.1 and AVX architectures on windows.

could be a codegen bug, have not investigated yet.

Exact steps for others to reproduce the error

Run tests

**System Information** Operating system: Windows Graphics card: N/A **Blender Version** Broken: Latest master Worked: Before C++17 switch **Short description of error** The `cycles_denoise` and `cycles_denoise_animation` are failing on SSE4.1 and AVX architectures on windows. could be a codegen bug, have not investigated yet. **Exact steps for others to reproduce the error** Run tests
Author
Member

Added subscriber: @LazyDodo

Added subscriber: @LazyDodo
Author
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Author
Member

The first one is hiding in fast_exp2f4 managed to extract a repro, but it's not quite "minimal" yet, so unsure on the exact issue. Not convinced there are not other issues as well, we'd really should have landed D5602 for at least the cpu architectures before switching compilers.

The first one is hiding in `fast_exp2f4` managed to extract a repro, but it's not quite "minimal" yet, so unsure on the exact issue. Not convinced there are not other issues as well, we'd really should have landed [D5602](https://archive.blender.org/developer/D5602) for at least the cpu architectures before switching compilers.

Added subscriber: @Sergey

Added subscriber: @Sergey

@LazyDodo, are you looking into this or want me to help with something?

@LazyDodo, are you looking into this or want me to help with something?
Author
Member

Looking into this, but it's a jumpy little bastard, every-time you edit some seemingly unrelated code it may or may not go into hiding, given it only seems to rear it's head inside fast_exp2f4 disabling the optimizer for just that function seems to sidestep the issue (and given its only used in the denoiser and only in a single pass, I don't feel super bad about a possible perf hit).

Given extracting a good repro case will take a bit of time, as will reporting it and getting it fixed (guessing months, the race condition we had in the CRT last august is [still open ]] , although an asan bug recently got [ https:*developercommunity.visualstudio.com/content/problem/1041477/asan-triggers-on-aligned-malloc-size-requirement.html | dealt with swiftly ) i think the way to go right now would be something like

diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h
index dbed83ab84d..c046601f48e 100644
--- a/intern/cycles/util/util_math_fast.h
+++ b/intern/cycles/util/util_math_fast.h
@@ -446,6 +446,10 @@ ccl_device_inline float fast_expf(float x)
 }

 #ifndef __KERNEL_GPU__
+/* MSVC seems to have a codegen bug here in SSE41/AVX */
+#ifdef _MSC_VER
+#  pragma optimize( "", off )
+#endif
 ccl_device float4 fast_exp2f4(float4 x)
 {
   const float4 one = make_float4(1.0f);
@@ -461,6 +465,9 @@ ccl_device float4 fast_exp2f4(float4 x)
   r = madd4(x, r, make_float4(1.0f));
   return __int4_as_float4(__float4_as_int4(r) + (m << 23));
 }
+#ifdef _MSC_VER
+#  pragma optimize( "", on )
+#endif

 ccl_device_inline float4 fast_expf4(float4 x)
 {

A more fine grained approach by singling out the SSE4/AVX kernels is possible,but given how jumpy it is, i'm not sure AVX2 isn't affected, it may just not be affected "right now", and I would lean on the side of caution there and just disable the optimizer for all kernels.

That being said, having these kind of issues (also having codegen issues in last week in GCC's update) is making me somewhat uncomfortable, expanding our testing surface to cover all CPU architectures should be fast-tracked.

Looking into this, but it's a jumpy little bastard, every-time you edit some seemingly unrelated code it may or may not go into hiding, given it only seems to rear it's head inside `fast_exp2f4` disabling the optimizer for just that function seems to sidestep the issue (and given its only used in the denoiser and only in a single pass, I don't feel super bad about a possible perf hit). Given extracting a good repro case will take a bit of time, as will reporting it and getting it fixed (guessing months, the race condition we had in the CRT last august is [still open ]] , although an asan bug recently got [[ https:*developercommunity.visualstudio.com/content/problem/1041477/asan-triggers-on-aligned-malloc-size-requirement.html | dealt with swiftly ](https:*developercommunity.visualstudio.com/content/problem/672664/race-condition-on-g-tss-mutex-with-static-crt.html) ) i think the way to go right now would be something like ``` diff --git a/intern/cycles/util/util_math_fast.h b/intern/cycles/util/util_math_fast.h index dbed83ab84d..c046601f48e 100644 --- a/intern/cycles/util/util_math_fast.h +++ b/intern/cycles/util/util_math_fast.h @@ -446,6 +446,10 @@ ccl_device_inline float fast_expf(float x) } #ifndef __KERNEL_GPU__ +/* MSVC seems to have a codegen bug here in SSE41/AVX */ +#ifdef _MSC_VER +# pragma optimize( "", off ) +#endif ccl_device float4 fast_exp2f4(float4 x) { const float4 one = make_float4(1.0f); @@ -461,6 +465,9 @@ ccl_device float4 fast_exp2f4(float4 x) r = madd4(x, r, make_float4(1.0f)); return __int4_as_float4(__float4_as_int4(r) + (m << 23)); } +#ifdef _MSC_VER +# pragma optimize( "", on ) +#endif ccl_device_inline float4 fast_expf4(float4 x) { ``` A more fine grained approach by singling out the SSE4/AVX kernels is possible,but given how jumpy it is, i'm not sure AVX2 isn't affected, it may just not be affected "right now", and I would lean on the side of caution there and just disable the optimizer for all kernels. That being said, having these kind of issues (also having codegen issues in last week in GCC's update) is making me somewhat uncomfortable, expanding our testing surface to cover all CPU architectures should be fast-tracked.

Added subscriber: @brecht

Added subscriber: @brecht

The workaround is fine with me.

The workaround is fine with me.
Author
Member

Update: Issue reported , i'll land the work around tomorrow.

Update: Issue [reported ](https://developercommunity.visualstudio.com/content/problem/1089234/avx-codegen-issue-when-c17-is-enabled.html) , i'll land the work around tomorrow.

This issue was referenced by blender/cycles@71e53d7410

This issue was referenced by blender/cycles@71e53d7410c23da8d86aaf8ee88a0f4d93b0f029

This issue was referenced by 5cfbc722d0

This issue was referenced by 5cfbc722d095664c3d2496f21d9deb21c47f2e12
Author
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Ray molenkamp self-assigned this 2020-06-24 18:42:13 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#78047
No description provided.