Reputation: 1261
I try to measure time in a CUDA program.
For that purpose I want to use:
#include <chrono>
I receive an error though:
error: #error This file requires compiler and library support for the upcoming ISO C++ standard, C++0x. This support is currently experimental, and must be enabled with the -std=c++0x or -std=gnu++0x compiler options.
I have tried to inlcude the options -std=c++11
, -std=c++14
, -std=c++17
.
None of them worked. Any suggestions?
Upvotes: 0
Views: 870
Reputation: 132148
I'd like to add to @talonmies's correct answer, and caution you to consider carefully whether or not you actually want to write your own code to do the timing. CUDA offers a profiler for timing kernels and CUDA Runtime API calls; and you can also use its C(ish) API to mark segments and points on the program's timeline.
nVIDIA's Mark Harris wrote a blog post/tutorial about using the profile, you might want to check it out.
Upvotes: 0
Reputation: 72342
That message isn't coming from the CUDA toolchain, it is coming from gcc (and a rather old version of gcc, probably 4.3). And the message tells you exactly what to do -- you need to pass -std=c++0x
as an option to gcc. Any host compiler options are passed from nvcc via the -Xcompiler
option so
$ nvcc -Xcompiler="--std=c++0x" .....
should solve the problem of the compiler refusing to import <chrono>
.
Upvotes: 2