1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Copyright © 2023-2024 Apple Inc. */
#ifndef MLX_STREAM_H
#define MLX_STREAM_H
#include <stdbool.h>
#include "mlx/c/device.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* \defgroup mlx_stream Stream
* MLX stream object.
*/
/**@{*/
/**
* A MLX stream object.
*/
typedef struct mlx_stream_ {
void* ctx;
} mlx_stream;
/**
* Returns a new empty stream.
*/
mlx_stream mlx_stream_new();
/**
* Returns a new stream on a device.
*/
mlx_stream mlx_stream_new_device(mlx_device dev);
/**
* Set stream to provided src stream.
*/
int mlx_stream_set(mlx_stream* stream, const mlx_stream src);
/**
* Free a stream.
*/
int mlx_stream_free(mlx_stream stream);
/**
* Get stream description.
*/
int mlx_stream_tostring(mlx_string* str, mlx_stream stream);
/**
* Check if streams are the same.
*/
bool mlx_stream_equal(mlx_stream lhs, mlx_stream rhs);
/**
* Return the device of the stream.
*/
int mlx_stream_get_device(mlx_device* dev, mlx_stream stream);
/**
* Return the index of the stream.
*/
int mlx_stream_get_index(int* index, mlx_stream stream);
/**
* Synchronize with the provided stream.
*/
int mlx_synchronize(mlx_stream stream);
/**
* Returns the default stream on the given device.
*/
int mlx_get_default_stream(mlx_stream* stream, mlx_device dev);
/**
* Set default stream.
*/
int mlx_set_default_stream(mlx_stream stream);
/**
* Returns the current default CPU stream.
*/
mlx_stream mlx_default_cpu_stream_new();
/**
* Returns the current default GPU stream.
*/
mlx_stream mlx_default_gpu_stream_new();
/**@}*/
#ifdef __cplusplus
}
#endif
#endif