Skip to content

Commit

Permalink
Untested: total non-garbage-collected streams across all devices
Browse files Browse the repository at this point in the history
  • Loading branch information
lukstafi committed Nov 25, 2024
1 parent de6b088 commit 71a566f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Added

- Debug number of total and unreleased events in a stream.

- Debug the total number of non-garbage-collected streams across all devices.

### Fixed

Expand Down
5 changes: 5 additions & 0 deletions cudajit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1716,13 +1716,18 @@ module Stream = struct
| false -> Unsigned.UInt.of_int64 cu_stream_default
| true -> Unsigned.UInt.of_int64 cu_stream_non_blocking

let total_live_streams = Atomic.make 0
let get_total_live_streams () = Atomic.get total_live_streams

let destroy stream =
release_stream stream;
Atomic.decr total_live_streams;
check "cu_stream_destroy" @@ Cuda.cu_stream_destroy stream.stream

let create ?(non_blocking = false) ?(lower_priority = 0) () =
let open Ctypes in
let stream = allocate_n cu_stream ~count:1 in
Atomic.incr total_live_streams;
check "cu_stream_create_with_priority"
@@ Cuda.cu_stream_create_with_priority stream
(uint_of_cu_stream_flags ~non_blocking)
Expand Down
3 changes: 3 additions & 0 deletions cudajit.mli
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,9 @@ module Stream : sig
val total_unreleased_unfinished_delimited_events : t -> int * int * int
(** Debug information about delimited events carried by the stream: total, unreleased (i.e. not
destroyed), unfinished. *)

val get_total_live_streams : unit -> int
(** The total non-garbage-collected streams across all devices. *)
end

(** CUDA events can be used for synchronization between streams without blocking the CPU, and to
Expand Down

0 comments on commit 71a566f

Please sign in to comment.