Beatmup
|
Task: an operation that can be executed by multiple threads in parallel. More...
#include <parallelism.h>
Public Types | |
enum class | TaskDeviceRequirement { CPU_ONLY , GPU_OR_CPU , GPU_ONLY } |
Specifies which device (CPU and/or GPU) is used to run the task. More... | |
Public Member Functions | |
virtual void | beforeProcessing (ThreadIndex threadCount, ProcessingTarget target, GraphicPipeline *gpu) |
Instruction called before the task is executed. More... | |
virtual void | afterProcessing (ThreadIndex threadCount, GraphicPipeline *gpu, bool aborted) |
Instruction called after the task is executed. More... | |
virtual bool | process (TaskThread &thread)=0 |
Executes the task on CPU within a given thread. More... | |
virtual bool | processOnGPU (GraphicPipeline &gpu, TaskThread &thread) |
Executes the task on GPU. More... | |
virtual TaskDeviceRequirement | getUsedDevices () const |
Communicates devices (CPU and/or GPU) the task is run on. More... | |
virtual ThreadIndex | getMaxThreads () const |
Gives the upper limint on the number of threads the task may be performed by. More... | |
Public Member Functions inherited from Beatmup::Object | |
virtual | ~Object () |
Static Public Member Functions | |
static ThreadIndex | validThreadCount (int number) |
Valid thread count from a given integer value. More... | |
Task: an operation that can be executed by multiple threads in parallel.
Before executing the task, ThreadPool queries the task concerning
Definition at line 90 of file parallelism.h.
|
strong |
Specifies which device (CPU and/or GPU) is used to run the task.
Enumerator | |
---|---|
CPU_ONLY | this task does not use GPU |
GPU_OR_CPU | this task uses GPU if it is available, but CPU fallback is possible |
GPU_ONLY | this task requires GPU, otherwise it cannot run |
Definition at line 95 of file parallelism.h.
|
virtual |
Instruction called before the task is executed.
threadCount | Number of threads used to perform the task |
target | Device used to perform the task |
gpu | A graphic pipeline instance; may be null. |
Reimplemented in Beatmup::BitmapResampler, Beatmup::BitmapBinaryOperation, Beatmup::Crop, Beatmup::Audio::SignalPlot, Beatmup::NNets::InferenceTask, Beatmup::FloodFill, Beatmup::BitmapFromChunk, Beatmup::ShaderApplicator, Beatmup::SceneRenderer, Beatmup::CustomPipeline, Beatmup::Filters::PixelwiseFilter, Beatmup::Metric, Beatmup::FormatConverter, and Beatmup::Audio::AbstractPlayback.
Definition at line 24 of file parallelism.cpp.
|
virtual |
Instruction called after the task is executed.
threadCount | Number of threads used to perform the task |
gpu | GPU to be used to execute the task; may be null. |
aborted | true if the task was aborted |
Reimplemented in Beatmup::BitmapResampler, Beatmup::BitmapBinaryOperation, Beatmup::Crop, Beatmup::Audio::SignalPlot, Beatmup::NNets::InferenceTask, Beatmup::FloodFill, Beatmup::BitmapFromChunk, Beatmup::ShaderApplicator, Beatmup::CustomPipeline, Beatmup::Filters::PixelwiseFilter, Beatmup::Metric, and Beatmup::FormatConverter.
Definition at line 29 of file parallelism.cpp.
|
pure virtual |
Executes the task on CPU within a given thread.
Generally called by multiple threads.
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Implemented in Beatmup::NNets::InferenceTask, Beatmup::FloodFill, Beatmup::Filters::PixelwiseFilter, Beatmup::CallbackTask, Beatmup::TextureHandleFactory, Beatmup::BitmapFromChunk, Beatmup::SceneRenderer, Beatmup::CustomPipeline, Internal::Recycler, Beatmup::GpuTask, Beatmup::DisplaySwitch, Beatmup::BitmapResampler, Beatmup::BitmapBinaryOperation, Beatmup::Metric, Beatmup::FormatConverter, Beatmup::Audio::SignalPlot, Beatmup::Audio::BasicRealtimePlayback, and Beatmup::Crop.
|
virtual |
Executes the task on GPU.
gpu | graphic pipeline instance |
thread | associated task execution context |
true
if the execution is finished correctly, false
otherwise Reimplemented in Beatmup::NNets::InferenceTask, Beatmup::Filters::PixelwiseFilter, Beatmup::ShaderApplicator, Beatmup::SceneRenderer, Beatmup::CustomPipeline, Beatmup::GL::StorageBufferFetcher, Internal::Recycler, Beatmup::BitmapResampler, Beatmup::TextureHandleFactory, Beatmup::Swapper, and Beatmup::DisplaySwitch.
Definition at line 34 of file parallelism.cpp.
|
virtual |
Communicates devices (CPU and/or GPU) the task is run on.
Reimplemented in Beatmup::Filters::PixelwiseFilter, Beatmup::CallbackTask, Beatmup::TextureHandleFactory, Beatmup::CustomPipeline, Internal::Recycler, Beatmup::GpuTask, Beatmup::DisplaySwitch, Beatmup::BitmapResampler, Beatmup::FormatConverter, and Beatmup::Audio::SignalPlot.
Definition at line 54 of file parallelism.cpp.
|
virtual |
Gives the upper limint on the number of threads the task may be performed by.
The actual number of threads running a specific task may be less or equal to the returned value, depending on the number of workers in ThreadPool running the task.
Reimplemented in Beatmup::NNets::InferenceTask, Beatmup::CallbackTask, Beatmup::CustomPipeline, Beatmup::FloodFill, Beatmup::GpuTask, Beatmup::Filters::PixelwiseFilter, Beatmup::BitmapResampler, Beatmup::BitmapBinaryOperation, Beatmup::Metric, Beatmup::Crop, Beatmup::FormatConverter, Beatmup::Audio::SignalPlot, and Beatmup::Audio::AbstractPlayback.
Definition at line 40 of file parallelism.cpp.
|
static |
Valid thread count from a given integer value.
Definition at line 45 of file parallelism.cpp.