starpu_codelet

Struct starpu_codelet 

Source
#[repr(C)]
pub struct starpu_codelet {
Show 34 fields pub where_: u32, pub can_execute: Option<unsafe extern "C" fn(workerid: c_uint, task: *mut starpu_task, nimpl: c_uint) -> c_int>, pub type_: starpu_codelet_type, pub max_parallelism: c_int, pub cpu_func: starpu_cpu_func_t, pub cuda_func: starpu_cuda_func_t, pub opencl_func: starpu_opencl_func_t, pub cpu_funcs: [starpu_cpu_func_t; 4], pub cuda_funcs: [starpu_cuda_func_t; 4], pub cuda_flags: [c_char; 4], pub hip_funcs: [starpu_hip_func_t; 4], pub hip_flags: [c_char; 4], pub opencl_funcs: [starpu_opencl_func_t; 4], pub opencl_flags: [c_char; 4], pub max_fpga_funcs: [starpu_max_fpga_func_t; 4], pub cpu_funcs_name: [*const c_char; 4], pub bubble_func: starpu_bubble_func_t, pub bubble_gen_dag_func: starpu_bubble_gen_dag_func_t, pub nbuffers: c_int, pub modes: [starpu_data_access_mode; 8], pub dyn_modes: *mut starpu_data_access_mode, pub specific_nodes: c_uint, pub nodes: [c_int; 8], pub dyn_nodes: *mut c_int, pub model: *mut starpu_perfmodel, pub energy_model: *mut starpu_perfmodel, pub per_worker_stats: [c_ulong; 48], pub name: *const c_char, pub color: c_uint, pub callback_func: Option<unsafe extern "C" fn(arg1: *mut c_void)>, pub flags: c_int, pub perf_counter_sample: *mut starpu_perf_counter_sample, pub perf_counter_values: *mut starpu_perf_counter_sample_cl_values, pub checked: c_int,
}
Expand description

The codelet structure describes a kernel that is possibly implemented on various targets. For compatibility, make sure to initialize the whole structure to zero, either by using explicit memset, or the function starpu_codelet_init(), or by letting the compiler implicitly do it in e.g. static storage case.

Note that the codelet structure needs to exist until the task is terminated. If dynamic codelet allocation is desired, release should be done no sooner than the starpu_task::callback_func callback time.

If the application wants to make the structure constant, it needs to be filled exactly as StarPU expects:

  • starpu_codelet::cpu_funcs, starpu_codelet::cuda_funcs, etc. must be used instead of the deprecated starpu_codelet::cpu_func, starpu_codelet::cuda_func, etc.

  • the starpu_codelet::where field must be set.

and additionally, starpu_codelet::checked must be set to 1 to tell StarPU that the conditions above are properly met. Also, the \ref STARPU_CODELET_PROFILING environment variable must be set to 0. An example is provided in tests/main/const_codelet.c

Fields§

§where_: u32

Optional field to indicate which types of processing units are able to execute the codelet. The different values ::STARPU_CPU, ::STARPU_CUDA, ::STARPU_HIP, ::STARPU_OPENCL can be combined to specify on which types of processing units the codelet can be executed. ::STARPU_CPU|::STARPU_CUDA for instance indicates that the codelet is implemented for both CPU cores and CUDA devices while ::STARPU_OPENCL indicates that it is only available on OpenCL devices. If the field is unset, its value will be automatically set based on the availability of the XXX_funcs fields defined below. It can also be set to ::STARPU_NOWHERE to specify that no computation has to be actually done.

§can_execute: Option<unsafe extern "C" fn(workerid: c_uint, task: *mut starpu_task, nimpl: c_uint) -> c_int>

Define a function which should return 1 if the worker designated by \p workerid can execute the \p nimpl -th implementation of \p task, 0 otherwise.

§type_: starpu_codelet_type

Optional field to specify the type of the codelet. The default is ::STARPU_SEQ, i.e. usual sequential implementation. Other values (::STARPU_SPMD or ::STARPU_FORKJOIN) declare that a parallel implementation is also available. See \ref ParallelTasks for details.

§max_parallelism: c_int

Optional field. If a parallel implementation is available, this denotes the maximum combined worker size that StarPU will use to execute parallel tasks for this codelet.

§cpu_func: starpu_cpu_func_t

@deprecated Optional field which has been made deprecated. One should use instead the field starpu_codelet::cpu_funcs.

§cuda_func: starpu_cuda_func_t

@deprecated Optional field which has been made deprecated. One should use instead the starpu_codelet::cuda_funcs field.

§opencl_func: starpu_opencl_func_t

@deprecated Optional field which has been made deprecated. One should use instead the starpu_codelet::opencl_funcs field.

§cpu_funcs: [starpu_cpu_func_t; 4]

Optional array of function pointers to the CPU implementations of the codelet. The functions prototype must be: \code{.c} void cpu_func(void *buffers[], void *cl_arg) \endcode The first argument being the array of data managed by the data management library, and the second argument is a pointer to the argument passed from the field starpu_task::cl_arg. If the field starpu_codelet::where is set, then the field tarpu_codelet::cpu_funcs is ignored if ::STARPU_CPU does not appear in the field starpu_codelet::where, it must be non-NULL otherwise.

§cuda_funcs: [starpu_cuda_func_t; 4]

Optional array of function pointers to the CUDA implementations of the codelet. The functions must be host-functions written in the CUDA runtime API. Their prototype must be: \code{.c} void cuda_func(void *buffers[], void *cl_arg) \endcode If the field starpu_codelet::where is set, then the field starpu_codelet::cuda_funcs is ignored if ::STARPU_CUDA does not appear in the field starpu_codelet::where, it must be non-NULL otherwise.

§cuda_flags: [c_char; 4]

Optional array of flags for CUDA execution. They specify some semantic details about CUDA kernel execution, such as asynchronous execution.

§hip_funcs: [starpu_hip_func_t; 4]

Optional array of function pointers to the HIP implementations of the codelet. The functions must be host-functions written in the HIP runtime API. Their prototype must be: \code{.c} void hip_func(void *buffers[], void *cl_arg) \endcode If the field starpu_codelet::where is set, then the field starpu_codelet::hip_funcs is ignored if ::STARPU_HIP does not appear in the field starpu_codelet::where, it must be non-NULL otherwise.

§hip_flags: [c_char; 4]

Optional array of flags for HIP execution. They specify some semantic details about HIP kernel execution, such as asynchronous execution.

§opencl_funcs: [starpu_opencl_func_t; 4]

Optional array of function pointers to the OpenCL implementations of the codelet. The functions prototype must be: \code{.c} void opencl_func(void *buffers[], void *cl_arg) \endcode If the field starpu_codelet::where field is set, then the field starpu_codelet::opencl_funcs is ignored if ::STARPU_OPENCL does not appear in the field starpu_codelet::where, it must be non-NULL otherwise.

§opencl_flags: [c_char; 4]

Optional array of flags for OpenCL execution. They specify some semantic details about OpenCL kernel execution, such as asynchronous execution.

§max_fpga_funcs: [starpu_max_fpga_func_t; 4]

Optional array of function pointers to the Maxeler FPGA implementations of the codelet. The functions prototype must be: \code{.c} void fpga_func(void *buffers[], void *cl_arg) \endcode The first argument being the array of data managed by the data management library, and the second argument is a pointer to the argument passed from the field starpu_task::cl_arg. If the field starpu_codelet::where is set, then the field starpu_codelet::max_fpga_funcs is ignored if ::STARPU_MAX_FPGA does not appear in the field starpu_codelet::where, it must be non-NULL otherwise.

§cpu_funcs_name: [*const c_char; 4]

Optional array of strings which provide the name of the CPU functions referenced in the array starpu_codelet::cpu_funcs. This can be used when running on MPI MS devices for StarPU to simply look up the MPI MS function implementation through its name.

§bubble_func: starpu_bubble_func_t

Optional function to decide if the task is to be transformed into a bubble

§bubble_gen_dag_func: starpu_bubble_gen_dag_func_t

Optional function to transform the task into a new graph

§nbuffers: c_int

Specify the number of arguments taken by the codelet. These arguments are managed by the DSM and are accessed from the void *buffers[] array. The constant argument passed with the field starpu_task::cl_arg is not counted in this number. This value should not be above \ref STARPU_NMAXBUFS. It may be set to \ref STARPU_VARIABLE_NBUFFERS to specify that the number of buffers and their access modes will be set in starpu_task::nbuffers and starpu_task::modes or starpu_task::dyn_modes, which thus permits to define codelets with a varying number of data.

§modes: [starpu_data_access_mode; 8]

Is an array of ::starpu_data_access_mode. It describes the required access modes to the data needed by the codelet (e.g. ::STARPU_RW). The number of entries in this array must be specified in the field starpu_codelet::nbuffers, and should not exceed \ref STARPU_NMAXBUFS. If insufficient, this value can be set with the configure option \ref enable-maxbuffers “–enable-maxbuffers”.

§dyn_modes: *mut starpu_data_access_mode

Is an array of ::starpu_data_access_mode. It describes the required access modes to the data needed by the codelet (e.g. ::STARPU_RW). The number of entries in this array must be specified in the field starpu_codelet::nbuffers. This field should be used for codelets having a number of data greater than \ref STARPU_NMAXBUFS (see \ref SettingManyDataHandlesForATask). When defining a codelet, one should either define this field or the field starpu_codelet::modes defined above.

§specific_nodes: c_uint

Default value is 0. If this flag is set, StarPU will not systematically send all data to the memory node where the task will be executing, it will read the starpu_codelet::nodes or starpu_codelet::dyn_nodes array to determine, for each data, whether to send it on the memory node where the task will be executing (-1), or on a specific node (!= -1).

§nodes: [c_int; 8]

Optional field. When starpu_codelet::specific_nodes is 1, this specifies the memory nodes where each data should be sent to for task execution. The number of entries in this array is starpu_codelet::nbuffers, and should not exceed \ref STARPU_NMAXBUFS.

§dyn_nodes: *mut c_int

Optional field. When starpu_codelet::specific_nodes is 1, this specifies the memory nodes where each data should be sent to for task execution. The number of entries in this array is starpu_codelet::nbuffers. This field should be used for codelets having a number of data greater than \ref STARPU_NMAXBUFS (see \ref SettingManyDataHandlesForATask). When defining a codelet, one should either define this field or the field starpu_codelet::nodes defined above.

§model: *mut starpu_perfmodel

Optional pointer to the task duration performance model associated to this codelet. This optional field is ignored when set to NULL or when its field starpu_perfmodel::symbol is not set.

§energy_model: *mut starpu_perfmodel

Optional pointer to the task energy consumption performance model associated to this codelet (in J). This optional field is ignored when set to NULL or when its field starpu_perfmodel::symbol is not set. In the case of parallel codelets, this has to account for all processing units involved in the parallel execution.

§per_worker_stats: [c_ulong; 48]

Optional array for statistics collected at runtime: this is filled by StarPU and should not be accessed directly, but for example by calling the function starpu_codelet_display_stats() (See starpu_codelet_display_stats() for details).

§name: *const c_char

Optional name of the codelet. This can be useful for debugging purposes.

§color: c_uint

Optional color of the codelet. This can be useful for debugging purposes. Value 0 acts like if this field wasn’t specified. Color representation is hex triplet (for example: 0xff0000 is red, 0x0000ff is blue, 0xffa500 is orange, …).

§callback_func: Option<unsafe extern "C" fn(arg1: *mut c_void)>

Optional field, the default value is NULL. This is a function pointer of prototype void (*f)(void *) which specifies a possible callback. If this pointer is non-NULL, the callback function is executed on the host after the execution of the task. If the task defines a callback, the codelet callback is not called, unless called within the task callback function. The callback is passed the value contained in the starpu_task::callback_arg field. No callback is executed if the field is set to NULL.

§flags: c_int

Various flags for the codelet.

§perf_counter_sample: *mut starpu_perf_counter_sample§perf_counter_values: *mut starpu_perf_counter_sample_cl_values§checked: c_int

Whether _starpu_codelet_check_deprecated_fields was already done or not.

Trait Implementations§

Source§

impl Clone for starpu_codelet

Source§

fn clone(&self) -> starpu_codelet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for starpu_codelet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for starpu_codelet

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for starpu_codelet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.