/*
 * This file is part of the StarPU Handbook.
 * Copyright (C) 2009--2011  Universit@'e de Bordeaux
 * Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015, 2016  CNRS
 * Copyright (C) 2011, 2012 INRIA
 * See the file version.doxy for copying conditions.
 */

/*! \defgroup API_Insert_Task Insert_Task

\fn starpu_insert_task(struct starpu_codelet *cl, ...)
\ingroup API_Insert_Task
This function does the same as the function starpu_task_insert(). It has been kept to avoid breaking old codes.

\fn int starpu_task_insert(struct starpu_codelet *cl, ...)
\ingroup API_Insert_Task
Create and submit a task corresponding to \p cl with the
following arguments. The argument list must be zero-terminated.

The arguments following the codelet can be of the following types:
<ul>
<li> ::STARPU_R, ::STARPU_W, ::STARPU_RW, ::STARPU_SCRATCH,
::STARPU_REDUX an access mode followed by a data handle;
<li> ::STARPU_DATA_ARRAY followed by an array of data handles and its
number of elements;
<li> ::STARPU_DATA_MODE_ARRAY followed by an array of struct
starpu_data_descr, i.e data handles with their associated access
modes, and its number of elements;
<li> ::STARPU_EXECUTE_ON_WORKER, ::STARPU_WORKER_ORDER followed by an integer value
specifying the worker on which to execute the task (as specified by
starpu_task::execute_on_a_specific_worker)
<li> the specific values ::STARPU_VALUE, ::STARPU_CALLBACK,
::STARPU_CALLBACK_ARG, ::STARPU_CALLBACK_WITH_ARG, ::STARPU_PRIORITY,
::STARPU_TAG, ::STARPU_TAG_ONLY, ::STARPU_FLOPS, ::STARPU_SCHED_CTX, ::STARPU_CL_ARGS
followed by the appropriated objects as defined elsewhere.
</ul>

When using ::STARPU_DATA_ARRAY, the access mode of the data handles is
not defined, it will be taken from the codelet starpu_codelet::modes or starpu_codelet::dyn_modes field. One
should use ::STARPU_DATA_MODE_ARRAY to define the data handles along with the
access modes.

Parameters to be passed to the codelet implementation are defined
through the type ::STARPU_VALUE. The function
starpu_codelet_unpack_args() must be called within the codelet
implementation to retrieve them.

\def STARPU_VALUE
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by a pointer to a constant value and the size of the
constant

\def STARPU_CL_ARGS
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by a memory buffer containing the arguments to be given to
the task, and by the size of the arguments. The memory buffer should
be the result of a previous call to starpu_codelet_pack_args(), and will be
freed (i.e. starpu_task::cl_arg_free will be set to 1)

\def STARPU_CALLBACK
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by a pointer to a callback function

\def STARPU_CALLBACK_WITH_ARG
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by two pointers: one to a callback function, and the other
to be given as an argument to the callback function; this is
equivalent to using both ::STARPU_CALLBACK and
::STARPU_CALLBACK_WITH_ARG.

\def STARPU_CALLBACK_ARG
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by a pointer to be given as an argument to the callback
function

\def STARPU_PRIORITY
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by a integer defining a priority level

\def STARPU_DATA_ARRAY
\ingroup API_Insert_Task
TODO

\def STARPU_DATA_MODE_ARRAY
\ingroup API_Insert_Task
TODO

\def STARPU_EXECUTE_ON_WORKER
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must be
followed by an integer value specifying the worker on which to execute
the task (as specified by starpu_task::execute_on_a_specific_worker)

\def STARPU_WORKER_ORDER
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must be
followed by an integer value specifying the worker order in which to execute
the tasks (as specified by starpu_task::workerorder)

\def STARPU_TAG
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must be followed by a tag.

\def STARPU_TAG_ONLY
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must be followed by a tag.
It sets starpu_task::tag_id, but leaves starpu_task::use_tag as 0.

\def STARPU_NAME
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must be followed by a char *.
It sets starpu_task::name to it.

\def STARPU_FLOPS
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by an amount of floating point operations, as a double.
Users <b>MUST</b> explicitly cast into double, otherwise parameter
passing will not work.

\def STARPU_SCHED_CTX
\ingroup API_Insert_Task
this macro is used when calling starpu_task_insert(), and must
be followed by the id of the scheduling context to which we want to
submit the task.

\fn void starpu_codelet_pack_args(void **arg_buffer, size_t *arg_buffer_size, ...)
\ingroup API_Insert_Task
Pack arguments of type ::STARPU_VALUE into a buffer which can be
given to a codelet and later unpacked with the function
starpu_codelet_unpack_args().

\fn void starpu_codelet_unpack_args(void *cl_arg, ...)
\ingroup API_Insert_Task
Retrieve the arguments of type ::STARPU_VALUE associated to a
task automatically created using the function starpu_task_insert(). If
some parameter is NULL, unpacking will stop there and ignore the remaining
parameters.

\fn void starpu_codelet_unpack_args_and_copyleft(void *cl_arg, void *buffer, size_t buffer_size, ...)
\ingroup API_Insert_Task
Similar to starpu_codelet_unpack_args(), but if some parameter is
NULL, copy the part of cl_arg that has not been read in buffer which
can then be used in a later call to one of the unpack functions.

\fn struct starpu_task *starpu_task_build(struct starpu_codelet *cl, ...)
\ingroup API_Insert_Task
Create a task corresponding to \p cl with the following arguments.
The argument list must be zero-terminated. The arguments
following the codelet are the same as the ones for the function
starpu_task_insert().
If some arguments of type ::STARPU_VALUE are given, the parameter
starpu_task::cl_arg_free will be set to 1.

*/
