Blender
V5.0
intern
cycles
kernel
device
gpu
parallel_prefix_sum.h
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2021-2022 Blender Foundation
2
*
3
* SPDX-License-Identifier: Apache-2.0 */
4
5
#pragma once
6
7
CCL_NAMESPACE_BEGIN
8
9
/* Parallel prefix sum.
10
*
11
* TODO: actually make this work in parallel.
12
*
13
* This is used for an array the size of the number of shaders in the scene
14
* which is not usually huge, so might not be a significant bottleneck. */
15
16
#include "
util/atomic.h
"
17
18
__device__
void
gpu_parallel_prefix_sum
(
const
int
global_id,
19
ccl_global
int
*counter,
20
ccl_global
int
*prefix_sum,
21
const
int
num_values)
22
{
23
if
(global_id != 0) {
24
return
;
25
}
26
27
int
offset = 0;
28
for
(
int
i
= 0;
i
< num_values;
i
++) {
29
const
int
new_offset = offset + counter[
i
];
30
prefix_sum[
i
] = offset;
31
counter[
i
] = 0;
32
offset = new_offset;
33
}
34
}
35
36
CCL_NAMESPACE_END
atomic.h
ccl_global
#define ccl_global
CCL_NAMESPACE_END
#define CCL_NAMESPACE_END
Definition
device/cuda/compat.h:10
__device__
#define __device__
Definition
device/metal/compat.h:292
CCL_NAMESPACE_BEGIN
Definition
python.cpp:37
gpu_parallel_prefix_sum
CCL_NAMESPACE_BEGIN __device__ void gpu_parallel_prefix_sum(const int global_id, ccl_global int *counter, ccl_global int *prefix_sum, const int num_values)
Definition
parallel_prefix_sum.h:18
i
i
Definition
text_draw.cc:230
Generated on
for Blender by
doxygen
1.16.1