aboutsummaryrefslogtreecommitdiff
path: root/offload/plugins-nextgen/level_zero/include/AsyncQueue.h
blob: fb38999b2125d57de95d9f46cde10c567d103d62 (plain)
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
//===--- Level Zero Target RTL Implementation -----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// Async Queue wrapper for Level Zero.
//
//===----------------------------------------------------------------------===//

#ifndef OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H
#define OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H

#include <tuple>

#include "L0Memory.h"

namespace llvm::omp::target::plugin {

/// Abstract queue that supports asynchronous command submission.
struct AsyncQueueTy {
  /// List of events attached to submitted commands.
  llvm::SmallVector<ze_event_handle_t> WaitEvents;
  /// Pending staging buffer to host copies.
  llvm::SmallVector<std::tuple<void *, void *, size_t>> H2MList;
  /// Pending USM memory copy commands that must wait for kernel completion.
  llvm::SmallVector<std::tuple<const void *, void *, size_t>> USM2MList;
  /// Kernel event not signaled.
  ze_event_handle_t KernelEvent = nullptr;
  /// Clear data.
  void reset() {
    WaitEvents.clear();
    H2MList.clear();
    USM2MList.clear();
    KernelEvent = nullptr;
  }
};

using AsyncQueuePoolTy = ObjPool<AsyncQueueTy>;

} // namespace llvm::omp::target::plugin
#endif // OPENMP_LIBOMPTARGET_PLUGINS_NEXTGEN_LEVEL_ZERO_ASYNCQUEUE_H