-
Notifications
You must be signed in to change notification settings - Fork 22
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
Make the benchmark compile successfully by GCC #1
Conversation
SIMDString.h
Outdated
@@ -801,7 +801,7 @@ class | |||
return append(c); | |||
} | |||
replace(pos - m_data, 0, 1, c); | |||
return m_data + pos; | |||
return pos; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pos
here is an iterator (aka const char*
), so it cannot be added to another const char*
(m_data
).
IMHO it is a logical error (and also a compile error).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been fixed as of 8495257
They also have a bug in the implementation #3 |
If we talk about memcpy I think their main target is windows libc. Also if we talk about glibc It can be worse for very short memcpy because of it's optimized for big sizes |
The whole point is that we allow for a larger buffer size than std::string. Different string libraries are good for different use cases. As it says in the README.md
If you want an exact apples to apples comparison, use SIMDString<16>.
Since SSE instructions can only be performed on 16-byte aligned memory, we can only perform SSE memcpy on memory that we can guarantee is 16-byte aligned. SSE memcpy on heap storage is possible, but it requires that heap memory also be 16-byte aligned, which we're not requiring.
To repeat what @MBkkt said, this isn't true for all versions of libc. |
@PragmaTwice you are absolutely right. And worse - that handwritten memcpy: (1) is used only for short strings stored in the stack (not for the actually problematic ones, the ones allocated to the heap);
This is indeed a very strange repository, full of bugs and based on a naive and trivial usage of SIMD. |
The benchmark CANNOT be compiled successfully by either GCC (12.2) or Clang (14.0).
This PR makes the benchmark pass gcc and run successfully.
BTW, the SSO inline size of std::string in libstdc++ is 15 now (22 in libc++, maybe),
so the default SSO size of SIMDString in the benchmark is not fair to be compared with std::string.
Also, the only use of SIMD in the whole project is a handwritten memcpy: this is strange,
because memcpy in glibc, for example, is highly optimized (handwritten assembly with SSE2/AVX2 instructions),
so I find it hard to believe that such a very trivial toy memcpy could be more efficient.
IMHO this project is more like an assignment from a random college student than a proven product in a company.