Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2015 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
CCL_NAMESPACE_BEGIN
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
|
2017-03-13 17:15:40 +01:00
|
|
|
/* This kernel Initializes structures needed in path-iteration kernels.
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
*
|
2017-03-13 17:15:40 +01:00
|
|
|
* Note on Queues:
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
* All slots in queues are initialized to queue empty slot;
|
|
|
|
* The number of elements in the queues is initialized to 0;
|
|
|
|
*/
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2017-02-14 06:20:48 -05:00
|
|
|
#ifndef __KERNEL_CPU__
|
2015-05-26 19:12:49 +05:00
|
|
|
ccl_device void kernel_data_init(
|
2017-02-14 06:20:48 -05:00
|
|
|
#else
|
|
|
|
void KERNEL_FUNCTION_FULL_NAME(data_init)(
|
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
KernelGlobals *kg,
|
|
|
|
ccl_constant KernelData *data,
|
|
|
|
ccl_global void *split_data_buffer,
|
|
|
|
int num_elements,
|
|
|
|
ccl_global char *ray_state,
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
|
2017-02-22 08:10:02 -05:00
|
|
|
#ifdef __KERNEL_OPENCL__
|
2019-04-17 06:17:24 +02:00
|
|
|
KERNEL_BUFFER_PARAMS,
|
2017-02-22 08:10:02 -05:00
|
|
|
#endif
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
int start_sample,
|
|
|
|
int end_sample,
|
|
|
|
int sx,
|
|
|
|
int sy,
|
|
|
|
int sw,
|
|
|
|
int sh,
|
|
|
|
int offset,
|
|
|
|
int stride,
|
|
|
|
ccl_global int *Queue_index, /* Tracks the number of elements in queues */
|
|
|
|
int queuesize, /* size (capacity) of the queue */
|
|
|
|
ccl_global char *
|
|
|
|
use_queues_flag, /* flag to decide if scene-intersect kernel should use queues to fetch ray index */
|
|
|
|
ccl_global unsigned int *work_pools, /* Work pool for each work group */
|
|
|
|
unsigned int num_samples,
|
|
|
|
ccl_global float *buffer)
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
{
|
2017-05-16 15:59:57 -04:00
|
|
|
#ifdef KERNEL_STUB
|
2019-04-17 06:17:24 +02:00
|
|
|
STUB_ASSERT(KERNEL_ARCH, data_init);
|
2017-05-16 15:59:57 -04:00
|
|
|
#else
|
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
# ifdef __KERNEL_OPENCL__
|
|
|
|
kg->data = data;
|
|
|
|
# endif
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.tile.x = sx;
|
|
|
|
kernel_split_params.tile.y = sy;
|
|
|
|
kernel_split_params.tile.w = sw;
|
|
|
|
kernel_split_params.tile.h = sh;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.tile.start_sample = start_sample;
|
|
|
|
kernel_split_params.tile.num_samples = num_samples;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.tile.offset = offset;
|
|
|
|
kernel_split_params.tile.stride = stride;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.tile.buffer = buffer;
|
2017-09-26 23:42:36 +02:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.total_work_size = sw * sh * num_samples;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.work_pools = work_pools;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
kernel_split_params.queue_index = Queue_index;
|
|
|
|
kernel_split_params.queue_size = queuesize;
|
|
|
|
kernel_split_params.use_queues_flag = use_queues_flag;
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
split_data_init(kg, &kernel_split_state, num_elements, split_data_buffer, ray_state);
|
2017-02-22 08:10:02 -05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
# ifdef __KERNEL_OPENCL__
|
|
|
|
kernel_set_buffer_pointers(kg, KERNEL_BUFFER_ARGS);
|
|
|
|
kernel_set_buffer_info(kg);
|
|
|
|
# endif
|
|
|
|
|
|
|
|
int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
|
|
|
|
|
|
|
|
/* Initialize queue data and queue index. */
|
|
|
|
if (thread_index < queuesize) {
|
|
|
|
for (int i = 0; i < NUM_QUEUES; i++) {
|
|
|
|
kernel_split_state.queue_data[i * queuesize + thread_index] = QUEUE_EMPTY_SLOT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thread_index == 0) {
|
|
|
|
for (int i = 0; i < NUM_QUEUES; i++) {
|
|
|
|
Queue_index[i] = 0;
|
|
|
|
}
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
|
2019-04-17 06:17:24 +02:00
|
|
|
/* The scene-intersect kernel should not use the queues very first time.
|
|
|
|
* since the queue would be empty.
|
|
|
|
*/
|
|
|
|
*use_queues_flag = 0;
|
|
|
|
}
|
|
|
|
#endif /* KERENL_STUB */
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
}
|
2017-02-22 08:10:02 -05:00
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|