From 77edfe3b7c74e534ff0f97e8f6938548a85a63c7 Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Thu, 6 Oct 2022 17:26:38 +0300 Subject: [PATCH] Fix bug #411: Drop occurrences of `std::` namespace prefix without qualification by a `::` prefix (which potentially clashes with NVIDIA's standard library constructs) --- src/cuda/api/detail/optional.hpp | 4 ++-- src/cuda/api/kernel_launch.hpp | 2 +- src/cuda/nvrtc/compilation_options.hpp | 10 ++++----- src/cuda/nvrtc/compilation_output.hpp | 6 +++--- src/cuda/nvrtc/program.hpp | 28 +++++++++++++------------- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cuda/api/detail/optional.hpp b/src/cuda/api/detail/optional.hpp index cef04184..9f03121d 100644 --- a/src/cuda/api/detail/optional.hpp +++ b/src/cuda/api/detail/optional.hpp @@ -11,8 +11,8 @@ #include #include namespace cuda { -using std::optional; -using std::nullopt; +using ::std::optional; +using ::std::nullopt; } // namespace cuda #elif __cplusplus >= 201402L namespace cuda { diff --git a/src/cuda/api/kernel_launch.hpp b/src/cuda/api/kernel_launch.hpp index 70252f67..66b5b587 100644 --- a/src/cuda/api/kernel_launch.hpp +++ b/src/cuda/api/kernel_launch.hpp @@ -341,7 +341,7 @@ void launch( * * @tparam SpanOfConstVoidPtrLike * Type of the container for the marshalled arguments; typically, this - * would be `span` - but it can be an `std::vector`, or + * would be `span` - but it can be an `::std::vector`, or * have non-const `void*` elements etc. * @param stream * Proxy for the stream on which to enqueue the kernel launch; may be the diff --git a/src/cuda/nvrtc/compilation_options.hpp b/src/cuda/nvrtc/compilation_options.hpp index 51e95bcb..544930e8 100644 --- a/src/cuda/nvrtc/compilation_options.hpp +++ b/src/cuda/nvrtc/compilation_options.hpp @@ -276,26 +276,26 @@ struct compilation_options_t { /** * Extra options for the PTX compiler (a.k.a. "PTX optimizing assembler"). */ - std::string ptxas; + ::std::string ptxas; /** * A sequence of directories to be searched for headers. These paths are searched _after_ the * list of headers given to nvrtcCreateProgram. * - * @note The members here are `std::string`'s rather than `const char*` or `std::string_view`'s, + * @note The members here are `::std::string`'s rather than `const char*` or `::std::string_view`'s, * since this class is a value-type, and cannot rely someone else keeping these strings alive. * - * @todo In C++17, consider making the elements `std::filesystem::path`'s. + * @todo In C++17, consider making the elements `::std::filesystem::path`'s. */ ::std::vector<::std::string> additional_include_paths; /** * Header files to preinclude during preprocessing of the source. * - * @note The members here are `std::string`'s rather than `const char*` or `std::string_view`'s, + * @note The members here are `::std::string`'s rather than `const char*` or `::std::string_view`'s, * since this class is a value-type, and cannot rely someone else keeping these strings alive. * - * @todo In C++17, consider making the elements `std::filesystem::path`'s. + * @todo In C++17, consider making the elements `::std::filesystem::path`'s. * * @todo Check how these strings are interpreted. Do they need quotation marks? brackets? full paths? */ diff --git a/src/cuda/nvrtc/compilation_output.hpp b/src/cuda/nvrtc/compilation_output.hpp index a68fadb4..b20cdab7 100644 --- a/src/cuda/nvrtc/compilation_output.hpp +++ b/src/cuda/nvrtc/compilation_output.hpp @@ -93,8 +93,8 @@ inline size_t get_cubin_size(program::handle_t program_handle, const char* progr auto status = nvrtcGetCUBINSize(program_handle, &size); throw_if_error(status, "Failed obtaining NVRTC program output CUBIN size"); if (size == 0) { - throw std::runtime_error("CUBIN requested for a program compiled for a virtual architecture only: " - + identify(program_handle, program_name)); + throw ::std::runtime_error("CUBIN requested for a program compiled for a virtual architecture only: " + + identify(program_handle, program_name)); } return size; } @@ -103,7 +103,7 @@ inline void get_cubin(char* buffer, program::handle_t program_handle, const char { auto status = nvrtcGetCUBIN(program_handle, buffer); throw_if_error(status, "Failed obtaining NVRTC program output CUBIN for " - + identify(program_handle, program_name)); + + identify(program_handle, program_name)); } #endif // CUDA_VERSION >= 11010 diff --git a/src/cuda/nvrtc/program.hpp b/src/cuda/nvrtc/program.hpp index f2a96919..984087f0 100644 --- a/src/cuda/nvrtc/program.hpp +++ b/src/cuda/nvrtc/program.hpp @@ -168,12 +168,12 @@ class program_t { template static inline void check_string_type() { - using no_cref_string_type = typename std::remove_const::type>::type; + using no_cref_string_type = typename ::std::remove_const::type>::type; static_assert( - std::is_same::value or - std::is_same::value or - std::is_same::value or - std::is_same::value, + ::std::is_same::value or + ::std::is_same::value or + ::std::is_same::value or + ::std::is_same::value, "Cannot use this type for a named header name or source; use char*, const char* or a " "reference to a string you own" ); @@ -181,19 +181,19 @@ class program_t { // Note: All methods involved in adding headers - which eventually call one of the // three adders of each kind here - are written carefully to support both C-style strings - // and lvalue references to std::string's - but _not_ rvalue strings or rvalue string + // and lvalue references to ::std::string's - but _not_ rvalue strings or rvalue string // references, as the latter are not owned by the caller, and this class' code does not // make a copy or take ownership. If you make any changes, you must be very careful not // to _copy_ anything by mistake, but rather carry forward reference-types all the way // to here. - void add_header_name_ (const char* name) { headers_.names.emplace_back(name); } - void add_header_name_ (const std::string& name) { add_header_name_(name.c_str()); } - void add_header_name_ (std::string&& name) = delete; + void add_header_name_ (const char* name) { headers_.names.emplace_back(name); } + void add_header_name_ (const ::std::string& name) { add_header_name_(name.c_str()); } + void add_header_name_ (::std::string&& name) = delete; - void add_header_source_(const char* source) { headers_.sources.emplace_back(source); } - void add_header_source_(const std::string& source) { add_header_source_(source.c_str()); } - void add_header_source_(std::string&& source) = delete; + void add_header_source_(const char* source) { headers_.sources.emplace_back(source); } + void add_header_source_(const ::std::string& source) { add_header_source_(source.c_str()); } + void add_header_source_(::std::string&& source) = delete; public: // mutators template @@ -205,7 +205,7 @@ class program_t { } template - program_t& add_header(const std::pair& name_and_source) + program_t& add_header(const ::std::pair& name_and_source) { add_header_name_(name_and_source.first); add_header_source_(name_and_source.second); @@ -213,7 +213,7 @@ class program_t { } template - program_t& add_header(std::pair&& name_and_source) + program_t& add_header(::std::pair&& name_and_source) { check_string_type(); check_string_type();