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
/* 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_* mlx_stream;
/**
* Returns a new stream, with specified `index`, on a device.
*/
mlx_stream mlx_stream_new(int index, mlx_device dev);
/**
* Returns a new stream on a device.
*/
mlx_stream mlx_stream_new_on_device(mlx_device dev);
/**
* Check if streams are the same.
*/
bool mlx_stream_equal(mlx_stream lhs, mlx_stream rhs);
/**
* Return the device of the stream.
*/
mlx_device mlx_stream_get_device(mlx_stream stream);
/**
* Synchronize with the provided stream.
*/
void mlx_synchronize(mlx_stream stream);
/**
* Returns the default stream on the given device.
*/
mlx_stream mlx_default_stream(mlx_device dev);
/**
* Set default stream.
*/
mlx_stream mlx_set_default_stream(mlx_stream stream);
/**
* Returns the current default CPU stream.
*/
mlx_stream mlx_cpu_stream();
/**
* Returns the current default GPU stream.
*/
mlx_stream mlx_gpu_stream();
/**@}*/
#ifdef __cplusplus
}
#endif
#endif