Cyles: TextureInterpolator Undefined linker behavior - performance regression. #55054
Labels
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
5 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#55054
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Allright, while implementing clang support in D3304 I ran into an issue where
I'd hit an andn BMI instruction (haswell and up, my ivy lake didn't take that too well)
And it took me a few days to figure out, and it's gonna take quite a bit of explaining
to get to the cause of the bug.
lets fist take some detours to get some basic concepts ironed out.
Detour number 1: Undefined behavior - Libraries and duplicate functions
Seems simple enough. Question time, what does this do?
a) Error out at link time, duplicate functions aren't allowed!
b) print "Hello From A"
c) print "Hello From B"
d) print "Hello From A" on windows, "Hello From B" on linux
turns out the answer is d. If there's multiple definitions in a library the linker is apparently
allowed to pick 'whatever it feels like' and not tell anyone about it, on linux it seems to
depend on the link order, microsoft's linker ... errr..yeah....I have honestly no idea what the logic is.
Detour number 2, behavior of the static keyword in C++
when using the static keyword on a c++ class it does NOT limit the visiblity to just
this compile unit like it does in C, it merely marks if you can call this function
without an instance (there's more to it, but given our usage of it, this will suffice)
Bringing it all together:
in kernel_cpu_image.h there's this little snippet
the never_inline is there, cause the massive amount of inlining added 20 minutes to a cycles release build
with msvc. we put this there before it was a templated class so that worked, however when this got refactored
into a template, wonkyness ensured.
At this point, every kernel compile unit will have a interp_3d_tricubic function, the linker is free
to pick any of them, and when build with msvc will consistently pick the unoptimized one from the 'cpu'
kernel, however when build with clang, it went with the AVX2 implementation causing a segfault with an
invalid instruction.
Current Situation:
Solution:
I have nothing pretty really, but here's some options.
could work, but it requires hackery in osl_services.cpp since it doesn't know about the KERNEL_FUNCTION_FULL_NAME macro
We could remove the ccl_never_inline but it'll balloon the build time, also i'm not convinced the linker will do
the the right thing in a debbug build with inlining disabled.
anyone else have a bright idea here?
Added subscriber: @LazyDodo
Added subscriber: @Sergey
Proper way to deal with this would be to move every CPU kernel into a namespace. That would ensure linker never re-uses "wrong" microarchitecture implementation.
Added subscriber: @mano-wii
looked some more into this, looks like chrome ran into a similar issue coming from math.h, all i can say is 'yikes'
https://bugs.chromium.org/p/chromium/issues/detail?id=666707
https://randomascii.wordpress.com/2016/12/05/vc-archavx-option-unsafe-at-any-speed/
This issue was referenced by blender/cycles@9933b10a15
This issue was referenced by
ea8e0df672
Changed status from 'Open' to: 'Resolved'