Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/intern/COM_WorkScheduler.h
| Show All 24 Lines | |||||
| #include "COM_defines.h" | #include "COM_defines.h" | ||||
| namespace blender::compositor { | namespace blender::compositor { | ||||
| /** \brief the workscheduler | /** \brief the workscheduler | ||||
| * \ingroup execution | * \ingroup execution | ||||
| */ | */ | ||||
| struct WorkScheduler { | struct WorkScheduler { | ||||
| enum class ThreadingModel { | |||||
| /** Everything is executed in the caller thread. easy for debugging. */ | |||||
| SingleThreaded, | |||||
| /** Multi-threaded model, which uses the BLI_thread_queue pattern. */ | |||||
| Queue, | |||||
| /** Uses BLI_task as threading backend. */ | |||||
| Task | |||||
| }; | |||||
| /** | /** | ||||
| * \brief schedule a chunk of a group to be calculated. | * \brief schedule a chunk of a group to be calculated. | ||||
| * An execution group schedules a chunk in the WorkScheduler | * An execution group schedules a chunk in the WorkScheduler | ||||
| * when ExecutionGroup.get_flags().open_cl is set the work will be handled by a OpenCLDevice | * when ExecutionGroup.get_flags().open_cl is set the work will be handled by a OpenCLDevice | ||||
| * otherwise the work is scheduled for an CPUDevice | * otherwise the work is scheduled for an CPUDevice | ||||
| * \see ExecutionGroup.execute | * \see ExecutionGroup.execute | ||||
| */ | */ | ||||
| static void schedule(WorkPackage *package); | static void schedule(WorkPackage *package); | ||||
| /** | /** | ||||
| * \brief initialize the WorkScheduler | * \brief initialize the WorkScheduler | ||||
| * | * | ||||
| * during initialization the mutexes are initialized. | * during initialization the mutexes are initialized. | ||||
| * there are two mutexes (for every device type one) | * there are two mutexes (for every device type one) | ||||
| * After mutex initialization the system is queried in order to count the number of CPUDevices | * After mutex initialization the system is queried in order to count the number of CPUDevices | ||||
| * and GPUDevices to be created. For every hardware thread a CPUDevice and for every OpenCL GPU | * and GPUDevices to be created. For every hardware thread a CPUDevice and for every OpenCL GPU | ||||
| * device a OpenCLDevice is created. these devices are stored in a separate list (cpudevices & | * device a OpenCLDevice is created. these devices are stored in a separate list (cpudevices & | ||||
| * gpudevices) | * gpudevices) | ||||
| * | * | ||||
| * This function can be called multiple times to lazily initialize OpenCL. | * This function can be called multiple times to lazily initialize OpenCL. | ||||
| */ | */ | ||||
| static void initialize(bool use_opencl, int num_cpu_threads); | static void initialize(bool use_opencl, | ||||
| int num_cpu_threads, | |||||
| ThreadingModel model = ThreadingModel::Queue); | |||||
| /** | /** | ||||
| * \brief deinitialize the WorkScheduler | * \brief deinitialize the WorkScheduler | ||||
| * free all allocated resources | * free all allocated resources | ||||
| */ | */ | ||||
| static void deinitialize(); | static void deinitialize(); | ||||
| /** | /** | ||||
| Show All 35 Lines | |||||