Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
06fd2dc0
提交
06fd2dc0
authored
2月 28, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Automatically add the equivalent of the --march=native flags.
It is done in a safe way if we share the compiledir.
上级
1878c88d
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
63 行增加
和
2 行删除
+63
-2
faq.txt
doc/tutorial/faq.txt
+9
-2
cmodule.py
theano/gof/cmodule.py
+54
-0
没有找到文件。
doc/tutorial/faq.txt
浏览文件 @
06fd2dc0
...
...
@@ -26,10 +26,17 @@ Faster gcc optimization
You can enable faster gcc optimization with the ``cxxflags``. This list of flags was suggested on the mailing list::
cxxflags=-march=native
-O3 -ffast-math -ftree-loop-distribution -funroll-loops -ftracer
-O3 -ffast-math -ftree-loop-distribution -funroll-loops -ftracer
Use it at your own risk. Some people warned that the ``-ftree-loop-distribution`` optimization resulted in wrong results in the past.
Also the ``-march=native`` flag must be used with care if you have NFS. In that case, you MUST set the compiledir to a local path of the computer.
In the past we told that if the ``compiledir`` wasn't shared by multiple
computers, you could add the ``-march=native`` flags. Now we recommande
to remove this flags as Theano does that automatically and safelly
even if the ``compiledir`` is shared by multiple computers with different
CPU. In fact, we ask g++ what are the equivalent flags it use and use
them directly.
Faster Theano function
----------------------
...
...
theano/gof/cmodule.py
浏览文件 @
06fd2dc0
...
...
@@ -1482,6 +1482,60 @@ class GCC_compiler(object):
@staticmethod
def
compile_args
():
cxxflags
=
[
flag
for
flag
in
config
.
gcc
.
cxxflags
.
split
(
' '
)
if
flag
]
# Add the equivalent of -march=native flag. We can't use
# -march=native as if the compiledir is shared by multiple
# computers (for example, if the home directory is on NFS), this
# won't be optimum or cause crash depending if the file is compiled
# on an older or more recent computer.
# Those URL discuss how to find witch flags are used by -march=native.
#http://en.gentoo-wiki.com/wiki/Safe_Cflags#-march.3Dnative
#http://en.gentoo-wiki.com/wiki/Hardware_CFLAGS
add_march
=
True
#We will add it ourself in a safe way, so remove them.
if
'-march=native'
in
cxxflags
:
cxxflags
.
remove
(
'-march=native'
)
if
'--march=native'
in
cxxflags
:
cxxflags
.
remove
(
'--march=native'
)
for
f
in
cxxflags
:
#If the user specify an -march=X parameter, don't add one ourself
if
((
f
.
startswith
(
"--march="
)
or
f
.
startswith
(
"-march="
))):
print
(
"WARNING: your Theano flags `gcc.cxxflags` specify an"
" `-march=X` flags that isn't `-march=native`"
)
print
(
" It is better to let Theano/g++ find it "
"automatically, but we don't do it now"
)
add_march
=
False
if
add_march
:
def
get_lines
(
cmd
):
p
=
call_subprocess_Popen
(
cmd
,
stderr
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
shell
=
True
)
p
.
wait
()
stdout
=
p
.
stdout
.
readlines
()
stderr
=
p
.
stderr
.
readlines
()
lines
=
[]
for
line
in
stdout
+
stderr
:
if
"march"
in
line
:
lines
.
append
(
line
.
strip
())
return
lines
native_lines
=
get_lines
(
"gcc -march=native -E -v - </dev/null"
)
assert
len
(
native_lines
)
==
1
default_lines
=
get_lines
(
"gcc -E -v - </dev/null"
)
assert
len
(
default_lines
)
>
1
part
=
native_lines
[
0
]
.
split
()
for
line
in
default_lines
:
if
line
.
startswith
(
part
[
0
]):
part2
=
[
p
for
p
in
line
.
split
()
if
not
'march'
in
p
and
not
'mtune'
in
p
]
new_flags
=
[
p
for
p
in
part
if
p
not
in
part2
]
cxxflags
.
extend
(
new_flags
)
break
#NumPy 1.7 Deprecate the old API. I updated most of the places
#to use the new API, but not everywhere. When finished, enable
#the following macro to assert that we don't bring new code
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论