aiter_stream.h 720 Bytes
Newer Older
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
// SPDX-License-Identifier: MIT
// Copyright (C) 2024-2026, Advanced Micro Devices, Inc. All rights reserved.
#pragma once

#include <hip/hip_runtime.h>

/// Lightweight thread-local stream manager (pure HIP, no torch dependency).
///
/// Usage:
///   hipStream_t s = aiter::getCurrentHIPStream();
///   aiter::setCurrentHIPStream(stream);

namespace aiter {

namespace detail {

inline hipStream_t& threadLocalStream()
{
    thread_local hipStream_t stream = nullptr;
    return stream;
}

} // namespace detail

inline hipStream_t getCurrentHIPStream()
{
    return detail::threadLocalStream();
}

inline void setCurrentHIPStream(hipStream_t stream)
{
    detail::threadLocalStream() = stream;
}

} // namespace aiter