提交 1e727604 authored 作者: Frederic's avatar Frederic

Change an assert to a warning and disable the functionality.

This was breaking Theano on briaree I also changed the parsing to make it work with g++ 4.4.4 4.5.1 4.6.3
上级 c58fd8c8
...@@ -1511,7 +1511,7 @@ class GCC_compiler(object): ...@@ -1511,7 +1511,7 @@ class GCC_compiler(object):
if detect_march: if detect_march:
GCC_compiler.march_flags = [] GCC_compiler.march_flags = []
def get_lines(cmd): def get_lines(cmd, parse=True):
p = call_subprocess_Popen(cmd, p = call_subprocess_Popen(cmd,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True) stdout=subprocess.PIPE, shell=True)
...@@ -1519,10 +1519,17 @@ class GCC_compiler(object): ...@@ -1519,10 +1519,17 @@ class GCC_compiler(object):
stdout = p.stdout.readlines() stdout = p.stdout.readlines()
stderr = p.stderr.readlines() stderr = p.stderr.readlines()
lines = [] lines = []
for line in stdout + stderr: if parse:
if "-march=" in line and "-march=native" not in line: for line in stdout + stderr:
lines.append(line.strip()) if "COLLECT_GCC_OPTIONS=" in line:
lines = list(set(lines)) # to remove duplicate continue
elif "-march=" in line and "-march=native" not in line:
lines.append(line.strip())
elif "-mtune=" in line and "-march=native" not in line:
lines.append(line.strip())
lines = list(set(lines)) # to remove duplicate
else:
lines = stdout + stderr
return lines return lines
native_lines = get_lines("g++ -march=native -E -v - </dev/null") native_lines = get_lines("g++ -march=native -E -v - </dev/null")
...@@ -1538,17 +1545,27 @@ class GCC_compiler(object): ...@@ -1538,17 +1545,27 @@ class GCC_compiler(object):
else: else:
default_lines = get_lines("g++ -E -v - </dev/null") default_lines = get_lines("g++ -E -v - </dev/null")
_logger.info("g++ default lines: %s", default_lines) _logger.info("g++ default lines: %s", default_lines)
assert len(default_lines) > 1 if len(default_lines) < 1:
part = native_lines[0].split() _logger.warn(
for line in default_lines: "OPTIMIZATION WARNING: Theano was not able to find the"
if line.startswith(part[0]): " default g++ parameter. This is needed to tune"
part2 = [p for p in line.split() " the compilation to your specific"
if not 'march' in p and not 'mtune' in p] " CPU. This can slow down the execution of Theano"
new_flags = [p for p in part if p not in part2] " function. Can you submit the following lines to"
GCC_compiler.march_flags = new_flags " Theano's mailing list such that we fix this"
break " problem:\n %s",
_logger.info("g++ -march=native equivalent flags: %s", get_lines("g++ -E -v - </dev/null", parse=False))
GCC_compiler.march_flags) else:
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]
GCC_compiler.march_flags = new_flags
break
_logger.info("g++ -march=native equivalent flags: %s",
GCC_compiler.march_flags)
#Add the detected -march=native equivalent flags #Add the detected -march=native equivalent flags
cxxflags.extend(GCC_compiler.march_flags) cxxflags.extend(GCC_compiler.march_flags)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论