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
reorder forward declarations to get rid of C++14-only auto return types #2720
Conversation
@gentryx This is roughly what we've had before. Unfortunately this fails compiling on some platforms (sorry, don't remember which) because of incomplete types. Could you please change the PR such that both versions of the code are there, using a pp constant to switch between the two ( |
@hkaiser Are you referring by "this" to the use of decltype instead of auto for the return types in the customization points? Yeah, I can change that to be configurable, no problem. :-) |
@gentryx: I meant the whole forward declaration. Also, the use of |
@hkaiser I think I don't quite understand. What I did was basically two things:
|
Oh, and I forgot:
|
Thanks! |
@hkaiser: I've added preprocessor guards so that the customization points will again use forward declarations and "auto" if C++14 is available, but will fall back to a C++11-compatible style if necessary. I've successfully tested this build with GCC 4.9.4 with and without CUDA 8.0 for the C++11-mode and with GCC 6.3.0 for a C++14 build. Please let me know if you want me to try further compiler versions. :-) |
cmake/tests/cxx14_auto.cpp
Outdated
{ | ||
T j = 1 + j; | ||
return j; | ||
} |
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 is not C++11. For this, the body of the function has to consist of only the return statement.
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.
Correct, this tests for C++14 auto capability. There already is another file (cxx11_auto.cpp) that's testing the C++11 auto compiler feature.
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.
Let me rephrase this. If the feature test is for a C++14 feature (which is fine), why do you use the result of this feature test to add a workaround for a missing C++11 capability of a particular compiler? Shouldn't we rather feature test for the particular missing capabilities und use this instead to decide whether to activate the workaround?
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.
Ah, got it. You're right, this is apparently a bug in NVCC. However, CMake isn't using NVCC to test for compiler flags (but rather the default C++ compiler), so a test here for that specific defect likely wouldn't yield us much.
If you object to this test as it is in the PR then I think it would be fine to just tell CUDA users to manually set "-DWITH_CXX11_AUTO=false". In that case I'd remove the new C++14 auto test. Your thoughts?
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.
I'm not opposed to this feature test. I'm opposed to using the results of this test to detect a NVCC problem related to a C++11 feature. Couldn't we just force HPX_WITH_CXX11_AUTO=OFF whenever HPX is configured with CUDA/NVCC enabled?
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.
At CMake time we don't know if the user is going to use nvcc for their code.
I can drop the additional (misleading) CXX14 CMake test and then users can manually disable CXX11 auto support. Would that be better?
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.
Looks like clang on CircleCI is complaining. This is good because it allows me to debug the issue. I'm on it.
cmake/tests/cxx14_auto.cpp
Outdated
{ | ||
T j = 1 + j; | ||
return j; | ||
} |
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.
Correct, this tests for C++14 auto capability. There already is another file (cxx11_auto.cpp) that's testing the C++11 auto compiler feature.
@gentryx: should those changes be applied to the execution information and timed execution customization points as well: https://github.com/STEllAR-GROUP/hpx/blob/master/hpx/parallel/executors/execution_information_fwd.hpp and https://github.com/STEllAR-GROUP/hpx/blob/master/hpx/parallel/executors/timed_execution_fwd.hpp? |
@gentryx: to clarify: you have applied different methods of resolving the issue at hand for the base execution customization points compared to how you resolved it for the timed execution and informational customization points. Why? Also, the original code was using the You have also removed the headers |
… contains forward declarations
@hkaiser I added explicit return types (via decltype(...)) for customization_point because of NVCC's shortcomings WRT auto return types. This seems to be the only solution that works with NVCC (so apparently NVCC is not standard compliant). However, this is conditional on the CMake check for C++14 auto support, and if such support is found the code after the preprocessor is identical to the original code. As mentioned above I can change the conditional from "C++14 auto" to "C++11 auto". If this approach is fine for you then I can follow the same pattern for timed_execution_fwd.hpp and execution_information_fwd.hpp. I had these headers removed as my builds (g++ 4.9.4 with CUDA 8.0 g++ 6.2.0 and clang 4.0) work just fine with moving those functions into the corresponding headers, but I hold no stake in this, I'm fine with doing the same as I did for execution.hpp/execution_fwd.hpp. |
OK, looks like CircleCI is fine with the PR (the error it's throwing seems related to the Perl install?). :-) Please advise on how to procedd WRT timed_execution_fwd.hpp/execution_information_fwd.hpp. Same pattern as for execution_fwd.hpp? |
No idea what's wrong there... I have never seen this before.
Yes, please. |
@gentryx: are you still working on this? |
…, as well as applying preprocessor guards to work with and without proper support for auto return types
K, I've refactored the patch for readability as you suggested. The new CXX11 auto option is now off by default if HPX_WITH_CUDA is selected. |
Thanks, perfect!
Uhh, shouldn't it be |
@gentryx: uhh, I moved this over to the branch https://github.com/STEllAR-GROUP/hpx/tree/gentryx-master in the main repo and fixed some things. I'll try to reintegrate your work with that branch tomorrow. Thanks! |
@hkaiser Okidoki. I've just pushed some changes to please inspect. And yes: the option should be on by default and off if CUDA is being used as NVCC doesn't support it. |
@hkaiser Regarding your branch gentryx-master: the default value for the option needs to be inversed: on by default, off if CUDA (with gcc) is selected. |
@gentry: ok, I'll verify again. |
- fixing too long lines - unified handling of the issue at hand
@gentryx I changed the default for the option (thanks for pointing this out) and reintegrated all of your recent changes into https://github.com/STEllAR-GROUP/hpx/tree/gentryx-master (please check, I hope I have not missed anything). Once circleci passes I'm going to merge things from there. |
@hkaiser Looks good so far. I've merged the gentryx-master branch in this PR and added another commit to mask some tests that won't compile in CXX11-mode (as they expect auto-typed lambda parameters). |
@gentryx: thanks so much! |
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.
LGTM, thanks!
I have no clue what the error message means that CircleCI is showing. Does this block the merge? |
@gentryx: I think this is happening because the build - for some reason - runs under your account, not under the STEllAR-GROUP account. I think we're fine merging anyways. |
Woohoo! :-) |
This fixes C++11-only builds (basically anything that's using CUDA). Closes #2718