diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-02-15 10:18:38 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2019-02-15 10:49:25 +0300 |
commit | 4ce9785e01587638ae26256fe23315e436c658ff (patch) | |
tree | 338144aec436dc68a6fdd9240786988dd3f8705e /intern/cycles/blender/blender_python.cpp | |
parent | d17a0270344101c4cd6e5026ea8239240868d24f (diff) |
Cycles: Support multithreaded compilation of kernels
This patch implements a workaround to get the multithreaded compilation from D2231 working.
So far, it only works for Blender, not for Cycles Standalone. Also, I have only tested the Linux codepath in the helper function.
Depends on D2231.
Reviewers: brecht, dingto, sergey, juicyfruit, lukasstockner97
Reviewed By: brecht
Subscribers: Loner, jbakker, candreacchio, 3dLuver, LazyDodo, bliblubli
Differential Revision: https://developer.blender.org/D2264
Diffstat (limited to 'intern/cycles/blender/blender_python.cpp')
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index de702337f98..a720a60c05b 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -40,6 +40,10 @@ #include <OSL/oslconfig.h> #endif +#ifdef WITH_OPENCL +#include "device/device_intern.h" +#endif + CCL_NAMESPACE_BEGIN namespace { @@ -628,6 +632,31 @@ static PyObject *opencl_disable_func(PyObject * /*self*/, PyObject * /*value*/) DebugFlags().opencl.device_type = DebugFlags::OpenCL::DEVICE_NONE; Py_RETURN_NONE; } + +static PyObject *opencl_compile_func(PyObject * /*self*/, PyObject *args) +{ + PyObject *sequence = PySequence_Fast(args, "Arguments must be a sequence"); + if(sequence == NULL) { + Py_RETURN_FALSE; + } + + vector<string> parameters; + for(Py_ssize_t i = 0; i < PySequence_Fast_GET_SIZE(sequence); i++) { + PyObject *item = PySequence_Fast_GET_ITEM(sequence, i); + PyObject *item_as_string = PyObject_Str(item); + const char *parameter_string = PyUnicode_AsUTF8(item_as_string); + parameters.push_back(parameter_string); + Py_DECREF(item_as_string); + } + Py_DECREF(sequence); + + if (device_opencl_compile_kernel(parameters)) { + Py_RETURN_TRUE; + } + else { + Py_RETURN_FALSE; + } +} #endif static bool denoise_parse_filepaths(PyObject *pyfilepaths, vector<string>& filepaths) @@ -903,6 +932,7 @@ static PyMethodDef methods[] = { {"system_info", system_info_func, METH_NOARGS, ""}, #ifdef WITH_OPENCL {"opencl_disable", opencl_disable_func, METH_NOARGS, ""}, + {"opencl_compile", opencl_compile_func, METH_VARARGS, ""}, #endif /* Standalone denoising */ |