carries-dependency

When should you not use [[carries_dependency]]?

好久不见. 提交于 2020-01-13 05:34:07
问题 I've found questions (like this one) asking what [[carries_dependency]] does, and that's not what I'm asking here. I want to know when you shouldn't use it, because the answers I've read all make it sound like you can plaster this code everywhere and magically you'd get equal or faster code. One comment said the code can be equal or slower, but the poster didn't elaborate. I imagine appropriate places to use this is on any function return or parameter that is a pointer or reference and that

What does the [[carries_dependency]] attribute mean?

。_饼干妹妹 提交于 2019-11-29 20:22:56
Can someone explain it in a language that mere mortals understand? Anthony Williams [[carries_dependency]] is used to allow dependencies to be carried across function calls. This potentially allows the compiler to generate better code when used with std::memory_order_consume for transferring values between threads on platforms with weakly-ordered architectures such as IBM's POWER architecture. In particular, if a value read with memory_order_consume is passed in to a function, then without [[carries_dependency]] , then the compiler may have to issue a memory fence instruction to guarantee that

What does the [[carries_dependency]] attribute mean?

可紊 提交于 2019-11-28 16:23:07
问题 Can someone explain it in a language that mere mortals understand? 回答1: [[carries_dependency]] is used to allow dependencies to be carried across function calls. This potentially allows the compiler to generate better code when used with std::memory_order_consume for transferring values between threads on platforms with weakly-ordered architectures such as IBM's POWER architecture. In particular, if a value read with memory_order_consume is passed in to a function, then without [[carries