Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'attempting to reference a deleted function' with MSVC #8258

Merged
merged 3 commits into from
Oct 28, 2019
Merged

Fix 'attempting to reference a deleted function' with MSVC #8258

merged 3 commits into from
Oct 28, 2019

Conversation

cloudhan
Copy link
Contributor

@cloudhan cloudhan commented Oct 8, 2019

Fixed #8192, Close #8193

This PR will suppress #8193.

noexcept(true) is not required for std::unordered_map, causing compilation error with MSVC for noexcept moveable BackwardBuilder. For more detail, please refers to microsoft/STL#165

So a simple fix is just replace std::unordered_map with noexcept guaranteed hash map

Note, according to https://www.ece.uvic.ca/~frodo/cppdraft/n4659/html/dcl.fct.def#delete-2

A program that refers to a deleted function implicitly or explicitly, other than to declare it, is ill-formed. [ Note: This includes calling the function implicitly or explicitly and forming a pointer or pointer-to-member to the function. It applies even for references in expressions that are not potentially-evaluated. If a function is overloaded, it is referenced only if the function is selected by overload resolution. The implicit odr-use ([basic.def.odr]) of a virtual function does not, by itself, constitute a reference. — end note ]

Deleted move assignment operator is still used, causing the program ill-formed, but seems both GCC and MSVC accept it.

…ation error with MSVC for noexcept moveable BackwardBuilder
@cloudhan
Copy link
Contributor Author

cloudhan commented Oct 9, 2019

@niboshi remove noexcept might also do the trick, might need additional minor changes on the call site of move. Is it OK to swap std::unordered_map for absl::flat_hash_map for noexcept-ness?

@emcastillo
Copy link
Member

Just for reference "Iteration on absl's tables is O(capacity), not O(size)."

Can we measure how this change could impact performance?

@niboshi
Copy link
Member

niboshi commented Oct 9, 2019

Another way around could be to try { } catch (...) { } ?

@cloudhan
Copy link
Contributor Author

cloudhan commented Oct 9, 2019

Another way around could be to try { } catch (...) { } ?

Only if you want to implement move ctor manually.

@cloudhan
Copy link
Contributor Author

cloudhan commented Oct 9, 2019

FYI, there are interesting sets of benchmarks about hashmap https://martin.ankerl.com/2019/04/01/hashmap-benchmarks-01-overview/

@emcastillo
Copy link
Member

I will try to measure the effect on chainerX, from the links you posted, it actually seems that we could get more performance!!

@cloudhan
Copy link
Contributor Author

cloudhan commented Oct 10, 2019

Actually only

absl::flat_hash_map<BackpropId, std::shared_ptr<internal::OpNode>> op_node_map_;
is needed, if you don't mind using std and abseil's hash map simultaneously.

@cloudhan
Copy link
Contributor Author

@emcastillo @niboshi Any progress or suggestion?

@emcastillo
Copy link
Member

Sorry, I will look at it ASAP

@emcastillo
Copy link
Member

I just tested it with imagenet and resnet-50, performance remains exactly the same 👍

emcastillo
emcastillo previously approved these changes Oct 24, 2019
Copy link
Member

@emcastillo emcastillo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets fix Travis errors

@emcastillo emcastillo dismissed their stale review October 24, 2019 08:36

travis issues

@emcastillo emcastillo added this to the v7.0.0 milestone Oct 25, 2019
@emcastillo
Copy link
Member

Jenkins, test this please

@chainer-ci
Copy link
Member

Jenkins CI test (for commit 4c78844, target branch master) succeeded!

@emcastillo
Copy link
Member

Jenkins, test this please

@emcastillo emcastillo added cat:bug Bug report or fix. st:test-and-merge State indicating that pull request is approved by a reviewer and can be merged after CI passes. labels Oct 28, 2019
@chainer-ci
Copy link
Member

Jenkins CI test (for commit 471e82c, target branch master) succeeded!

@mergify mergify bot merged commit 008e2db into chainer:master Oct 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cat:bug Bug report or fix. st:test-and-merge State indicating that pull request is approved by a reviewer and can be merged after CI passes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MSVC Error, attempting to reference a deleted function
4 participants