提交 a73dd646 authored 作者: Frederic's avatar Frederic

use a tempfile to test if the compiler support openmp.

上级 492b9dc4
...@@ -7,6 +7,7 @@ This is needed as we need to have parsed the previous ...@@ -7,6 +7,7 @@ This is needed as we need to have parsed the previous
import os import os
import logging import logging
import subprocess import subprocess
import tempfile
import theano import theano
from theano.configparser import ( from theano.configparser import (
...@@ -63,16 +64,19 @@ int main( int argc, const char* argv[] ) ...@@ -63,16 +64,19 @@ int main( int argc, const char* argv[] )
} }
} }
""" """
p = os.path.join(config.compiledir, 'test_omp.c') fd, path = tempfile.mkstemp(suffix='.c', prefix='test_omp_')
f = open(p, 'w') try:
f.write(code) os.write(fd, code)
f.close() os.close(fd)
p = subprocess.Popen(['g++', '-fopenmp', p], stdout=subprocess.PIPE, proc = subprocess.Popen(['g++', '-fopenmp', path],
stderr=subprocess.PIPE, stdout=subprocess.PIPE,
stdin=dummy_stdin.fileno()) stderr=subprocess.PIPE,
p.wait() stdin=dummy_stdin.fileno())
if p.returncode != 0: proc.wait()
default_openmp = False if proc.returncode != 0:
default_openmp = False
finally:
os.remove(path)
except OSError, e: except OSError, e:
default_openmp = False default_openmp = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论