File util.h¶
Utility functions.
Functions
-
int
gpuarray_register_type
(gpuarray_type * t, int * ret)¶ Registers a type with the kernel machinery.
On error this function will return -1.
- Return
The type code that corresponds to the registered type. This code is only valid for the duration of the application and cannot be reused between invocation.
- Parameters
t
: is a preallocated and filled gpuarray_type structure. The memory can be allocated from static memory as it will never be freed.ret
: is a pointer where the error code (if any) will be stored. It can be NULL in which case no error code will be returned. If there is no error then the memory pointed to byret
will be untouched.
-
const gpuarray_type*
gpuarray_get_type
(int typecode)¶ Get the type structure for a type.
The resulting structure MUST NOT be modified.
- Return
A type structure pointer or NULL
- Parameters
typecode
: the typecode to get structure for
-
size_t
gpuarray_get_elsize
(int typecode)¶ Get the size of one element of a type.
If the type does not exists this function returns (size_t)-1.
- Return
the size
- Parameters
typecode
: the type to get the element size for
-
int
gpuarray_type_flags
(int init, ...)¶ Return the type use flags for the specified typecodes.
The flags for each type passed in are OR-ed together.
To check for a single typecode, you have to pass the final -1 also.
Passing a -1 as the sole argument is allowed and returns 0, however useful that is.
- Return
flags for all passed-in types.
- Parameters
init
: a typecode...
: list of typecodes terminated by -1
-
int
gpuarray_type_flagsa
(unsigned int n, gpuelemwise_arg * arg)¶
-
void
gpuarray_elemwise_collapse
(unsigned int n, unsigned int * nd, size_t * dim, ssize_t ** strs)¶ Perform dimension collapsing on the specified arguments.
This function will check for dimension that are next to each other and contiguous for all inputs and merge them together. This allows to reduce the complexity of the indexing code in kernels and therefore enables faster runtime for kernels.
On return the nd, dims and strs will be overwritten with the collapsed versions.
For scalar arguments, strs[k] can be NULL.
- Parameters
n
: The number of argumentsnd
: The number of dimensions of all argumentsdim
: The compute shapestrs
: The strides for all arguments