Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
50d64bd3
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
50d64bd3
编写于
10月 17, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(pytest/windows/impertive): open impertive pytest on windows
GitOrigin-RevId: 2e8f15607e876aac2cc5926da9c9f347f84cf473
上级
dfc3935d
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
47 addition
and
3 deletion
+47
-3
imperative/python/megengine/data/dataloader.py
imperative/python/megengine/data/dataloader.py
+1
-1
src/core/impl/utils/thread.cpp
src/core/impl/utils/thread.cpp
+3
-0
src/core/include/megbrain/utils/thread_impl_1.h
src/core/include/megbrain/utils/thread_impl_1.h
+43
-2
未找到文件。
imperative/python/megengine/data/dataloader.py
浏览文件 @
50d64bd3
...
...
@@ -114,7 +114,7 @@ class DataLoader:
self
.
__initialized
=
True
def
__iter__
(
self
):
if
platform
.
system
()
==
"Windows"
:
if
platform
.
system
()
==
"Windows"
and
self
.
num_workers
>
0
:
print
(
"pyarrow.plasma does not support ParallelDataLoader on windows, changing num_workers to be zero"
)
...
...
src/core/impl/utils/thread.cpp
浏览文件 @
50d64bd3
...
...
@@ -67,6 +67,9 @@ namespace {
/* =============== SCQueueSynchronizer =============== */
size_t
SCQueueSynchronizer
::
cached_max_spin
=
0
;
#ifdef WIN32
bool
SCQueueSynchronizer
::
is_into_atexit
=
false
;
#endif
size_t
SCQueueSynchronizer
::
max_spin
()
{
if
(
cached_max_spin
)
...
...
src/core/include/megbrain/utils/thread_impl_1.h
浏览文件 @
50d64bd3
...
...
@@ -72,6 +72,13 @@ namespace mgb {
return
m_worker_started
;
}
#ifdef WIN32
static
bool
is_into_atexit
;
void
set_finish_called
(
bool
status
)
{
m_wait_finish_called
=
status
;
}
#endif
static
size_t
max_spin
();
void
start_worker
(
std
::
thread
thread
);
...
...
@@ -143,14 +150,29 @@ namespace mgb {
};
public:
void
add_task
(
const
Param
&
param
)
{
#ifdef WIN32
bool
check_is_into_atexit
()
{
if
(
SCQueueSynchronizer
::
is_into_atexit
)
{
mgb_log_warn
(
"add_task after system call atexit happened! "
"ignore it, workround for windows os force INT "
"some thread before shared_ptr destructor "
"finish!!"
);
m_synchronizer
.
set_finish_called
(
true
);
}
return
SCQueueSynchronizer
::
is_into_atexit
;
}
#endif
void
add_task
(
const
Param
&
param
)
{
SyncedParam
*
p
=
allocate_task
();
new
(
p
->
get
())
Param
(
param
);
p
->
init_done
.
store
(
true
,
std
::
memory_order_release
);
m_synchronizer
.
producer_add
();
}
void
add_task
(
Param
&&
param
)
{
void
add_task
(
Param
&&
param
)
{
SyncedParam
*
p
=
allocate_task
();
new
(
p
->
get
())
Param
(
std
::
move
(
param
));
p
->
init_done
.
store
(
true
,
std
::
memory_order_release
);
...
...
@@ -165,6 +187,10 @@ namespace mgb {
void
wait_all_task_finish
()
{
auto
tgt
=
m_queue_tail_tid
.
load
(
std
::
memory_order_acquire
);
do
{
#ifdef WIN32
if
(
check_is_into_atexit
())
return
;
#endif
// we need a loop because other threads might be adding new
// tasks, and m_queue_tail_tid is increased before
// producer_add()
...
...
@@ -184,6 +210,10 @@ namespace mgb {
void
wait_task_queue_empty
()
{
size_t
tgt
,
done
;
do
{
#ifdef WIN32
if
(
check_is_into_atexit
())
return
;
#endif
m_synchronizer
.
producer_wait
();
// producer_wait() only waits for tasks that are added upon
// entrance of the function, and new tasks might be added
...
...
@@ -272,6 +302,17 @@ namespace mgb {
// reload newest tail
tail
=
m_queue_tail
;
if
(
!
m_synchronizer
.
worker_started
())
{
#ifdef WIN32
if
(
!
SCQueueSynchronizer
::
is_into_atexit
)
{
auto
cb_atexit
=
[]
{
SCQueueSynchronizer
::
is_into_atexit
=
true
;
};
auto
err
=
atexit
(
cb_atexit
);
mgb_assert
(
!
err
,
"failed to register windows_call_atexit "
"at exit"
);
}
#endif
m_synchronizer
.
start_worker
(
std
::
thread
{
&
AsyncQueueSC
::
worker_thread_impl
,
this
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录