Blender  V3.3
work_stealing.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
7 
8 /*
9  * Utility functions for work stealing
10  */
11 
12 /* Map global work index to tile, pixel X/Y and sample. */
14  uint global_work_index,
18 {
19  uint sample_offset, pixel_offset;
20 
21  if (kernel_data.integrator.scrambling_distance < 0.9f) {
22  /* Keep threads for the same sample together. */
23  uint tile_pixels = tile->w * tile->h;
24  sample_offset = global_work_index / tile_pixels;
25  pixel_offset = global_work_index - sample_offset * tile_pixels;
26  }
27  else {
28  /* Keeping threads for the same pixel together.
29  * Appears to improve performance by a few % on CUDA and OptiX. */
30  sample_offset = global_work_index % tile->num_samples;
31  pixel_offset = global_work_index / tile->num_samples;
32  }
33 
34  uint y_offset = pixel_offset / tile->w;
35  uint x_offset = pixel_offset - y_offset * tile->w;
36 
37  *x = tile->x + x_offset;
38  *y = tile->y + y_offset;
39  *sample = tile->start_sample + sample_offset;
40 }
41 
unsigned int uint
Definition: BLI_sys_types.h:67
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_inline
Definition: cuda/compat.h:34
#define ccl_global
Definition: cuda/compat.h:43
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
#define kernel_data
ccl_global const KernelWorkTile * tile
CCL_NAMESPACE_BEGIN ccl_device_inline void get_work_pixel(ccl_global const KernelWorkTile *tile, uint global_work_index, ccl_private uint *x, ccl_private uint *y, ccl_private uint *sample)
Definition: work_stealing.h:13