types#
- group Type system
Objects for the specification and management of types.
Enums
-
enum class ReductionOpKind : std::int32_t#
Enum for reduction operator kinds.
Values:
-
enumerator ADD#
Addition
-
enumerator MUL#
Multiplication
-
enumerator MAX#
Binary maximum operator
-
enumerator MIN#
Binary minimum operator
-
enumerator OR#
Bitwise OR
-
enumerator AND#
Bitwse AND
-
enumerator XOR#
Bitwas XOR
-
enumerator ADD#
Functions
-
Type primitive_type(Type::Code code)#
Creates a metadata object for a primitive type.
-
Type binary_type(std::uint32_t size)#
Creates an opaque binary type of a given size.
- Parameters:
size – Element size
- Returns:
Type object
- FixedArrayType fixed_array_type(
- const Type &element_type,
- std::uint32_t N
Creates a metadata object for a fixed-size array type.
- Parameters:
element_type – Type of the array elements
N – Size of the array
- Returns:
FixedArrayType object
- StructType struct_type(
- const std::vector<Type> &field_types,
- bool align = true
Creates a metadata object for a struct type.
- Parameters:
field_types – A vector of field types
align – If true, fields in the struct are aligned
- Returns:
StructType object
-
ListType list_type(const Type &element_type)#
Creates a metadata object for a list type.
-
template<typename ...Args>
std::enable_if_t<std::conjunction_v<std::is_convertible<std::decay_t<Args>, Type>...>, StructType> struct_type( - bool align,
- Args&&... field_types
Creates a metadata object for a struct type.
- Parameters:
align – If true, fields in the struct are aligned
field_types – Field types
- Returns:
StructType object
- std::ostream &operator<<(
- std::ostream &ostream,
- const Type::Code &code
-
std::ostream &operator<<(std::ostream &ostream, const Type &type)#
-
FixedArrayType point_type(std::uint32_t ndim)#
Creates a point type.
- Parameters:
ndim – Number of dimensions
- Returns:
FixedArrayType object
-
StructType rect_type(std::uint32_t ndim)#
Creates a rect type.
- Parameters:
ndim – Number of dimensions
- Returns:
StructType object
-
bool is_point_type(const Type &type)#
Checks if the type is a point type.
- Parameters:
type – Type to check
- Returns:
true If the
type
is a point type- Returns:
false Otherwise
-
bool is_point_type(const Type &type, std::uint32_t ndim)#
Checks if the type is a point type of the given dimensionality.
- Parameters:
type – Type to check
ndim – Number of dimensions the point type should have
- Returns:
true If the
type
is a point type- Returns:
false Otherwise
-
std::int32_t ndim_point_type(const Type &type)#
Returns the number of dimensions of a given point type.
- Parameters:
type – Point type
- Throws:
std::invalid_argument – IF the type is not a point type
- Returns:
Number of dimensions
-
bool is_rect_type(const Type &type)#
Checks if the type is a rect type.
- Parameters:
type – Type to check
- Returns:
true If the
type
is a rect type- Returns:
false Otherwise
-
class Type
- #include <legate/type/types.h>
A base class for data type metadata.
Subclassed by legate::FixedArrayType, legate::ListType, legate::StructType
Public Types
-
enum class Code : std::int32_t
Enum for type codes.
Values:
-
enumerator BOOL
Boolean type
-
enumerator INT8
8-bit signed integer type
-
enumerator INT16
16-bit signed integer type
-
enumerator INT32
32-bit signed integer type
-
enumerator INT64
64-bit signed integer type
-
enumerator UINT8
8-bit unsigned integer type
-
enumerator UINT16
16-bit unsigned integer type
-
enumerator UINT32
32-bit unsigned integer type
-
enumerator UINT64
64-bit unsigned integer type
-
enumerator FLOAT16
Half-precision floating point type
-
enumerator FLOAT32
Single-precision floating point type
-
enumerator FLOAT64
Double-precision floating point type
-
enumerator COMPLEX64
Single-precision complex type
-
enumerator COMPLEX128
Double-precision complex type
-
enumerator NIL
Null type
-
enumerator BINARY
Opaque binary type
-
enumerator FIXED_ARRAY
Fixed-size array type
-
enumerator STRUCT
Struct type
-
enumerator STRING
String type
-
enumerator LIST
List type
-
enumerator BOOL
Public Functions
-
std::uint32_t size() const
Size of the data type in bytes.
- Returns:
Data type size in bytes
-
std::uint32_t alignment() const
Alignment of the type.
- Returns:
Alignment in bytes
-
std::uint32_t uid() const
Unique ID of the data type.
- Returns:
Unique ID
-
bool variable_size() const
Indicates whether the data type is of variable size elements.
- Returns:
true Elements can be variable size
- Returns:
false Elements have fixed size
-
std::string to_string() const
Converts the data type into a string.
- Returns:
A string of the data type
-
bool is_primitive() const
Indicates whether the type is a primitive type.
- Returns:
true If the type is a primitive type
- Returns:
false Otherwise
-
FixedArrayType as_fixed_array_type() const
Dynamically casts the type into a fixed size array type.
If the type is not a fixed size array type, an exception will be raised.
- Returns:
Type object
-
StructType as_struct_type() const
Dynamically casts the type into a struct type.
If the type is not a struct type, an exception will be raised.
- Returns:
Type object
-
ListType as_list_type() const
Dynamically casts the type into a struct type.
If the type is not a struct type, an exception will be raised.
- Returns:
Type object
- void record_reduction_operator(
- std::int32_t op_kind,
- GlobalRedopID global_op_id
Records a reduction operator.
The global ID of the reduction operator is issued when that operator is registered to the runtime.
- Parameters:
op_kind – Reduction operator kind
global_op_id – Global reduction operator ID
- void record_reduction_operator(
- ReductionOpKind op_kind,
- GlobalRedopID global_op_id
Records a reduction operator.
The global ID of the reduction operator is issued when that operator is registered to the runtime.
- Parameters:
op_kind – Reduction operator kind
global_op_id – Global reduction operator ID
-
GlobalRedopID find_reduction_operator(std::int32_t op_kind) const
Finds the global operator ID for a given reduction operator kind.
Raises an exception if no reduction operator has been registered for the kind.
- Parameters:
op_kind – Reduction operator kind
- Returns:
Global reduction operator ID
-
GlobalRedopID find_reduction_operator(ReductionOpKind op_kind) const
Finds the global operator ID for a given reduction operator kind.
Raises an exception if no reduction operator has been registered for the kind.
- Parameters:
op_kind – Reduction operator kind
- Returns:
Global reduction operator ID
-
bool operator==(const Type &other) const
Equality check between types.
Note that type checks are name-based; two isomorphic fixed-size array types are considered different if their uids are different (the same applies to struct types).
- Parameters:
other – Type to compare
- Returns:
true Types are equal
- Returns:
false Types are different
-
enum class Code : std::int32_t
-
class FixedArrayType : public legate::Type
- #include <legate/type/types.h>
A class for fixed-size array data types.
Public Functions
-
std::uint32_t num_elements() const
Returns the number of elements.
- Returns:
Number of elements
-
Type element_type() const
Returns the element type.
- Returns:
Element type
-
std::uint32_t num_elements() const
-
class StructType : public legate::Type
- #include <legate/type/types.h>
A class for struct data types.
Public Functions
-
std::uint32_t num_fields() const
Returns the number of fields.
- Returns:
Number of fields
-
Type field_type(std::uint32_t field_idx) const
Returns the element type.
- Parameters:
field_idx – Field index. Must be within the range
- Returns:
Element type
-
bool aligned() const
Indicates whether the fields are aligned.
- Returns:
true Fields are aligned
- Returns:
false Fields are compact
-
std::vector<std::uint32_t> offsets() const
Returns offsets to fields.
- Returns:
Field offsets in a vector
-
std::uint32_t num_fields() const
-
enum class ReductionOpKind : std::int32_t#