Giter Site home page Giter Site logo

Performance in DEBUG mode about eve HOT 6 CLOSED

dpronin avatar dpronin commented on June 14, 2024
Performance in DEBUG mode

from eve.

Comments (6)

dpronin avatar dpronin commented on June 14, 2024 1

@DenisYaroshevskiy thank you, indeed so, again from https://en.cppreference.com/w/cpp/algorithm/copy:

In practice, implementations of std::copy avoid multiple assignments and use bulk copy functions such as std::memmove if the value type is TriviallyCopyable and the iterator types satisfy LegacyContiguousIterator.

But actually I see a contradiction in the standard because they preserve a well-defined behaviour for trivially copyable POD types as a special case but warn about everything else to be copied with undefined result. They'd better call memcpy from my point of view to conform their rules and also possibly increase performance. Of course, if they did that they would definitely need to introduce a new algo for copying overlapping objects and memory

Nevertheless, it is quite beside the point of our initial talk

from eve.

DenisYaroshevskiy avatar DenisYaroshevskiy commented on June 14, 2024

Why eve doesn't call memmove

We could but then: a) we loose all the tuning abilities. b) memmove is great, just use memmove.
Generally speaking I wouldn't use eve::algo::copy for just bytes copying.

PSS: Also, be aware, that everything is compiled in -march=native mode that enables everything up to avx512 including

If you use avx512 - I'd recommend to think about frequency scaling https://jfalcou.github.io/eve/freqscale.html - you might get more perf.

from eve.

dpronin avatar dpronin commented on June 14, 2024

@DenisYaroshevskiy I didn't talk about memmove, though :) Is there misundestanding?)

from eve.

DenisYaroshevskiy avatar DenisYaroshevskiy commented on June 14, 2024

std::copy is calling memmove under the hood, sorry for misunderstaning.

from eve.

dpronin avatar dpronin commented on June 14, 2024

@DenisYaroshevskiy are you sure? I do not think so, it must not. The ranges must not overlap, but memmove works with possibly overlapping memory. I think std::copy assumes that a source does not intersect a destination.

From https://en.cppreference.com/w/cpp/algorithm/copy

Copies all elements in the range [first, last) starting from first and proceeding to last.
If d_first is in [first, last), the behavior is undefined. In this case, std::copy_backward may be used instead.

Correct me if I am wrong

from eve.

DenisYaroshevskiy avatar DenisYaroshevskiy commented on June 14, 2024

I believe you are, they can overlap one way. And copy_backward are allowed to overlap the other way

In any case: https://github.com/llvm/llvm-project/blob/b0c6fc81fe132f20eed38bd836620dfcb5ac17e9/libcxx/include/__algorithm/copy_move_common.h#L66

And: https://github.com/llvm/llvm-project/blob/b0c6fc81fe132f20eed38bd836620dfcb5ac17e9/libcxx/include/__string/constexpr_c_functions.h#L212

from eve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.