Skip to content

Commit

Permalink
Prefer use of bool_constant<v> instead of `::std::integral_constant…
Browse files Browse the repository at this point in the history
…<bool, v>`
  • Loading branch information
eyalroz committed Feb 29, 2024
1 parent d8c57b8 commit 9598294
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/cuda/api/kernel_launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ template<typename P>
using kernel_parameter_decay_t = typename kernel_parameter_decay<P>::type;

template<typename Fun>
struct is_function_ptr: ::std::integral_constant<bool,
struct is_function_ptr: bool_constant<
::std::is_pointer<Fun>::value and ::std::is_function<typename ::std::remove_pointer<Fun>::type>::value> { };

inline void collect_argument_addresses(void**) { }
Expand All @@ -128,26 +128,26 @@ struct enqueue_launch_helper {

template<typename Kernel, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, false>,
::std::integral_constant<bool, false>,
bool_constant<false>,
bool_constant<false>,
Kernel&& kernel_function,
const stream_t& stream,
launch_configuration_t launch_configuration,
KernelParameters&&... parameters);

template<typename Kernel, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, true>,
::std::integral_constant<bool, false>,
bool_constant<true>,
bool_constant<false>,
Kernel&& kernel,
const stream_t& stream,
launch_configuration_t launch_configuration,
KernelParameters&&... parameters);

template<typename Kernel, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, false>,
::std::integral_constant<bool, true>,
bool_constant<false>,
bool_constant<true>,
Kernel&& kernel,
const stream_t& stream,
launch_configuration_t launch_configuration,
Expand Down Expand Up @@ -333,8 +333,8 @@ void enqueue_launch(
// use tagged dispatch for the separate behavior for raw and wrapped kernels - although the enqueue_launch
// function for each of them will basically be just a one-liner :-(
detail_::enqueue_launch<Kernel, KernelParameters...>(
::std::integral_constant<bool, wrapped_contextual_kernel>{},
::std::integral_constant<bool, library_kernel>{},
detail_::bool_constant<wrapped_contextual_kernel>{},
detail_::bool_constant<library_kernel>{},
::std::forward<Kernel>(kernel), stream, launch_configuration,
::std::forward<KernelParameters>(parameters)...);
}
Expand Down
12 changes: 6 additions & 6 deletions src/cuda/api/multi_wrapper_impls/kernel_launch.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ struct enqueue_launch_helper<kernel_t, KernelParameters...> {

template<typename RawKernelFunction, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, false>, // Not a wrapped contextual kernel,
::std::integral_constant<bool, false>, // and not a library kernel, so it must be a raw kernel function
bool_constant<false>, // Not a wrapped contextual kernel,
bool_constant<false>, // and not a library kernel, so it must be a raw kernel function
RawKernelFunction&& kernel_function,
const stream_t& stream,
launch_configuration_t launch_configuration,
Expand All @@ -229,8 +229,8 @@ void enqueue_launch(

template<typename Kernel, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, true>, // a kernel wrapped in a kernel_t (sub)class
::std::integral_constant<bool, false>, // Not a library kernel
bool_constant<true>, // a kernel wrapped in a kernel_t (sub)class
bool_constant<false>, // Not a library kernel
Kernel&& kernel,
const stream_t& stream,
launch_configuration_t launch_configuration,
Expand All @@ -244,8 +244,8 @@ void enqueue_launch(
#if CUDA_VERSION >= 12000
template<typename Kernel, typename... KernelParameters>
void enqueue_launch(
::std::integral_constant<bool, false>, // Not a wrapped contextual kernel,
::std::integral_constant<bool, true>, // but a library kernel
bool_constant<false>, // Not a wrapped contextual kernel,
bool_constant<true>, // but a library kernel
Kernel&& kernel,
const stream_t& stream,
launch_configuration_t launch_configuration,
Expand Down

0 comments on commit 9598294

Please sign in to comment.