Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
2 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "core/framework/execution_steps.h"
#include "core/framework/sequential_executor.h"
 
namespace onnxruntime {
 
BarrierStep::BarrierStep(size_t id, NodeIndex node_index) : SequentialExecutionPlan::ExecutionStep(node_index),
                                                            barrier_id_{id} {}
 
Status BarrierStep::Execute(StreamExecutionContext& ctx,
                            size_t /*stream_idx*/,
                            SessionScope& /*session_scope*/,
                            const bool& /*terminate_flag*/,
                            bool& continue_flag) {
  continue_flag = ctx.DecCountDownBarrier(barrier_id_);
  return Status::OK();
}
 
std::string BarrierStep::ToString() const {
  // Set a barrier with id: barrier_id_, count: 2.
  return MakeString("Barrier - BarrierId: ", barrier_id_, ", Count: ", 2);
}
 
WaitOnEPStep::WaitOnEPStep(WaitNotificationFn handle, NotificationIndex idx, NodeIndex node_index)
    : SequentialExecutionPlan::ExecutionStep(node_index),
      wait_fn_(handle),
      notification_idx_(idx) {
  ORT_ENFORCE(wait_fn_, "WaitNoficationFn must be provided.");
}
 
Status WaitOnEPStep::Execute(StreamExecutionContext& ctx,
                             size_t stream_idx,
                             SessionScope& /*session_scope*/,
                             const bool& /*terminate_flag*/,
                             bool& continue_flag) {
  auto* stream = ctx.GetDeviceStream(stream_idx);
  auto& notification = *ctx.GetNotification(notification_idx_);
  wait_fn_(stream, notification);
 
  // update the stream's clock status
  if (stream != nullptr) {
    stream->UpdateWithAwaitedNotification(notification);
  }
 
  LOGS(ctx.GetLogger(), VERBOSE) << "stream " << stream_idx << " wait on Notification with id: " << notification_idx_;
  continue_flag = true;
  return Status::OK();
}
 
std::string WaitOnEPStep::ToString() const {
  // Wait on notification with notification_idx_
  return MakeString("WaitOnEP - NotificationId: ", notification_idx_);
}
 
#if defined(ORT_MINIMAL_BUILD)
LaunchKernelStep::LaunchKernelStep(NodeIndex index)
    : SequentialExecutionPlan::ExecutionStep(index) {}
#else
LaunchKernelStep::LaunchKernelStep(NodeIndex index, std::string_view node_name)
    : SequentialExecutionPlan::ExecutionStep(index), node_name_(node_name) {}
#endif
 
Status LaunchKernelStep::Execute(StreamExecutionContext& ctx,
                                 size_t stream_idx,
                                 SessionScope& session_scope,
                                 const bool& terminate_flag,
                                 bool& continue_flag) {
#ifdef ENABLE_TRAINING
  // legacy code required by ORTTrainer. Should be removed when ORTTrainer is removed
  auto* node_to_execute = ctx.GetNodeToExecute();
  if (node_to_execute && node_to_execute->count(node_index_) == 0) {
    continue_flag = true;
    return Status::OK();
  }
#endif
  Status status = ExecuteKernel(ctx, node_index_, stream_idx, terminate_flag, session_scope);
  continue_flag = status.IsOK();
  return status;
}
 
std::string LaunchKernelStep::ToString() const {
#if defined(ORT_MINIMAL_BUILD)
  return MakeString("LaunchKernel - ", "NodeIndex: ", node_index_);
#else
  return MakeString("LaunchKernel - ", "NodeIndex: ", node_index_, ", Name: ", node_name_);
#endif
}
 
ActivateNotificationStep::ActivateNotificationStep(
    NotificationIndex notification_index, NodeIndex node_index) : SequentialExecutionPlan::ExecutionStep(node_index),
                                                                  notification_idx_(notification_index) {}
 
Status ActivateNotificationStep::Execute(StreamExecutionContext& ctx,
                                         size_t stream_idx,
                                         SessionScope& /*session_scope*/,
                                         const bool& /*terminate_flag*/,
                                         bool& continue_flag) {
  if (ctx.GetNotification(notification_idx_)) {
    ctx.GetNotification(notification_idx_)->ActivateAndUpdate();
  }
  LOGS(ctx.GetLogger(), VERBOSE) << "stream " << stream_idx
                                 << " activate notification with index " << notification_idx_;
  continue_flag = true;
  return Status::OK();
}
 
std::string ActivateNotificationStep::ToString() const {
  // Activate notification with id: notification_idx_
  return MakeString("ActivateNotification - NotificationId: ", notification_idx_);
}
 
TriggerDownstreamStep::TriggerDownstreamStep(size_t trigger_point_index, NodeIndex node_index)
    : SequentialExecutionPlan::ExecutionStep(node_index), trigger_point_index_(trigger_point_index) {}
 
Status TriggerDownstreamStep::Execute(StreamExecutionContext& ctx,
                                      size_t /*stream_idx*/,
                                      SessionScope& session_scope,
                                      const bool& terminate_flag,
                                      bool& continue_flag) {
  ScheduleDownstream(ctx, trigger_point_index_, ctx.SingleThreadMode(), terminate_flag, session_scope);
  continue_flag = true;
  return Status::OK();
}
 
std::string TriggerDownstreamStep::ToString() const {
  // Trigger downstream of trigger point: trigger_point_index_.
  return MakeString("TriggerDownstream - TriggerPointIndex: ", trigger_point_index_);
}
 
}  // namespace onnxruntime