summaryrefslogtreecommitdiff
path: root/boost/compute/detail/get_object_info.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/compute/detail/get_object_info.hpp')
-rw-r--r--boost/compute/detail/get_object_info.hpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/boost/compute/detail/get_object_info.hpp b/boost/compute/detail/get_object_info.hpp
index cdc20cbc13..1e6f7132b8 100644
--- a/boost/compute/detail/get_object_info.hpp
+++ b/boost/compute/detail/get_object_info.hpp
@@ -37,6 +37,16 @@ struct bound_info_function
}
template<class Info>
+ cl_int operator()(Info info, size_t input_size, const void *input,
+ size_t size, void *value, size_t *size_ret) const
+ {
+ return m_function(
+ m_object, m_aux_info, info,
+ input_size, input, size, value, size_ret
+ );
+ }
+
+ template<class Info>
cl_int operator()(Info info, size_t size, void *value, size_t *size_ret) const
{
return m_function(m_object, m_aux_info, info, size, value, size_ret);
@@ -96,6 +106,20 @@ struct get_object_info_impl
return value;
}
+
+ template<class Function, class Info>
+ T operator()(Function function, Info info,
+ const size_t input_size, const void* input) const
+ {
+ T value;
+
+ cl_int ret = function(info, input_size, input, sizeof(T), &value, 0);
+ if(ret != CL_SUCCESS){
+ BOOST_THROW_EXCEPTION(opencl_error(ret));
+ }
+
+ return value;
+ }
};
// specialization for bool
@@ -159,6 +183,8 @@ struct get_object_info_impl<std::vector<T> >
BOOST_THROW_EXCEPTION(opencl_error(ret));
}
+ if(size == 0) return std::vector<T>();
+
std::vector<T> vector(size / sizeof(T));
ret = function(info, size, &vector[0], 0);
if(ret != CL_SUCCESS){
@@ -167,6 +193,42 @@ struct get_object_info_impl<std::vector<T> >
return vector;
}
+
+ template<class Function, class Info>
+ std::vector<T> operator()(Function function, Info info,
+ const size_t input_size, const void* input) const
+ {
+ #ifdef BOOST_COMPUTE_CL_VERSION_2_1
+ // For CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT in clGetKernelSubGroupInfo
+ // we can't get param_value_size using param_value_size_ret
+ if(info == CL_KERNEL_LOCAL_SIZE_FOR_SUB_GROUP_COUNT)
+ {
+ std::vector<T> vector(3);
+ cl_int ret = function(
+ info, input_size, input,
+ sizeof(T) * vector.size(), &vector[0], 0
+ );
+ if(ret != CL_SUCCESS){
+ BOOST_THROW_EXCEPTION(opencl_error(ret));
+ }
+ return vector;
+ }
+ #endif
+ size_t size = 0;
+
+ cl_int ret = function(info, input_size, input, 0, 0, &size);
+ if(ret != CL_SUCCESS){
+ BOOST_THROW_EXCEPTION(opencl_error(ret));
+ }
+
+ std::vector<T> vector(size / sizeof(T));
+ ret = function(info, input_size, input, size, &vector[0], 0);
+ if(ret != CL_SUCCESS){
+ BOOST_THROW_EXCEPTION(opencl_error(ret));
+ }
+
+ return vector;
+ }
};
// returns the value (of type T) from the given clGet*Info() function call.
@@ -182,6 +244,12 @@ inline T get_object_info(Function f, Object o, Info i, AuxInfo j)
return get_object_info_impl<T>()(bind_info_function(f, o, j), i);
}
+template<class T, class Function, class Object, class Info, class AuxInfo>
+inline T get_object_info(Function f, Object o, Info i, AuxInfo j, const size_t k, const void * l)
+{
+ return get_object_info_impl<T>()(bind_info_function(f, o, j), i, k, l);
+}
+
// returns the value type for the clGet*Info() call on Object with Enum.
template<class Object, int Enum>
struct get_object_info_type;