Skip to content

Commit

Permalink
Fixes #579: Can now set the device on launch_config_builder_t, with…
Browse files Browse the repository at this point in the history
… either a device ID or a `device_t` reference
  • Loading branch information
eyalroz committed Jan 29, 2024
1 parent a394820 commit c720d1b
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/cuda/api/launch_config_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class launch_config_builder_t {
if (use_min_params_for_max_occupancy_) {
throw ::std::logic_error(
"Cannot both use the minimum grid parameters for achieving maximum occupancy, _and_ saturate "
"the grid with fixed-size cubs.");
"the grid with fixed-size blocks.");
}
#endif
if (not (kernel_)) {
Expand Down Expand Up @@ -464,13 +464,34 @@ class launch_config_builder_t {

launch_config_builder_t& kernel(const kernel_t* wrapped_kernel_ptr)
{
if (device_ and kernel_->device_id() != device_) {
throw ::std::invalid_argument("Launch config builder already associated with "
+ device::detail_::identify(*device_) + " and cannot further be associated "
"with " +kernel::detail_::identify(*wrapped_kernel_ptr));
}
#ifndef NDEBUG
validate_kernel(wrapped_kernel_ptr);
#endif
kernel_ = wrapped_kernel_ptr;
return *this;
}

launch_config_builder_t& device(const device::id_t device_id)
{
if (kernel_ and kernel_->device_id() != device_id) {
throw ::std::invalid_argument("Launch config builder already associated with "
+ kernel::detail_::identify(*kernel_) + " and cannot further be associated "
"another device: " + device::detail_::identify(device_id));
}
device_ = device_id;
return *this;
}

launch_config_builder_t& device(const device_t& device)
{
return this->device(device.id());
}

launch_config_builder_t& kernel_independent()
{
kernel_ = nullptr;
Expand Down Expand Up @@ -520,8 +541,6 @@ class launch_config_builder_t {
saturate_with_active_blocks_ = false;
return *this;
}


}; // launch_config_builder_t

inline launch_config_builder_t launch_config_builder() { return {}; }
Expand Down

0 comments on commit c720d1b

Please sign in to comment.