52 const float*
const new_xyz,
53 const float*
const xyz,
55 if (b <= 0 || m <= 0)
return;
56 const float radius2 = radius * radius;
57 const size_t wg = kBallQueryWGSize;
59 queue.submit([&](sycl::handler& cgh) {
63 sycl::nd_range<1>(sycl::range<1>(
size_t(b) * m * wg),
66 [=](sycl::nd_item<1> item) [[intel::kernel_args_restrict]] {
67 const size_t group_id = item.get_group(0);
68 const int bs_idx =
static_cast<int>(group_id / m);
69 const int pt_idx =
static_cast<int>(group_id % m);
70 const size_t lid = item.get_local_id(0);
71 auto group = item.get_group();
73 const float*
const nxyz =
74 new_xyz + bs_idx * m * 3 + pt_idx * 3;
75 const float*
const xyz_batch = xyz + bs_idx * n * 3;
77 idx + bs_idx * m * nsample + pt_idx * nsample;
79 const float new_x = nxyz[0];
80 const float new_y = nxyz[1];
81 const float new_z = nxyz[2];
85 for (
int k =
static_cast<int>(lid); k < n;
86 k +=
static_cast<int>(wg)) {
87 const float x = xyz_batch[k * 3 + 0];
88 const float y = xyz_batch[k * 3 + 1];
89 const float z = xyz_batch[k * 3 + 2];
90 const float d2 = (new_x -
x) * (new_x -
x) +
91 (new_y -
y) * (new_y -
y) +
92 (new_z -
z) * (new_z -
z);
93 if (d2 < radius2) ++local_count;
100 const int base_slot = sycl::exclusive_scan_over_group(
101 group, local_count, sycl::plus<int>());
102 const int total_count = sycl::reduce_over_group(
103 group, local_count, sycl::plus<int>());
105 if (total_count == 0) {
117 int slot = base_slot;
118 for (
int k =
static_cast<int>(lid); k < n && slot < nsample;
119 k +=
static_cast<int>(wg)) {
120 const float x = xyz_batch[k * 3 + 0];
121 const float y = xyz_batch[k * 3 + 1];
122 const float z = xyz_batch[k * 3 + 2];
123 const float d2 = (new_x -
x) * (new_x -
x) +
124 (new_y -
y) * (new_y -
y) +
125 (new_z -
z) * (new_z -
z);
135 sycl::group_barrier(group);
136 if (lid == 0 && total_count < nsample) {
137 const int first_value = idx_out[0];
138 for (
int l = total_count; l < nsample; ++l) {
139 idx_out[l] = first_value;
144 queue.wait_and_throw();