Skip to content

Commit

Permalink
Fixes #503, fixes #507:
Browse files Browse the repository at this point in the history
* No longer using anything from the `helper_string.h` header we had lifted from the CUDA samples' common includes directory
* Refactored `simpleStreams.cu` to run with all possible synch policies (thus foregoing the need for a command-line argument; and - we were ignoring the other one, -anyway)
  • Loading branch information
eyalroz authored and Eyal Rozenberg committed May 11, 2023
1 parent d0ff161 commit f4c6ec1
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 708 deletions.
14 changes: 10 additions & 4 deletions examples/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,16 @@ cuda::device::id_t choose_device(int argc, char const** argv)
}

cuda::device::id_t device_id { -1 };
// Being very cavalier about our command-line arguments here...
if (std::strncmp(argv[1],"--device=", std::strlen("--device=")) == 0) {
auto actual_arg = argv[1] + std::strlen("--device=");
device_id = (argc > 1) ? std::stoi(actual_arg) : cuda::device::default_device_id;
if (argc == 1) {
device_id = cuda::device::default_device_id;
}
else {
std::string device_id_arg { argv[1] };
std::string prefix { "--device=" };
if (device_id_arg.rfind(prefix) == 0) {
device_id_arg = device_id_arg.substr(prefix.length());
}
device_id = std::stoi(device_id_arg);
}

if (device_id < 0) {
Expand Down
Loading

0 comments on commit f4c6ec1

Please sign in to comment.