Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
964dbdd7
提交
964dbdd7
authored
3月 27, 2009
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Using new compilation directory lock to make parallel execution safer
上级
36233c33
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
41 行增加
和
10 行删除
+41
-10
cc.py
theano/gof/cc.py
+33
-9
cutils.py
theano/gof/cutils.py
+8
-1
没有找到文件。
theano/gof/cc.py
浏览文件 @
964dbdd7
...
@@ -2,7 +2,6 @@
...
@@ -2,7 +2,6 @@
Defines Linkers that deal with C implementations.
Defines Linkers that deal with C implementations.
"""
"""
# Python imports
# Python imports
from
copy
import
copy
from
copy
import
copy
import
md5
import
md5
...
@@ -20,6 +19,7 @@ import link
...
@@ -20,6 +19,7 @@ import link
import
utils
import
utils
from
compiledir
import
*
from
compiledir
import
*
from
compilelock
import
get_lock
,
release_lock
class
CodeBlock
:
class
CodeBlock
:
"""WRITEME
"""WRITEME
...
@@ -301,7 +301,6 @@ def struct_variable_codeblocks(variable, policies, id, symbol_table, sub):
...
@@ -301,7 +301,6 @@ def struct_variable_codeblocks(variable, policies, id, symbol_table, sub):
return
struct_builder
,
block
return
struct_builder
,
block
class
CLinker
(
link
.
Linker
):
class
CLinker
(
link
.
Linker
):
"""WRITEME
"""WRITEME
...
@@ -616,8 +615,17 @@ class CLinker(link.Linker):
...
@@ -616,8 +615,17 @@ class CLinker(link.Linker):
f()
f()
first_output = ostor[0].data
first_output = ostor[0].data
"""
"""
# Note: acquiring the lock here may not be necessary. However, it is
# cheap enough that it should not matter.
get_lock
()
try
:
cthunk
,
in_storage
,
out_storage
,
error_storage
=
self
.
__compile__
(
input_storage
,
output_storage
)
cthunk
,
in_storage
,
out_storage
,
error_storage
=
self
.
__compile__
(
input_storage
,
output_storage
)
return
_execute
(
cthunk
,
self
.
init_tasks
,
self
.
tasks
,
error_storage
),
in_storage
,
out_storage
res
=
_execute
(
cthunk
,
self
.
init_tasks
,
self
.
tasks
,
error_storage
),
in_storage
,
out_storage
except
:
release_lock
()
raise
release_lock
()
return
res
def
cthunk_factory
(
self
,
error_storage
,
in_storage
,
out_storage
):
def
cthunk_factory
(
self
,
error_storage
,
in_storage
,
out_storage
):
"""WRITEME
"""WRITEME
...
@@ -632,9 +640,14 @@ class CLinker(link.Linker):
...
@@ -632,9 +640,14 @@ class CLinker(link.Linker):
type, value and traceback of the exception in error_storage.
type, value and traceback of the exception in error_storage.
"""
"""
get_lock
()
try
:
# check if we already compiled this
# check if we already compiled this
if
not
getattr
(
self
,
'instantiate'
,
False
):
if
not
getattr
(
self
,
'instantiate'
,
False
):
self
.
code_gen
()
self
.
code_gen
()
module_name
=
self
.
hash
module_name
=
self
.
hash
...
@@ -708,11 +721,14 @@ class CLinker(link.Linker):
...
@@ -708,11 +721,14 @@ class CLinker(link.Linker):
instantiate
.
customize
.
add_library
(
lib
)
instantiate
.
customize
.
add_library
(
lib
)
mod
.
add_function
(
instantiate
)
mod
.
add_function
(
instantiate
)
#mod.compile(location = compile_dir())
mod
.
compile
(
location
=
get_compiledir
())
mod
.
compile
(
location
=
get_compiledir
())
module
=
__import__
(
"
%
s"
%
(
module_name
),
{},
{},
[
module_name
])
module
=
__import__
(
"
%
s"
%
(
module_name
),
{},
{},
[
module_name
])
self
.
instantiate
=
module
.
instantiate
self
.
instantiate
=
module
.
instantiate
else
:
else
:
# Eliminate duplicate inputs and outputs from the storage that we will pass to instantiate
# Eliminate duplicate inputs and outputs from the storage that we will pass to instantiate
out_storage
=
[
x
for
i
,
x
in
enumerate
(
out_storage
)
if
(
i
+
len
(
in_storage
))
not
in
self
.
dupidx
]
out_storage
=
[
x
for
i
,
x
in
enumerate
(
out_storage
)
if
(
i
+
len
(
in_storage
))
not
in
self
.
dupidx
]
...
@@ -724,6 +740,12 @@ class CLinker(link.Linker):
...
@@ -724,6 +740,12 @@ class CLinker(link.Linker):
ret
=
module
.
instantiate
(
error_storage
,
*
(
in_storage
+
out_storage
+
orphd
))
ret
=
module
.
instantiate
(
error_storage
,
*
(
in_storage
+
out_storage
+
orphd
))
#win pdb add 3 ref count, so we disable it by default.
#win pdb add 3 ref count, so we disable it by default.
#assert sys.getrefcount(ret) == 2 # refcount leak check
#assert sys.getrefcount(ret) == 2 # refcount leak check
except
:
release_lock
()
raise
release_lock
()
return
ret
return
ret
...
@@ -793,6 +815,10 @@ class OpWiseCLinker(link.LocalLinker):
...
@@ -793,6 +815,10 @@ class OpWiseCLinker(link.LocalLinker):
return
self
return
self
def
make_all
(
self
,
profiler
=
None
,
input_storage
=
None
,
output_storage
=
None
):
def
make_all
(
self
,
profiler
=
None
,
input_storage
=
None
,
output_storage
=
None
):
# Acquire lock on compilation directory.
get_lock
()
env
=
self
.
env
env
=
self
.
env
order
=
env
.
toposort
()
order
=
env
.
toposort
()
no_recycling
=
self
.
no_recycling
no_recycling
=
self
.
no_recycling
...
@@ -869,6 +895,9 @@ class OpWiseCLinker(link.LocalLinker):
...
@@ -869,6 +895,9 @@ class OpWiseCLinker(link.LocalLinker):
f
.
allow_gc
=
self
.
allow_gc
f
.
allow_gc
=
self
.
allow_gc
# Release lock on compilation directory.
release_lock
()
return
f
,
[
link
.
Container
(
input
,
storage
)
for
input
,
storage
in
zip
(
env
.
inputs
,
input_storage
)],
\
return
f
,
[
link
.
Container
(
input
,
storage
)
for
input
,
storage
in
zip
(
env
.
inputs
,
input_storage
)],
\
[
link
.
Container
(
output
,
storage
,
True
)
for
output
,
storage
in
zip
(
env
.
outputs
,
output_storage
)],
\
[
link
.
Container
(
output
,
storage
,
True
)
for
output
,
storage
in
zip
(
env
.
outputs
,
output_storage
)],
\
thunks
,
order
thunks
,
order
...
@@ -960,8 +989,3 @@ class DualLinker(link.Linker):
...
@@ -960,8 +989,3 @@ class DualLinker(link.Linker):
return
f
,
i1
,
o1
return
f
,
i1
,
o1
theano/gof/cutils.py
浏览文件 @
964dbdd7
from
compiledir
import
*
from
compiledir
import
*
from
compilelock
import
get_lock
,
release_lock
import
sys
import
sys
...
@@ -30,8 +31,14 @@ except ImportError:
...
@@ -30,8 +31,14 @@ except ImportError:
cthunk
=
object
()
cthunk
=
object
()
mod
=
weave
.
ext_tools
.
ext_module
(
'cutils_ext'
)
mod
=
weave
.
ext_tools
.
ext_module
(
'cutils_ext'
)
fun
=
weave
.
ext_tools
.
ext_function
(
'run_cthunk'
,
single_runner
,
[
'cthunk'
])
fun
=
weave
.
ext_tools
.
ext_function
(
'run_cthunk'
,
single_runner
,
[
'cthunk'
])
fun
.
customize
.
add_extra_compile_arg
(
'--permissive'
)
fun
.
customize
.
add_extra_compile_arg
(
'--permissive'
)
mod
.
add_function
(
fun
)
mod
.
add_function
(
fun
)
get_lock
()
try
:
mod
.
compile
(
location
=
get_compiledir
())
mod
.
compile
(
location
=
get_compiledir
())
except
:
release_lock
()
raise
release_lock
()
from
cutils_ext
import
*
from
cutils_ext
import
*
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论