/* * MTAPI header contains the public MTAPI API and data type definitions. * * This file defines the MTAPI API. it has to be included by any application * using MTAPI. * * \copyright * Copyright (c) 2012, The Multicore Association. * All rights reserved. * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * (1) Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * (2) Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * (3) Neither the name of the Multicore Association nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * * \note * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #ifndef EMBB_MTAPI_C_MTAPI_H_ #define EMBB_MTAPI_C_MTAPI_H_ /** * \defgroup C_MTAPI MTAPI * \ingroup C * * Multicore Task Management API (MTAPI®). * * MTAPI is an API standardized by the * Multicore Association * for leveraging task parallelism on a wide range of embedded devices * containing symmetric or asymmetric multicore processors. * A description of the basic terms and concepts is given below. More * information can be found on the website of the * Multicore Task Management Working Group. * * ## Definitions * *
Action | *An action is the hardware or software implementation of a job. An * action implemented in software consists of the implementation of an * action function with a predefined signature. Software actions are * registered with the MTAPI runtime and associated with a job. While * executing, an action is also associated with a task and task context. * Hardware implementations of actions must be known a priori in the * MTAPI runtime implementation. There is no standardized way of * registering hardware actions because they are highly * hardware-dependent. Hardware and software actions are referenced by * handles or indirectly through job IDs and job handles. | *
Action Function | *The executable function of an action, invoked by the * MTAPI runtime when a task is started. | *
Affinity | *Defines which cores can execute a given action function. | *
Blocking | *A blocking function does not return until the function completes * successfully or returns with an error. | *
Core | *A core is an undividable processing element. Two cores can share * resources such as memory or ALUs for hyperthreaded cores. The core * notion is necessary for core affinity, but is * implementation-specific. | *
Domain | *An implementation of MTAPI includes one or more domains, each with * one or more nodes. The concept of domains is consistent in all * Multicore Association APIs. A domain is comparable to a subnet in a * network or a namespace for unique names and IDs. Domains are * supported by a runtime. | *
Handle | *An abstract reference to an object on the same node or to an object * managed by another node. A handle is valid only on the node on which * it was requested and generated. A handle is opaque, that is, its * underlying representation is implementation-defined. Handles can be * copied, assigned, and passed as arguments, but the application * should make no other assumptions about the type, representation, or * contents of a handle. | *
Job | *A job provides a way to reference one or more actions. Jobs are * abstractions of the processing implemented in hardware or software * by actions. Multiple actions can implement the same job based on * different hardware resources (for instance a job can be implemented * by one action on a DSP and by another action on a general purpose * core, or a job can be implemented by both hardware and software * actions). Each job is represented by a domain-wide job ID, or by a * job handle local to a node. | *
MCA | *The Multicore Association. | *
MTAPI | *Multicore Task Management API, defined by The Multicore Association. * | *
Node | *A node represents an independent unit of execution that maps to a * process, thread, thread pool, instance of an operating system, * hardware accelerator, processor core, a cluster of processor cores, * or other abstract processing entity with an independent program * counter. Each node can belong to only one domain. The concept of * nodes is consistent in all Multicore Associations APIs. Code * executed on an MTAPI node shares memory (data) with any other code * executed on the same node. | *
Queue | *A software or hardware entity in which tasks are enqueued in a * given order. The queue can ensure in-order execution of tasks. * Furthermore, queues might implement other scheduling policies that * can be configured by setting queue attributes. | *
Reference | *A reference exists when an object or abstract entity has knowledge * or access to another object, without regard to the specific means of * the implementation. | *
Resource | *A processing core or chip, hardware accelerator, memory region, or * I/O. | *
Remote Memory | *Memory that cannot be accessed using standard load and store * operations. For example, host memory is remote to a GPU core. | *
Runtime System | *An MTAPI runtime system (or "runtime") is the underlying * implementation of MTAPI. The core of the runtime system supports * task scheduling and communication with other nodes. Each MTAPI has * an MTAPI runtime system. | *
SMP | *SMP is short for symmetric multiprocessing, in which two or more * identical processing cores are connected to a shared main memory * and are controlled by a single OS instance. | *
Task | *A task is the invocation of an action. A task is associated with a * job object, which is associated with one or more actions. A task * may optionally be associated with a task group. A task has * attributes and an internal state. A task begins its lifetime with a * call to mtapi_task_start() or mtapi_task_enqueue(). A task is * referenced by a handle of type mtapi_task_hndl_t. After a task has * started, it is possible to wait for task completion from other * parts of the program. Every task can run exactly once, i.e., the * task cannot be started a second time. (Note that in other contexts, * the term "task" has a different meaning. Some real-time operating * systems use "task" for operating system threads, for example.) | *
Task Context | *Information about the task, accessible by the corresponding action * function; useful for action code reflection. | *
Attribute num | *Description | *Data Type | *Default | *
---|---|---|---|
\c MTAPI_NODES_NUMCORES | *(Read-only) number of processor cores of the node. | *\c mtapi_uint_t | *(none) | *
Attribute num | *Description | *Data Type | *Default | *
---|---|---|---|
MTAPI_ACTION_GLOBAL | *Indicates whether or not this is a globally visible action. Local * actions are not shared with other nodes. | *mtapi_boolean_t | *MTAPI_TRUE | *
MTAPI_ACTION_AFFINITY | *Core affinity of action code. | *mtapi_affinity_t | *all cores set | *
MTAPI_DOMAIN_SHARED | *Indicates whether or not the action is shareable across * domains. | *mtapi_boolean_t | *MTAPI_TRUE | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_JOB_INVALID | *The \c job_id is not a valid job ID, i.e., no action was created for * that ID or the action has been deleted. | *
\c MTAPI_ERR_ACTION_EXISTS | *This action is already created. | *
\c MTAPI_ERR_ACTION_LIMIT | *Exceeded maximum number of actions allowed. | *
\c MTAPI_ERR_ACTION_NOAFFINITY | *The action was created with an \c MTAPI_ACTION_AFFINITY attribute * that has set the affinity to all cores of the node to * \c MTAPI_FALSE. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
\c MTAPI_ERR_PARAMETER | *Invalid attributes parameter. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_CONTEXT_OUTOFCONTEXT | *Not called in the context of a task execution. This function must * be used in an action function only. The action function must be * called from the MTAPI runtime system. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Attribute num | *Description | *Data Type | *Default | *
---|---|---|---|
\c MTAPI_QUEUE_GLOBAL | *Indicates if this is a globally visible queue. Only global queues * are shared with other nodes. | *\c mtapi_boolean_t | *\c MTAPI_TRUE | *
\c MTAPI_QUEUE_PRIORITY | *Priority of the queue. | *\c mtapi_uint_t | *0(default priority) | *
MTAPI_QUEUE_LIMIT | *Max. number of elements in the queue; the queue blocks on queuing * more items. | *\c mtapi_uint_t | *0(0 stands for 'unlimited') | *
\c MTAPI_QUEUE_ORDERED | *Specify if the queue is order-preserving. | *\c mtapi_boolean_t | *\c MTAPI_TRUE | *
\c MTAPI_QUEUE_RETAIN | *Allow enqueuing of jobs when queue is disabled. | *\c mtapi_boolean_t | *\c MTAPI_FALSE | *
\c MTAPI_DOMAIN_SHARED | *Indicates if the queue is shareable across domains. | *\c mtapi_boolean_t | *\c MTAPI_TRUE | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_QUEUE_INVALID | *The \c queue_id parameter does not refer to a valid queue or it is set * to \c MTAPI_QUEUE_ID_ANY. | *
\c MTAPI_ERR_NODE_NOTINIT | *The node/domain is not initialized. | *
\c MTAPI_ERR_DOMAIN_NOTSHARED | *This resource cannot be shared by this domain. | *
Attribute num | *Description | *Data Type | *Default | *
---|---|---|---|
\c MTAPI_TASK_DETACHED | *Indicates if this is a detached task. A detached task is deleted by * MTAPI runtime after execution. The task handle of detached tasks * must not be used, i.e., it is not possible to wait for completion * of dedicated detached tasks. But it is possible to add detached * tasks to a group and wait for completion of the group. | *\c mtapi_boolean_t | *\c MTAPI_FALSE | *
\c MTAPI_TASK_INSTANCES | *Indicates how many parallel instances of task shall be started by * MTAPI. The default case is that each task is executed exactly once. * Setting this value to n, the corresponding action code will be * executed n times, in parallel, if the underlying hardware allows it. * (see chapter 4.1.7 Multi-Instance Tasks, page 107) | *\c mtapi_uint_t | *1 | *
Error code | *Description | *
---|---|
\c MTAPI_ERR_TASK_INVALID | *Argument is not a valid task handle. | *
\c MTAPI_TIMEOUT | *Timeout was reached. | *
\c MTAPI_ERR_PARAMETER | *Invalid timeout parameter. | *
\c MTAPI_ERR_TASK_CANCELLED | *The task has been canceled because of mtapi_task_cancel() was * called before the task was executed or the error code was set to * \c MTAPI_ERR_TASK_CANCELLED by mtapi_context_status_set() in the * action function. | *
\c MTAPI_ERR_WAIT_PENDING | *mtapi_task_wait() had already been called for the same task and the * first wait call is still pending. | *
\c MTAPI_ERR_ACTION_CANCELLED | *Action execution was canceled by the action function * (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_FAILED | *Error set by action function (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_DELETED | *All actions associated with the task have been deleted before the * execution of the task was started or the error code has been set in * the action function to \c MTAPI_ERR_ACTION_DELETED by * mtapi_context_status_set(). | *
\c MTAPI_ERR_ARG_SIZE | *The size of the arguments expected by action differs from arguments * size of the caller. | *
\c MTAPI_ERR_RESULT_SIZE | *The size of the result buffer expected by action differs from * result buffer size of the caller. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
Error code | *Description | *
---|---|
\c MTAPI_TIMEOUT | *Timeout was reached. | *
\c MTAPI_ERR_GROUP_INVALID | *Argument is not a valid task handle. | *
\c MTAPI_ERR_WAIT_PENDING | *mtapi_group_wait_all() had already been called for the same group * and the first wait call is still pending. | *
\c MTAPI_ERR_PARAMETER | *Invalid timeout parameter. | *
\c MTAPI_ERR_ARG_SIZE | *The size of the arguments expected by action differs from arguments * size of the caller. | *
\c MTAPI_ERR_RESULT_SIZE | *The size of the result buffer expected by action differs from * result buffer size of the caller. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
\c MTAPI_GROUP_COMPLETED | *Group completed, i.e., there are no more task to wait for in * the group. | *
\c MTAPI_ERR_TASK_CANCELLED | *At least one task has been canceled because of mtapi_task_cancel() * was called before the task was executed or the error code was set * to \c MTAPI_ERR_TASK_CANCELLED by mtapi_context_status_set() in the * action function. | *
\c MTAPI_ERR_ACTION_CANCELLED | *The action execution of at least one task was canceled by the * action function (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_FAILED | *Error set by at least one action function * (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_DELETED | *All actions associated with the task have been deleted before the * execution of the task was started or the error code has been set in * the action function to \c MTAPI_ERR_ACTION_DELETED by * mtapi_context_status_set(). | *
Error code | *Description | *
---|---|
\c MTAPI_TIMEOUT | *Timeout was reached. | *
\c MTAPI_ERR_GROUP_INVALID | *Argument is not a valid task handle. | *
\c MTAPI_ERR_PARAMETER | *Invalid timeout parameter. | *
\c MTAPI_ERR_ARG_SIZE | *The size of the arguments expected by action differs from arguments * size of the caller. | *
\c MTAPI_ERR_RESULT_SIZE | *The size of the result buffer expected by action differs from * result buffer size of the caller. | *
\c MTAPI_ERR_NODE_NOTINIT | *The calling node is not initialized. | *
\c MTAPI_GROUP_COMPLETED | *Group completed, i.e., there are no more tasks to wait for in * the group. | *
\c MTAPI_ERR_TASK_CANCELLED | *The task has been canceled because mtapi_task_cancel() was called * before the task was executed, or the error code was set to * \c MTAPI_ERR_TASK_CANCELLED by mtapi_context_status_set() in the * action code. | *
\c MTAPI_ERR_ACTION_CANCELLED | *Action execution was canceled by the action function * (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_FAILED | *Error set by action function (mtapi_context_status_set()). | *
\c MTAPI_ERR_ACTION_DELETED | *All actions associated with the task have been deleted before the * execution of the task was started or the error code has been set in * the action code to \c MTAPI_ERR_ACTION_DELETED * by mtapi_context_status_set(). | *