I am working with the below sample code.
auto kernarg = hip_impl::make_kernarg(kernel, std::tuple<Args...>{std::move(args)...});
.
.
.
template <typename... Formals, typename... Actuals>
inline impl::kernarg make_kernarg(
void (*kern)(Formals...), std::tuple<Actuals...> actuals) {
static_assert(sizeof...(Formals) == sizeof...(Actuals),
"The count of formal arguments must match the count of actuals.");
if (sizeof...(Formals) == 0) return {};
std::tuple<Formals...> to_formals{std::move(actuals)};
impl::kernarg kernarg;
kernarg.reserve(sizeof(to_formals));
.
.
.
when NULL is present as one of the arguments in actuals, the code gives error as below (type of NULL is long int in this case).
grid_launch.hpp:96:28: error: no matching constructor for initialization of 'std::tuple<float *, int, int *>'
std::tuple<Formals...> to_formals{std::move(actuals)};
^ ~~~~~~~~~~~~~~~~~~~~
grid_launch.hpp:165:30:
note: in instantiation of function template specialization
'impl::make_kernarg<float *, int, int *, float *, int, long>'
requested here
auto kernarg = impl::make_kernarg(kernel, std::tuple<Args...>
{std::move(args)...});
As seen, the expected type of parameter is int* here, but NULL is of type long, so the error.
In such cases, How can we find which argument is NULL in the tuple actuals and fetch it and typecast or do something to match it with the exact type in the tuple to_formals (Here its int*, but it can be any pointer to integral type depending on the situation). Do we need to fetch all the values from to_formals and actuals.