本文整理汇总了C++中group::get_nd_range方法的典型用法代码示例。如果您正苦于以下问题:C++ group::get_nd_range方法的具体用法?C++ group::get_nd_range怎么用?C++ group::get_nd_range使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类group
的用法示例。
在下文中一共展示了group::get_nd_range方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parallel_for_workitem
void parallel_for_workitem(const group<Dimensions> &g,
ParallelForFunctor f) {
#if defined(_OPENMP) && (!defined(TRISYCL_NO_BARRIER) && !defined(_MSC_VER))
/* To implement barriers With OpenMP, one thread is created for each
work-item in the group and thus an OpenMP barrier has the same effect
of an OpenCL barrier executed by the work-items in a workgroup
The issue is that the parallel_for_workitem() execution is slow even
when nd_item::barrier() is not used
*/
range<Dimensions> l_r = g.get_nd_range().get_local_range();
id<Dimensions> id_l_r { l_r };
auto tot = l_r.size();
if constexpr (Dimensions == 1) {
#pragma omp parallel for collapse(1) schedule(static) num_threads(tot)
for (size_t i = 0; i < l_r.get(0); ++i) {
T_Item index{g.get_nd_range()};
index.set_local(i);
index.set_global(index.get_local_id() + id_l_r * g.get_id());
f(index);
}
} else if constexpr (Dimensions == 2) {