MCPcopy Create free account
hub / github.com/Oneflow-Inc/oneflow / Thread

Method Thread

oneflow/core/thread/thread.cpp:29–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27namespace oneflow {
28
29Thread::Thread(const StreamId& stream_id) : thrd_id_(EncodeStreamIdToInt64(stream_id)) {
30 local_msg_queue_enabled_ = ParseBooleanFromEnv("ONEFLOW_THREAD_ENABLE_LOCAL_MESSAGE_QUEUE", true);
31 light_actor_enabled_ = ParseBooleanFromEnv("ONEFLOW_ACTOR_ENABLE_LIGHT_ACTOR", true);
32 if (IsClassRegistered<int, StreamContext, const StreamId&>(stream_id.device_id().device_type(),
33 stream_id)) {
34 stream_ctx_.reset(NewObj<int, StreamContext, const StreamId&>(
35 stream_id.device_id().device_type(), stream_id));
36 } else {
37 stream_ctx_.reset(new GenericStreamContext(stream_id));
38 }
39
40 actor_thread_ = std::thread([this, stream_id]() {
41 LazyMode::Guard guard(true);
42 OF_PROFILER_NAME_THIS_HOST_THREAD("_" + ToString(stream_id.device_id().device_type())
43 + std::to_string(stream_id.device_id().device_index())
44 + "_actor");
45 CHECK_JUST(stream_ctx_->stream()->OnExecutionContextSetup());
46 PollMsgChannel();
47 CHECK_JUST(stream_ctx_->stream()->OnExecutionContextTeardown());
48 });
49}
50
51Thread::~Thread() {
52 actor_thread_.join();

Callers 4

__init__Method · 0.80
test_streamMethod · 0.80
test_cpu_streamMethod · 0.80
test_cuda_streamMethod · 0.80

Calls 12

EncodeStreamIdToInt64Function · 0.85
ParseBooleanFromEnvFunction · 0.85
threadClass · 0.85
to_stringFunction · 0.85
ToStringFunction · 0.50
device_typeMethod · 0.45
device_idMethod · 0.45
resetMethod · 0.45
device_indexMethod · 0.45
streamMethod · 0.45

Tested by 3

test_streamMethod · 0.64
test_cpu_streamMethod · 0.64
test_cuda_streamMethod · 0.64