Skip to content
Snippets Groups Projects
Commit aec95fac authored by willzhang4a58's avatar willzhang4a58
Browse files

act event

parent fdc92422
No related branches found
No related tags found
No related merge requests found
syntax = "proto2";
package oneflow;
message ActEvent {
required int64 actor_id = 1;
required int64 work_stream_id = 2;
required int64 act_id = 3;
required double start_time = 4;
required double stop_time = 5;
}
#include "oneflow/core/actor/act_event.pb.h"
#include "oneflow/core/actor/actor.h"
namespace oneflow {
void Actor::Init(const TaskProto& task_proto, const ThreadCtx& thread_ctx) {
actor_id_ = task_proto.task_id();
act_id_ = 0;
if (task_proto.has_parallel_ctx()) {
parallel_ctx_.reset(new ParallelContext(task_proto.parallel_ctx()));
}
......@@ -93,7 +95,23 @@ int Actor::HandlerZombie(const ActorMsg& msg) {
}
void Actor::ActUntilFail() {
while (IsReadReady() && IsWriteReady()) { Act(); }
while (IsReadReady() && IsWriteReady()) {
double start_time = GetCurTime();
Act();
if (RuntimeCtx::Singleton()->is_adjust_phase() == false) { continue; }
int64_t actor_id = actor_id_;
int64_t act_id = actor_id_++;
int64_t work_stream_id = device_ctx_->work_stream_id();
device_ctx_->AddCallBack([start_time, act_id, actor_id, work_stream_id]() {
double stop_time = GetCurTime();
ActEvent act_event;
act_event.set_actor_id(actor_id);
act_event.set_work_stream_id(work_stream_id);
act_event.set_act_id(act_id);
act_event.set_start_time(start_time);
act_event.set_stop_time(stop_time);
});
}
}
bool Actor::IsWriteReady() {
......
......@@ -95,6 +95,7 @@ class Actor {
private:
int64_t actor_id_;
int64_t act_id_;
std::unique_ptr<ParallelContext> parallel_ctx_;
std::vector<ExecKernel> exec_kernel_vec_;
HashMap<int64_t, std::vector<std::unique_ptr<Regst>>> produced_regsts_;
......
......@@ -152,6 +152,10 @@ inline uint32_t NewRandomSeed() {
void RedirectStdoutAndStderrToGlogDir();
void CloseStdoutAndStderr();
inline double GetCurTime() {
return std::chrono::high_resolution_clock::now().time_since_epoch().count();
}
} // namespace oneflow
#endif // ONEFLOW_CORE_COMMON_UTIL_H_
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment