Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions sycl/include/CL/sycl/detail/cg_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,23 +149,39 @@ static constexpr bool check_kernel_lambda_takes_args() {
return check_fn_signature<std::remove_reference_t<F>, void(Args...)>::value;
}

// Type traits to find out if kernal lambda has kernel_handler argument
// isKernelLambdaCallableWithKernelHandlerImpl checks if LambdaArgType is void
// (e.g., in single_task), and based on that, calls
// check_kernel_lambda_takes_args with proper set of arguments. Also this type
// trait workarounds compilation error which happens only with msvc.

template <typename KernelType, typename LambdaArgType = void,
template <typename KernelType, typename LambdaArgType,
typename std::enable_if_t<std::is_same<LambdaArgType, void>::value>
* = nullptr>
constexpr bool isKernelLambdaCallableWithKernelHandler() {
constexpr bool isKernelLambdaCallableWithKernelHandlerImpl() {
return check_kernel_lambda_takes_args<KernelType, kernel_handler>();
}

template <typename KernelType, typename LambdaArgType,
typename std::enable_if_t<!std::is_same<LambdaArgType, void>::value>
* = nullptr>
constexpr bool isKernelLambdaCallableWithKernelHandler() {
constexpr bool isKernelLambdaCallableWithKernelHandlerImpl() {
return check_kernel_lambda_takes_args<KernelType, LambdaArgType,
kernel_handler>();
}

// Type traits to find out if kernal lambda has kernel_handler argument

template <typename KernelType>
constexpr bool isKernelLambdaCallableWithKernelHandler() {
return check_kernel_lambda_takes_args<KernelType, kernel_handler>();
}

template <typename KernelType, typename LambdaArgType>
constexpr bool isKernelLambdaCallableWithKernelHandler() {
return isKernelLambdaCallableWithKernelHandlerImpl<KernelType,
LambdaArgType>();
}

// Helpers for running kernel lambda on the host device

template <typename KernelType,
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/kernel_desc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum class kernel_param_kind_t {
kind_accessor = 0,
kind_std_layout = 1, // standard layout object parameters
kind_sampler = 2,
kind_pointer = 3
kind_pointer = 3,
kind_specialization_constants_buffer = 4,
};

// describes a kernel parameter
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ class __SYCL_EXPORT handler {
LambdaArgType>() &&
MIsHost) {
throw cl::sycl::feature_not_supported(
"kernel_handler is not supported by host device.",
"kernel_handler is not yet supported by host device.",
PI_INVALID_OPERATION);
}
MHostKernel.reset(
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/kernel_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ class kernel_handler {
#ifdef __SYCL_DEVICE_ONLY__
return getSpecializationConstantOnDevice<S>();
#else
// TODO: add support of host device
throw cl::sycl::feature_not_supported(
"kernel_handler::get_specialization_constant() is not supported by "
"kernel_handler::get_specialization_constant() is not yet supported by "
"host device.",
PI_INVALID_OPERATION);
#endif // __SYCL_DEVICE_ONLY__
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/specialization_id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ template <typename T> class specialization_id {

template <class... Args>
explicit constexpr specialization_id(Args &&... args)
: MSpecializationConstantValue(args...) {}
: MDefaultValue(std::forward<Args>(args)...) {}

specialization_id(const specialization_id &rhs) = delete;
specialization_id(specialization_id &&rhs) = delete;
specialization_id &operator=(const specialization_id &rhs) = delete;
specialization_id &operator=(specialization_id &&rhs) = delete;

private:
T MSpecializationConstantValue;
T MDefaultValue;
};

} // namespace sycl
Expand Down
6 changes: 6 additions & 0 deletions sycl/source/detail/scheduler/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,12 @@ pi_result ExecCGCommand::SetKernelParamsAndLaunch(
Arg.MSize, Arg.MPtr);
break;
}
case kernel_param_kind_t::kind_specialization_constants_buffer: {
throw cl::sycl::feature_not_supported(
"Specialization constants are not yet fully supported",
PI_INVALID_OPERATION);
break;
}
}
++NextTrueIndex;
}
Expand Down
6 changes: 6 additions & 0 deletions sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,12 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind,
Index + IndexShift);
break;
}
case kernel_param_kind_t::kind_specialization_constants_buffer: {
throw cl::sycl::feature_not_supported(
"Specialization constants are not yet fully supported",
PI_INVALID_OPERATION);
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
// RUN: %t.out

// This test checks all possible scenarios of running single_task, parallel_for
// and parallel_for_work_group to verify that this code compiles and runs
// correctly with user's lambda with and without sycl::kernel_handler argument

#include <CL/sycl.hpp>

int main() {
Expand Down