Skip to content

Commit

Permalink
Fixes #631: cuda::rtc::marshalled_options_t and related code are no…
Browse files Browse the repository at this point in the history
…w within the `detail_` subnamespace
  • Loading branch information
eyalroz committed Apr 13, 2024
1 parent 2fbc0ce commit 0e4db71
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/cuda/rtc/compilation_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,6 @@ struct opt_start_t {
opt_start_t(Delimiter delimiter) : ever_used(false), delimiter_(delimiter){ }
};

} // namespace detail_

template <typename MarshalTarget, typename Delimiter>
MarshalTarget& operator<<(MarshalTarget& mt, detail_::opt_start_t<Delimiter>& opt_start)
{
Expand Down Expand Up @@ -679,15 +677,17 @@ inline marshalled_options_t marshal(const compilation_options_t<Kind>& opts)
marshalled_options_t mo;
// TODO: Can we easily determine the max number of options here?
constexpr bool need_delimiter_after_last_option { true };
process(opts, mo, marshalled_options_t::advance_gadget{}, need_delimiter_after_last_option);
detail_::process(opts, mo, marshalled_options_t::advance_gadget{}, need_delimiter_after_last_option);
return mo;
}

} // namespace detail_

template <source_kind_t Kind>
inline ::std::string render(const compilation_options_t<Kind>& opts)
{
::std::ostringstream oss;
process(opts, oss, ' ');
detail_::process(opts, oss, ' ');
if (oss.tellp() > 0) {
// Remove the last, excessive, delimiter
oss.seekp(-1,oss.cur);
Expand Down
10 changes: 3 additions & 7 deletions src/cuda/rtc/detail/marshalled_options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ template <typename Delimiter> struct opt_start_t;
template<typename T>
struct is_marshalling_control : ::std::false_type {};

} // namespace detail_

/**
* This class is necessary for realizing everything we need from
* the marshalled options: Easy access using an array of pointers,
Expand Down Expand Up @@ -56,8 +54,8 @@ class marshalled_options_t {
mutable ::std::ostringstream oss;
mutable ::std::string finalized {};
::std::vector<size_type> option_positions;
// Offsets into the eventually-created options string.
// Note that the last offset is to a not-yet-existing option
// Offsets into the eventually-created options string.
// Note that the last offset is to a not-yet-existing option
public:

bool empty() const {
Expand Down Expand Up @@ -95,14 +93,12 @@ inline marshalled_options_t& operator<< (marshalled_options_t& mo, marshalled_op
return mo;
}

namespace detail_ {

template<> struct is_marshalling_control<marshalled_options_t::advance_gadget> : ::std::true_type {};

template<typename Delimiter>
struct is_marshalling_control<opt_start_t<Delimiter>> : ::std::true_type {};

}
} // namespace detail_

} // namespace rtc

Expand Down
4 changes: 2 additions & 2 deletions src/cuda/rtc/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class program_t<cuda_cpp> : public program::detail_::base_t<cuda_cpp> {
if ((source_ == nullptr or *source_ == '\0') and options_.preinclude_files.empty()) {
throw ::std::invalid_argument("Attempt to compile a CUDA program without any source code");
}
auto marshalled_options = marshal(options_);
auto marshalled_options = detail_::marshal(options_);
::std::vector<const char*> option_ptrs = marshalled_options.option_ptrs();
return program::detail_::compile(
name_.c_str(),
Expand Down Expand Up @@ -566,7 +566,7 @@ class program_t<ptx> : public program::detail_::base_t<ptx> {
if (source_ == nullptr or *source_ == '\0') {
throw ::std::invalid_argument("Attempt to compile a CUDA program without any source code");
}
auto marshalled_options = marshal(options_);
auto marshalled_options = detail_::marshal(options_);
::std::vector<const char*> option_ptrs = marshalled_options.option_ptrs();
return program::detail_::compile_ptx(
name_.c_str(),
Expand Down

0 comments on commit 0e4db71

Please sign in to comment.