Asynchronous stream queues#

Streams are NOT synchronous. Every async op (cudaMemcpyAsync/cudaMemsetAsync, LAUNCH_STREAM/LAUNCH_DYN_STREAM, cudaStreamAddCallback, cudaLaunchHostFunc, cudaEventRecord) is deferred into its stream’s queue and replayed only at a synchronisation point (cudaStreamSynchronize, cudaDeviceSynchronize, cudaEventSynchronize/Query, cudaStreamQuery, cudaStreamDestroy) or before any operation on the legacy default stream (a blocking cudaMemcpy/cudaMemset/ cudaFree, a plain LAUNCH, …) — the rule that stream 0 synchronises with every blocking stream.

Ops inside one stream replay in issue order; ACROSS streams the scheduler picks at random among the ops currently allowed to run, honouring cudaEventRecord / cudaStreamWaitEvent edges. So — exactly like the block and thread order randomisation — a program that omits a needed cross-stream dependency, or reads a result before synchronising, fails for some SIM_SEEDs instead of silently “working”.

Defined in code/simulator.h.

This page documents 5 symbols: 5 functions.

Functions#

Signature

Description

Availability

Location

Example

inline void drainAll()

sim only

simulator.h:1389

inline void drainOne(simStream_st* s)

sim only

simulator.h:1390

inline bool isDeviceStream(simStream_st* s)

sim only

simulator.h:1387

inline std::vector<simStream_st*>& liveStreams()

sim only

simulator.h:1319

inline void streamEnqueue(simStream_st* s, std::function<void()> fn, simEvent_st* wait = nullptr)

Enqueue on s. The NULL stream is the legacy default stream: drain everything first, then run inline.

sim only

simulator.h:1396