-
Notifications
You must be signed in to change notification settings - Fork 407
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
(Trilinos) build warning in atomic_assign, with Kokkos::complex #177
Comments
Harmless but annoying warning I have seen before. I will put harmless & annoying no-op in in the function to suppress the warning. From: Mark Hoemmen <notifications@github.commailto:notifications@github.com> When building Trilinos, GCC 4.7.2 reports a build warning in Kokkos::atomic_assign, line 301 of kokkos/core/src/impl/Kokkos_Atomic_Exchange.hpp: http://testing.sandia.gov/cdash/viewBuildError.php?type=1&buildid=2318891 warning: implicit dereference will not access object of type 'volatile Kokkos::complex' in statement [enabled by default] I'm not sure if this is harmless, or a problem with Kokkos::complex, but I just wanted to report it. Reply to this email directly or view it on GitHubhttps://github.com//issues/177. |
Yeah its kind of hard to suppress it. Its effectively an unused return value from fetch and add. |
I saw it was in an atomic_* function and left it alone like a sane person should ;-) If the no-op doesn't work, we can try the GCC pragmas (push / pop suppression of a particular warning). They don't work for all the warnings, though. Anyway, thanks for taking a look! |
@bartlettroscoe says:
|
@hcedwar I'm getting pushback from Trilinos leaders about this one; would you consider reopening it? |
Did the no-op not work? |
Just to be clear, this is currently not supported by TriBITS. I was just saying that we could consider that as part of: That would require a change in the way that TriBITS manages include dirs from upstream package (see this todo). |
@crtrott Unfortunately not. Compilers seem to have learned not to accept the "cast-to-void" idiom. I haven't had any customers complain about it. The only reason this came up is because Mike Heroux mentioned that test builds with warnings as errors weren't passing, and wondered what was going on. It would be nice to get those builds through Tpetra, but again, no customers are complaining. (They must not enable the warning in question.) @bartlettroscoe Thanks for the clarification! This could also be useful to applications that use Kokkos through its Makefile build system. |
It could be suppressed if the https://github.com/kokkos/kokkos/blob/master/core/src/Kokkos_Complex.hpp#L127 The difference is that an assignment statement could not be used as a value, for example https://github.com/ibaned/omega_h2/blob/master/src/int128.hpp#L22 |
I have argued a similar point in the ISO/C++ committee over atomic overloads for '=' and '+='. |
The semantic concern is race condition in the update-then-read. Should the read value be the updated value of that operation or should should it reflect a potentially intervening update for the most-up-to-the-instant value? When returning void there is no concern since update and read are always explicitly separate operations. |
@hcedwar Users would normally only exercise the volatile overload of Kokkos::complex in the join() of a parallel_{reduce, scan}. If they try to do |
Yeah I think that is ok. Also std::complex doesn't have the volatile overloads at all, so making them behave differently shouldn't hurt. |
Hm, line 296 of the implementation of Kokkos::atomic_fetch_add (for >64-bit types) does the following:
This means operator= must return something other than void. Can I change this line? Would that have horrible consequences for weird memory models like POWER's? |
@mhoemmen POWER8 is the same as X86 here, the operations are not executed concurrently, they are in C/C++ program order. If you were to break these into two statements it would be the "same" code. |
@nmhamster Can I get rid of If it needs to be there, somebody please explain to me why, and I'll put the comment explaining it right above the line of code myself. |
@mhoemmen if the result is thrown away the compiler will just not generate the code anyway (unless T is |
.../Trilinos/packages/kokkos/core/src/impl/Kokkos_Atomic_Exchange.hpp:310:3: warning: conversion to void will not access object of type
The GCC pragmas to silence warnings (pragma GCC diagnostic push, ignored "-Wall", pop) don't work. |
Thanks @nmhamster for encouragement and help! I think I've figured this out. This will require a backwards-incompatible change to both Kokkos::complex and Kokkos::pair. In particular, multiple assignments in a single statement (like This also appears to be the right thing to do with respect to GCC's https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Volatiles.html |
For volatile qualified types it is the right thing to do. |
I'll put it in develop then. I can test Trilinos (doing so right now) but will have to wait to test e.g., LAMMPS until the next develop -> master integration. |
Nice ! just one thing: can we remove the instances of:
? I think they were there in multiple assignment form to silence the unused reference warning, which is no longer necessary. They don't seem to do anything at all otherwise |
@ibaned Do those cause warnings for you? I really don't want to remove them, because this is tricky code. (For example, |
No warnings here, just an uneducated guess on my part. (conversely, if I'm right, we could avoid an unnecessary load in performance-critical code). |
Yep - put there to suppress warning. A decent optimizer would eliminate the code, but would be better not to have it in the first place. |
@mhoemmen or @ibaned can you give me co-ordinates for a specific piece of code I can look at. This appears to be rather nasty hack to get ride of the compile warnings but I want to check it won't affect correctness. In general loading a value ( |
Not sure a decent optimizer would get rid of the load if |
@nmhamster here are (I think all) the links:
|
see kokkos/kokkos#177 for detailed discussion of the issue and fix
When building Trilinos, GCC 4.7.2 reports a build warning in Kokkos::atomic_assign, line 301 of kokkos/core/src/impl/Kokkos_Atomic_Exchange.hpp:
http://testing.sandia.gov/cdash/viewBuildError.php?type=1&buildid=2318891
warning: implicit dereference will not access object of type ‘volatile Kokkos::complex’ in statement [enabled by default]
I'm not sure if this is harmless, or a problem with Kokkos::complex, but I just wanted to report it.
The text was updated successfully, but these errors were encountered: