[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43096] branches/tile: Tile branch
Daniel Salazar - 3Developer.com
zanqdo at gmail.com
Tue Jan 3 21:48:34 CET 2012
Are this flags exposed to cmake? I can't find them
cheers
Daniel Salazar
3Developer.com
On Tue, Jan 3, 2012 at 6:06 AM, Jeroen Bakker <j.bakker at atmind.nl> wrote:
> Revision: 43096
>
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43096
> Author: jbakker
> Date: 2012-01-03 12:06:30 +0000 (Tue, 03 Jan 2012)
> Log Message:
> -----------
> Tile branch
> * Enabled OpenCL for the compositor
> * Remove not working Threadind models of the compositor
> * OpenCL will only work when the COM_TM_QUEUE is enabled and
> COM_OPENCL_ENABLED
> * Updated the scons build system
>
> Modified Paths:
> --------------
> branches/tile/build_files/scons/tools/Blender.py
> branches/tile/source/blender/compositor/COM_defines.h
> branches/tile/source/blender/compositor/intern/COM_WorkScheduler.cpp
> branches/tile/source/blender/compositor/intern/COM_WorkScheduler.h
> branches/tile/source/blender/compositor/operations/COM_OpenCLKernels.cl
>
> branches/tile/source/blender/compositor/operations/COM_OpenCLKernels.cl.cpp
> branches/tile/source/blender/opencl/CMakeLists.txt
> branches/tile/source/blender/opencl/OCL_opencl.h
> branches/tile/source/blender/opencl/SConscript
> branches/tile/source/creator/creator.c
>
> Added Paths:
> -----------
> branches/tile/source/blender/opencl/intern/OCL_opencl.c
>
> Modified: branches/tile/build_files/scons/tools/Blender.py
> ===================================================================
> --- branches/tile/build_files/scons/tools/Blender.py 2012-01-03
> 10:55:46 UTC (rev 43095)
> +++ branches/tile/build_files/scons/tools/Blender.py 2012-01-03
> 12:06:30 UTC (rev 43096)
> @@ -317,7 +317,7 @@
> def creator(env):
> sources = ['creator.c']# + Blender.buildinfo(env, "dynamic") +
> Blender.resources
>
> - incs = ['#/intern/guardedalloc', '#/source/blender/blenlib',
> '#/source/blender/blenkernel', '#/source/blender/editors/include',
> '#/source/blender/blenloader', '#/source/blender/imbuf',
> '#/source/blender/renderconverter',
> '#/source/blender/render/extern/include', '#/source/blender/windowmanager',
> '#/source/blender/makesdna', '#/source/blender/makesrna',
> '#/source/gameengine/BlenderRoutines', '#/extern/glew/include',
> '#/source/blender/gpu', env['BF_OPENGL_INC']]
> + incs = ['#/intern/guardedalloc', '#/source/blender/blenlib',
> '#/source/blender/blenkernel', '#/source/blender/editors/include',
> '#/source/blender/blenloader', '#/source/blender/imbuf',
> '#/source/blender/renderconverter',
> '#/source/blender/render/extern/include', '#/source/blender/windowmanager',
> '#/source/blender/makesdna', '#/source/blender/makesrna',
> '#/source/gameengine/BlenderRoutines', '#/extern/glew/include',
> '#/source/blender/gpu', '#/source/blender/opencl', env['BF_OPENGL_INC']]
>
> defs = []
>
>
> Modified: branches/tile/source/blender/compositor/COM_defines.h
> ===================================================================
> --- branches/tile/source/blender/compositor/COM_defines.h 2012-01-03
> 10:55:46 UTC (rev 43095)
> +++ branches/tile/source/blender/compositor/COM_defines.h 2012-01-03
> 12:06:30 UTC (rev 43096)
> @@ -56,34 +56,22 @@
>
> // chunk size determination
> #define COM_PREVIEW_SIZE 140.0f
> -#define COM_OPENCL_ENABLED true
> -#define COM_PREVIEW_ENABLED true
> +#define COM_OPENCL_ENABLED
> +#define COM_PREVIEW_ENABLED
> // workscheduler threading models
> /**
> - * COM_TM_PTHREAD is a threading model based on pthread library. where
> the control (picking new work) is done by each thread
> + * COM_TM_QUEUE is a multithreaded model, which uses the
> BLI_thread_queue pattern. This is the default option.
> */
> -#define COM_TM_PTHREAD 1
> +#define COM_TM_QUEUE 1
>
> /**
> * COM_TM_NOTHREAD is a single threading model, everything is executed in
> the caller thread. easy for debugging
> */
> -#define COM_TM_NOTHREAD 2
> +#define COM_TM_NOTHREAD 0
>
> /**
> - * COM_TM_WORKER is a multithreaded model, which uses the BLI_Worker
> pattern. it is slower as it searched for free threads.
> - * But for stability reasons you can select this one.
> + * COM_CURRENT_THREADING_MODEL can be one of the above, COM_TM_QUEUE is
> currently default.
> */
> -#define COM_TM_WORKER 3
> -
> -/**
> - * COM_TM_QUEUE is a multithreaded model, which uses the
> BLI_thread_queue pattern. it has the same speed as PTHREAD. Currently this
> needs to
> - * be expended with OpenCL. After that it might become the default
> threading model.
> - */
> -#define COM_TM_QUEUE 4
> -
> -/**
> - * COM_CURRENT_THREADING_MODEL can be one of the above, COM_PTHREAD is
> currently default.
> - */
> #define COM_CURRENT_THREADING_MODEL COM_TM_QUEUE
>
> // chunk order
>
> Modified:
> branches/tile/source/blender/compositor/intern/COM_WorkScheduler.cpp
> ===================================================================
> --- branches/tile/source/blender/compositor/intern/COM_WorkScheduler.cpp
> 2012-01-03 10:55:46 UTC (rev 43095)
> +++ branches/tile/source/blender/compositor/intern/COM_WorkScheduler.cpp
> 2012-01-03 12:06:30 UTC (rev 43096)
> @@ -30,61 +30,40 @@
> #include "stdio.h"
> #include "COM_OpenCLKernels.cl.cpp"
>
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_PTHREAD
> -#elif COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
> -#elif COM_CURRENT_THREADING_MODEL == COM_TM_WORKER
> +#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
> +#warning COM_CURRENT_THREADING_MODEL COM_TM_NOTHREAD is activated. Use
> only for debugging.
> #elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> #else
> -#error WorkScheduler: No threading model configured
> +#error COM_CURRENT_THREADING_MODEL No threading model selected
> #endif
>
>
> -/// @brief mutex for cpuwork
> -static ThreadMutex cpumutex;
> -/// @brief mutem for gpuwork
> -static ThreadMutex gpumutex;
> /// @brief global state of the WorkScheduler.
> static WorkSchedulerState state;
> -/// @brief work that are scheduled for a CPUDevice. the work has not been
> picked up by a CPUDevice
> -static list<WorkPackage*> cpuwork;
> -/// @brief work that are scheduled for a OpenCLDevice. the work has not
> been picked up by a OpenCLDevice
> -static list<WorkPackage*> gpuwork;
> /// @brief list of all CPUDevices. for every hardware thread an instance
> of CPUDevice is created
> static vector<CPUDevice*> cpudevices;
> -/// @brief list of all OpenCLDevices. for every OpenCL GPU device an
> instance of OpenCLDevice is created
> -static vector<OpenCLDevice*> gpudevices;
> -static bool openclActive;
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_PTHREAD
> -/// @brief list of all thread for every CPUDevice in cpudevices a thread
> exists
> -static ListBase cputhreads;
> -/// @brief list of all thread for every OpenCLDevice in gpudevices a
> thread exists
> -static ListBase gputhreads;
> -#endif
>
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_WORKER
> -ThreadedWorker *cpuworker;
> -#endif
> -
> #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> /// @brief list of all thread for every CPUDevice in cpudevices a thread
> exists
> static ListBase cputhreads;
> +/// @brief all scheduled work for the cpu
> static ThreadQueue * cpuqueue;
> -#endif
> -
> +static ThreadQueue * gpuqueue;
> #ifdef COM_OPENCL_ENABLED
> static cl_context context;
> static cl_program program;
> +/// @brief list of all OpenCLDevices. for every OpenCL GPU device an
> instance of OpenCLDevice is created
> +static vector<OpenCLDevice*> gpudevices;
> +/// @brief list of all thread for every GPUDevice in cpudevices a thread
> exists
> +static ListBase gputhreads;
> +/// @brief all scheduled work for the gpu
> +#ifdef COM_OPENCL_ENABLED
> +static bool openclActive = false;
> #endif
> -
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_WORKER
> -void* worker_execute_cpu(void* data) {
> - CPUDevice device;
> - WorkPackage * package = (WorkPackage*)data;
> - device.execute(package);
> - delete package;
> - return NULL;
> -}
> #endif
> +#endif
> +
> +
> #if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> void* WorkScheduler::thread_execute_cpu(void* data) {
> bool continueLoop = true;
> @@ -104,38 +83,16 @@
> return NULL;
> }
>
> -bool WorkScheduler::isStopping() {return state == COM_WSS_STOPPING;}
> -
> -#endif
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_PTHREAD
> -void* WorkScheduler::thread_execute_cpu(void* data) {
> - bool continueLoop = true;
> - Device* device = (Device*)data;
> - while (continueLoop) {
> - WorkPackage* work = WorkScheduler::getCPUWork();
> - if (work) {
> - device->execute(work);
> - delete work;
> - }
> - PIL_sleep_ms(100);
> -
> - if (WorkScheduler::isStopping()) {
> - continueLoop = false;
> - }
> - }
> - return NULL;
> -}
> -
> void* WorkScheduler::thread_execute_gpu(void* data) {
> bool continueLoop = true;
> Device* device = (Device*)data;
> while (continueLoop) {
> - WorkPackage* work = WorkScheduler::getGPUWork();
> + WorkPackage* work =
> (WorkPackage*)BLI_thread_queue_pop(gpuqueue);
> if (work) {
> - device->execute(work);
> - delete work;
> + device->execute(work);
> + delete work;
> }
> - PIL_sleep_ms(100);
> + PIL_sleep_ms(10);
>
> if (WorkScheduler::isStopping()) {
> continueLoop = false;
> @@ -145,68 +102,43 @@
> }
>
> bool WorkScheduler::isStopping() {return state == COM_WSS_STOPPING;}
> -
> -WorkPackage* WorkScheduler::getCPUWork() {
> - WorkPackage* result = NULL;
> - BLI_mutex_lock(&cpumutex);
> -
> - if (cpuwork.size()>0) {
> - result = cpuwork.front();
> - cpuwork.pop_front();
> - }
> - BLI_mutex_unlock(&cpumutex);
> - return result;
> -}
> -
> -WorkPackage* WorkScheduler::getGPUWork() {
> - WorkPackage* result = NULL;
> - BLI_mutex_lock(&gpumutex);
> -
> - if (gpuwork.size()>0) {
> - result = gpuwork.front();
> - gpuwork.pop_front();
> - }
> - BLI_mutex_unlock(&gpumutex);
> - return result;
> -}
> -
> #endif
>
>
> +
> void WorkScheduler::schedule(ExecutionGroup *group, int chunkNumber) {
> WorkPackage* package = new WorkPackage(group, chunkNumber);
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_PTHREAD
> - if (group->isOpenCL() && openclActive){
> - BLI_mutex_lock(&gpumutex);
> - gpuwork.push_back(package);
> - BLI_mutex_unlock(&gpumutex);
> - } else{
> - BLI_mutex_lock(&cpumutex);
> - cpuwork.push_back(package);
> - BLI_mutex_unlock(&cpumutex);
> - }
> -#elif COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
> +#if COM_CURRENT_THREADING_MODEL == COM_TM_NOTHREAD
> CPUDevice device;
> device.execute(package);
> delete package;
> -#elif COM_CURRENT_THREADING_MODEL == COM_TM_WORKER
> - BLI_insert_work(cpuworker, package);
> #elif COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> +#ifdef COM_OPENCL_ENABLED
> + if (group->isOpenCL() && openclActive){
> + BLI_thread_queue_push(gpuqueue, package);
> + } else{
> + BLI_thread_queue_push(cpuqueue, package);
> + }
> +#else
> BLI_thread_queue_push(cpuqueue, package);
> #endif
> +#endif
> }
>
> void WorkScheduler::start(CompositorContext &context) {
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_PTHREAD
> +#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> unsigned int index;
> - cpuwork.clear();
> + cpuqueue = BLI_thread_queue_init();
> + BLI_thread_queue_nowait(cpuqueue);
> BLI_init_threads(&cputhreads, thread_execute_cpu,
> cpudevices.size());
> for (index = 0 ; index < cpudevices.size() ; index ++) {
> Device* device = cpudevices[index];
> BLI_insert_thread(&cputhreads, device);
> }
> +#ifdef COM_OPENCL_ENABLED
> if (context.getHasActiveOpenCLDevices()) {
> - gpuwork.clear();
> + gpuqueue = BLI_thread_queue_init();
> + BLI_thread_queue_nowait(gpuqueue);
> BLI_init_threads(&gputhreads, thread_execute_gpu,
> gpudevices.size());
> for (index = 0 ; index < gpudevices.size() ; index ++) {
> Device* device = gpudevices[index];
> @@ -217,70 +149,55 @@
> openclActive = false;
> }
> #endif
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_WORKER
> - cpuworker = BLI_create_worker(worker_execute_cpu,
> cpudevices.size(), 0);
> #endif
> -#if COM_CURRENT_THREADING_MODEL == COM_TM_QUEUE
> - unsigned int index;
> - cpuqueue = BLI_thread_queue_init();
> - BLI_thread_queue_nowait(cpuqueue);
> - BLI_init_threads(&cputhreads, thread_execute_cpu,
> cpudevices.size());
> - for (index = 0 ; index < cpudevices.size() ; index ++) {
> - Device* device = cpudevices[index];
> - BLI_insert_thread(&cputhreads, device);
> - }
> -#endif
> -
> state = COM_WSS_STARTED;
> }
> -
> -void WorkScheduler::stop() {
> - state = COM_WSS_STOPPING;
>
> @@ Diff output truncated at 10240 characters. @@
> _______________________________________________
> Bf-blender-cvs mailing list
> Bf-blender-cvs at blender.org
> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>
More information about the Bf-committers
mailing list