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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/// Marks an instantaneous event in the application.
///
/// # Arguments
///
/// * `message` - The message associated to this marker event.
///
/// # Examples
///
/// ```
/// use nvtx::{mark};
/// mark!("Operation A");
/// ```
/// Starts a nested thread range.
///
/// # Arguments
///
/// * `message` - The event message associated to this range event.
///
/// # Returns
///
/// * returns the 0 based level of range being started. If an error occurs a
/// negative value is returned.
///
/// # Examples
///
/// ```
/// use nvtx::{range_pop, range_push};
/// range_push!("Hello World!");
/// range_pop!();
/// ```
/// Ends a nested thread range.
///
/// # Returns
///
/// * returns the level of the range being ended. If an error occurs a negative
/// value is returned on the current thread.
///
/// # Examples
///
/// ```
/// use nvtx::{range_pop, range_push};
/// range_push!("Hello World!");
/// range_pop!();
/// ```
/// Starts a range that can occur on a different thread than the end.
///
/// # Arguments
///
/// * `message` - The event message associated to this range event.
///
/// # Returns
///
/// * returns the `id` of the range.
///
/// # Examples
///
/// ```
/// use nvtx::{range_end, range_start};
/// let id = range_start!("Hello World!");
/// range_end!(id);
/// ```
/// Ends a range that can occur on a different thread than the start.
///
/// # Arguments
///
/// * `id` - The event id associated to this range event.
///
/// # Examples
///
/// ```
/// use nvtx::{range_end, range_start};
/// let id = range_start!("Hello World!");
/// range_end!(id);
/// ```
/// Starts a range, returning a guard that will end the range when it is dropped.
///
/// This is a convenience for calling [`range_start!`] and [`range_end!`], in particular for cases
/// where a function might exit in multiple places.
///
/// # Arguments
///
/// * `message` - The event message associated to this range event.
///
/// # Returns
///
/// * returns a [`RangeGuard`](crate::RangeGuard) which will end the range when it goes out of
/// scope.
///
/// # Examples
///
/// ```
/// # let some_condition = true;
/// use nvtx::range;
/// let _range = range!("Hello World!");
///
/// // The range will end regardless of which branch is taken.
/// if some_condition {
/// return;
/// }
/// ```
/// Annotate an OS thread with a name.
///
/// # Examples
///
/// ```
/// use std::thread;
/// use nvtx::{name_thread};
/// name_thread!("Thread 1");
/// let handler = thread::spawn(|| {
/// name_thread!("Thread 2");
/// });
/// handler.join().unwrap();
/// ```