-
Notifications
You must be signed in to change notification settings - Fork 345
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
Fake warning on Fedora 34 (in fact newer gcc version 11.2.1 20210728) #189
Comments
By the way I made two candidate fixes
The compiler does not like out accessed as a vector (how big? Maybe only 0 bytes-long... WARNINGGGGGGGG!!!)
A bigger buffer, just to make sure the compiler is happy with MAX_SIMD_DEGREE 1
|
Related to: #183 Thanks for digging into this. I'm realizing now that the warnings aren't related to the compiler version, but instead to the value of diff --git a/c/blake3_impl.h b/c/blake3_impl.h
index 86ab6aa..0bf8c5e 100644
--- a/c/blake3_impl.h
+++ b/c/blake3_impl.h
@@ -45,13 +45,7 @@ enum blake3_flags {
#include <immintrin.h>
#endif
-#if defined(IS_X86)
-#define MAX_SIMD_DEGREE 16
-#elif defined(BLAKE3_USE_NEON)
-#define MAX_SIMD_DEGREE 4
-#else
#define MAX_SIMD_DEGREE 1
-#endif
// There are some places where we want a static size that's equal to the
// MAX_SIMD_DEGREE, but also at least 2.
A value of |
EDIT: Woops, this whole comment is a silly mistake, see below. Also notably, if I compile with the diff above and
But an input of size 2048 fails:
So GCC might be onto something here. If I change |
Ah woops, silly mistake on my part. The above is a crasher because the diff is bad. The diff --git a/c/blake3_dispatch.c b/c/blake3_dispatch.c
index 6518478..278a299 100644
--- a/c/blake3_dispatch.c
+++ b/c/blake3_dispatch.c
@@ -245,6 +245,7 @@ void blake3_hash_many(const uint8_t *const *inputs, size_t num_inputs,
// The dynamically detected SIMD degree of the current platform.
size_t blake3_simd_degree(void) {
+ return 1;
#if defined(IS_X86)
const enum cpu_feature features = get_cpu_features();
MAYBE_UNUSED(features);
diff --git a/c/blake3_impl.h b/c/blake3_impl.h
index 86ab6aa..0bf8c5e 100644
--- a/c/blake3_impl.h
+++ b/c/blake3_impl.h
@@ -45,13 +45,7 @@ enum blake3_flags {
#include <immintrin.h>
#endif
-#if defined(IS_X86)
-#define MAX_SIMD_DEGREE 16
-#elif defined(BLAKE3_USE_NEON)
-#define MAX_SIMD_DEGREE 4
-#else
#define MAX_SIMD_DEGREE 1
-#endif
// There are some places where we want a static size that's equal to the
// MAX_SIMD_DEGREE, but also at least 2. |
See also #94 |
Ugh yeah, I think I understood more of this at one point and just forgot it in the meantime. |
@fcorbelli could you test out #191 in your environment and confirm that it silences these warnings? |
In fact
the warning is triggered. And
write 64-bytes (2*32) into a 32 bytes long size. Therefore, for me, a bigger out_array is needed (the last memcpy warning) and better a variable-sized one (num_cvs is not fixed). => some reworking is needed, not just an assert()
=> something like this (entering num_cvs in the array size)
(just a snippet, because warning: ISO C++ forbids variable length array 'out_array'). => and num_cvs is changed inside the loop, so what is the MAX num_cvs (to pre-allocate the array)? |
The second (first) warning is, for me, a spurious one, just because the compiler cannot "know" how big is the memory @ uint8_t out, accessed by [], switching from "[" to "+(" (yes, very quick and very dirty, but much bigger changes are needed if you define a 32-bytes-long pointer structure etc etc instead of the uint8_t) Therefore some pointer-math is my suggestion (some side-effects? I do not think so) |
Just to be clear something like this will not work
|
Does not work on 8.5, unless you delete the /2 in the array definition (or at least so it seems to me) |
I believe this is fixed by b8e2dda, but please reopen if I've missed something. |
I found "classical" fake warning on newer gcc
may I suggest some code refactoring (just to do not get those spurious warnings)?
It happens quite frequently that I have to change perfectly functional code so as not to have to "fight" with compilers often full of bugs in detecting "memory" errors.
It's not that important, just a hint
PS Newer Linux-based g++ runs BLAKE3 two time faster then "not so old" g++, on AMD.
Yes, two time faster, not 2%!
The text was updated successfully, but these errors were encountered: