Back

DefaultTaskScheduler

The `DefaultTaskScheduler` is a part of the SOFA framework's simulation module, specifically under the `sofa::simulation` namespace within the `Sofa.framework.Simulation.Core` module. It inherits from `TaskScheduler`, managing task scheduling and thread management in simulations. **Role and Purpose:** `DefaultTaskScheduler` is responsible for initializing and managing worker threads that execute tasks in parallel, enhancing simulation performance by distributing computational load across multiple cores or processors. **Interactions with Other Components:* - **Task Scheduler Interface**: `init`, `stop`, `addTask`, `getCurrentThreadName`, `getThreadCount` are virtual methods that enable communication between the scheduler and other components in the SOFA framework. These methods manage thread lifecycle, task submission, and status retrieval. - **Worker Threads**: It interacts closely with `WorkerThread` objects to manage their creation, execution of tasks, and cleanup when necessary. **Practical Usage Guidance:** - Initialize the scheduler using `init` method, specifying a desired number of threads. If none is provided, it defaults to the number of hardware threads available. - Submit tasks for parallel processing using `addTask`. The scheduler will manage task distribution among available worker threads. - Use methods like `getCurrentThreadName`, `getThreadCount` to monitor and query thread-related information during runtime.

abstract
The `DefaultTaskScheduler` manages worker threads for parallel processing in SOFA simulations, enhancing performance by distributing tasks across multiple cores or processors.
sheet
# DefaultTaskScheduler ## Overview The `DefaultTaskScheduler` is a component within the SOFA framework's simulation module that handles thread management and task scheduling. It inherits from `TaskScheduler`, providing methods to initialize worker threads, submit tasks for parallel execution, and monitor thread-related information. ## Practical Notes - **Initialization**: Use the `init` method to set up the scheduler with a specified number of threads (defaulting to hardware threads if not provided). - **Task Submission**: Tasks are submitted using the `addTask` method, which distributes them among available worker threads for parallel execution. - **Monitoring**: Methods like `getCurrentThreadName`, `getThreadCount` allow monitoring thread-related information during runtime.
description
The `DefaultTaskScheduler` is a part of the SOFA framework's simulation module, specifically under the `sofa::simulation` namespace within the `Sofa.framework.Simulation.Core` module. It inherits from `TaskScheduler`, managing task scheduling and thread management in simulations. **Role and Purpose:** `DefaultTaskScheduler` is responsible for initializing and managing worker threads that execute tasks in parallel, enhancing simulation performance by distributing computational load across multiple cores or processors. **Interactions with Other Components:* - **Task Scheduler Interface**: `init`, `stop`, `addTask`, `getCurrentThreadName`, `getThreadCount` are virtual methods that enable communication between the scheduler and other components in the SOFA framework. These methods manage thread lifecycle, task submission, and status retrieval. - **Worker Threads**: It interacts closely with `WorkerThread` objects to manage their creation, execution of tasks, and cleanup when necessary. **Practical Usage Guidance:** - Initialize the scheduler using `init` method, specifying a desired number of threads. If none is provided, it defaults to the number of hardware threads available. - Submit tasks for parallel processing using `addTask`. The scheduler will manage task distribution among available worker threads. - Use methods like `getCurrentThreadName`, `getThreadCount` to monitor and query thread-related information during runtime.
maths
The `DefaultTaskScheduler` is not directly involved in mathematical or physical computations but rather focuses on the management and distribution of tasks across multiple threads to enhance simulation performance. Its primary role is thread management, task scheduling, and parallel processing support within the SOFA framework. ### Role and Purpose: - **Thread Management**: The `DefaultTaskScheduler` initializes and manages worker threads. It provides methods such as `init` for initializing the scheduler with a specified number of threads (defaulting to hardware threads if not provided) and `stop` for cleaning up resources used by these threads. - **Task Scheduling**: Tasks are submitted using the `addTask` method, which distributes tasks among available worker threads. The scheduler ensures that tasks are executed in parallel, thereby leveraging multi-core processors for improved performance. ### Interaction with Other Components: - **Worker Threads**: Each worker thread is managed by the `DefaultTaskScheduler`. It creates and attaches these threads using methods like `start` and cleans them up during shutdown via `stop`. - **Task Execution**: The scheduler communicates with tasks through methods such as `addTask`, which adds a task to the queue for execution. Tasks are then executed in parallel by worker threads, enhancing overall simulation efficiency. ### Practical Usage: - **Initialization**: To initialize the scheduler and specify the number of threads (if different from default), call `init`. This method ensures that worker threads are properly set up and ready to execute tasks. - **Task Submission**: Use `addTask` to submit tasks for parallel execution. The scheduler manages the distribution of these tasks across available worker threads, allowing efficient utilization of computational resources. - **Status Monitoring**: Methods like `getCurrentThreadName`, `getThreadCount` allow monitoring of thread-related information during runtime, providing insights into the current state and performance of the simulation. In summary, while the `DefaultTaskScheduler` does not perform mathematical or physical computations directly, its role in managing threads and distributing tasks is crucial for achieving efficient parallel processing in simulations.
{
  "name": "DefaultTaskScheduler",
  "main": {
    "name": "DefaultTaskScheduler",
    "namespace": "sofa::simulation",
    "module": "Sofa.framework.Simulation.Core",
    "include": "sofa/simulation/task/DefaultTaskScheduler.h",
    "doc": "",
    "inherits": [
      "TaskScheduler"
    ],
    "templates": [],
    "data_fields": [],
    "links": [],
    "methods": [
      {
        "name": "init",
        "return_type": "void",
        "params": [
          {
            "name": "nbThread",
            "type": "const unsigned int"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "stop",
        "return_type": "void",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getCurrent",
        "return_type": "WorkerThread *",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getThreadCount",
        "return_type": "unsigned int",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getCurrentThreadName",
        "return_type": "const char *",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getCurrentThreadType",
        "return_type": "int",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "addTask",
        "return_type": "bool",
        "params": [
          {
            "name": "task",
            "type": "Task *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "workUntilDone",
        "return_type": "void",
        "params": [
          {
            "name": "status",
            "type": "Task::Status *"
          }
        ],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "getTaskAllocator",
        "return_type": "Task::Allocator *",
        "params": [],
        "is_virtual": true,
        "is_pure_virtual": false,
        "is_static": false,
        "access": "public"
      },
      {
        "name": "name",
        "return_type": "const char *",
        "params": [],
        "is_virtual": false,
        "is_pure_virtual": false,
        "is_static": true,
        "access": "public"
      }
    ]
  },
  "desc": {
    "description": "The `DefaultTaskScheduler` is a part of the SOFA framework's simulation module, specifically under the `sofa::simulation` namespace within the `Sofa.framework.Simulation.Core` module. It inherits from `TaskScheduler`, managing task scheduling and thread management in simulations.\n\n**Role and Purpose:**\n`DefaultTaskScheduler` is responsible for initializing and managing worker threads that execute tasks in parallel, enhancing simulation performance by distributing computational load across multiple cores or processors.\n\n**Interactions with Other Components:*\n- **Task Scheduler Interface**: `init`, `stop`, `addTask`, `getCurrentThreadName`, `getThreadCount` are virtual methods that enable communication between the scheduler and other components in the SOFA framework. These methods manage thread lifecycle, task submission, and status retrieval.\n- **Worker Threads**: It interacts closely with `WorkerThread` objects to manage their creation, execution of tasks, and cleanup when necessary.\n\n**Practical Usage Guidance:**\n- Initialize the scheduler using `init` method, specifying a desired number of threads. If none is provided, it defaults to the number of hardware threads available.\n- Submit tasks for parallel processing using `addTask`. The scheduler will manage task distribution among available worker threads.\n- Use methods like `getCurrentThreadName`, `getThreadCount` to monitor and query thread-related information during runtime."
  },
  "maths": {
    "maths": "The `DefaultTaskScheduler` is not directly involved in mathematical or physical computations but rather focuses on the management and distribution of tasks across multiple threads to enhance simulation performance. Its primary role is thread management, task scheduling, and parallel processing support within the SOFA framework.\n\n### Role and Purpose:\n- **Thread Management**: The `DefaultTaskScheduler` initializes and manages worker threads. It provides methods such as `init` for initializing the scheduler with a specified number of threads (defaulting to hardware threads if not provided) and `stop` for cleaning up resources used by these threads.\n- **Task Scheduling**: Tasks are submitted using the `addTask` method, which distributes tasks among available worker threads. The scheduler ensures that tasks are executed in parallel, thereby leveraging multi-core processors for improved performance.\n\n### Interaction with Other Components:\n- **Worker Threads**: Each worker thread is managed by the `DefaultTaskScheduler`. It creates and attaches these threads using methods like `start` and cleans them up during shutdown via `stop`.\n- **Task Execution**: The scheduler communicates with tasks through methods such as `addTask`, which adds a task to the queue for execution. Tasks are then executed in parallel by worker threads, enhancing overall simulation efficiency.\n\n### Practical Usage:\n- **Initialization**: To initialize the scheduler and specify the number of threads (if different from default), call `init`. This method ensures that worker threads are properly set up and ready to execute tasks.\n- **Task Submission**: Use `addTask` to submit tasks for parallel execution. The scheduler manages the distribution of these tasks across available worker threads, allowing efficient utilization of computational resources.\n- **Status Monitoring**: Methods like `getCurrentThreadName`, `getThreadCount` allow monitoring of thread-related information during runtime, providing insights into the current state and performance of the simulation.\n\nIn summary, while the `DefaultTaskScheduler` does not perform mathematical or physical computations directly, its role in managing threads and distributing tasks is crucial for achieving efficient parallel processing in simulations."
  },
  "summary": {
    "abstract": "The `DefaultTaskScheduler` manages worker threads for parallel processing in SOFA simulations, enhancing performance by distributing tasks across multiple cores or processors.",
    "sheet": "# DefaultTaskScheduler\n\n## Overview\nThe `DefaultTaskScheduler` is a component within the SOFA framework's simulation module that handles thread management and task scheduling. It inherits from `TaskScheduler`, providing methods to initialize worker threads, submit tasks for parallel execution, and monitor thread-related information.\n\n## Practical Notes\n- **Initialization**: Use the `init` method to set up the scheduler with a specified number of threads (defaulting to hardware threads if not provided).\n- **Task Submission**: Tasks are submitted using the `addTask` method, which distributes them among available worker threads for parallel execution.\n- **Monitoring**: Methods like `getCurrentThreadName`, `getThreadCount` allow monitoring thread-related information during runtime."
  }
}