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

add the g++ and nvcc compiler string in the hash of the module.

上级 1b3170e9
...@@ -989,11 +989,12 @@ class CLinker(link.Linker): ...@@ -989,11 +989,12 @@ class CLinker(link.Linker):
compile_args=self.compile_args(), compile_args=self.compile_args(),
libraries=self.libraries(), libraries=self.libraries(),
header_dirs=self.header_dirs(), header_dirs=self.header_dirs(),
c_compiler=self.c_compiler(),
) )
@staticmethod @staticmethod
def cmodule_key_(env, no_recycling, compile_args=None, libraries=None, def cmodule_key_(env, no_recycling, compile_args=None, libraries=None,
header_dirs=None, insert_config_md5=True): header_dirs=None, insert_config_md5=True, c_compiler=None):
""" """
Do the actual computation of cmodule_key in a static method Do the actual computation of cmodule_key in a static method
to allow it to be reused in scalar.Composite.__eq__ to allow it to be reused in scalar.Composite.__eq__
...@@ -1039,6 +1040,8 @@ class CLinker(link.Linker): ...@@ -1039,6 +1040,8 @@ class CLinker(link.Linker):
# DynamicModule always add the include <numpy/arrayobject.h> # DynamicModule always add the include <numpy/arrayobject.h>
sig.append('NPY_ABI_VERSION=0x%X' % sig.append('NPY_ABI_VERSION=0x%X' %
numpy.core.multiarray._get_ndarray_c_version()) numpy.core.multiarray._get_ndarray_c_version())
if c_compiler:
sig.append('c_compiler_str=' + c_compiler.version_str())
# IMPORTANT: The 'md5' prefix is used to isolate the compilation # IMPORTANT: The 'md5' prefix is used to isolate the compilation
# parameters from the rest of the key. If you want to add more key # parameters from the rest of the key. If you want to add more key
......
...@@ -348,7 +348,8 @@ def get_module_hash(src_code, key): ...@@ -348,7 +348,8 @@ def get_module_hash(src_code, key):
# This is the md5 hash of the config options. We can stop # This is the md5 hash of the config options. We can stop
# here. # here.
break break
elif key_element.startswith('NPY_ABI_VERSION=0x'): elif (key_element.startswith('NPY_ABI_VERSION=0x') or
key_element.startswith('c_compiler_str=')):
to_hash.append(key_element) to_hash.append(key_element)
else: else:
raise AssertionError(error_msg) raise AssertionError(error_msg)
...@@ -1430,6 +1431,10 @@ def gcc_version(): ...@@ -1430,6 +1431,10 @@ def gcc_version():
class GCC_compiler(object): class GCC_compiler(object):
@staticmethod
def version_str():
return "g++ " + gcc_version_str
@staticmethod @staticmethod
def compile_args(): def compile_args():
cxxflags = [flag for flag in config.gcc.cxxflags.split(' ') if flag] cxxflags = [flag for flag in config.gcc.cxxflags.split(' ') if flag]
......
...@@ -119,6 +119,7 @@ def cleanup(): ...@@ -119,6 +119,7 @@ def cleanup():
1) keys that have an ndarray in them. 1) keys that have an ndarray in them.
Now we use a hash in the keys of the constant data. Now we use a hash in the keys of the constant data.
2) key that don't have the numpy ABI version in them 2) key that don't have the numpy ABI version in them
3) They do not have a compile version string
If there is no key left for a compiled module, we delete the module. If there is no key left for a compiled module, we delete the module.
""" """
...@@ -134,15 +135,18 @@ def cleanup(): ...@@ -134,15 +135,18 @@ def cleanup():
keydata = cPickle.load(file) keydata = cPickle.load(file)
for key in list(keydata.keys): for key in list(keydata.keys):
have_npy_abi_version = False have_npy_abi_version = False
have_c_compiler = False
for obj in flatten(key): for obj in flatten(key):
if isinstance(obj, numpy.ndarray): if isinstance(obj, numpy.ndarray):
keydata.remove_key(key) keydata.remove_key(key)
break break
if (isinstance(obj, basestring) and elif isinstance(obj, basestring):
obj.startswith('NPY_ABI_VERSION=0x')): if obj.startswith('NPY_ABI_VERSION=0x'):
have_npy_abi_version = True have_npy_abi_version = True
elif obj.startswith('c_compiler_str='):
have_c_compiler = True
if not have_npy_abi_version: if not have_npy_abi_version or not have_c_compiler:
keydata.remove_key(key) keydata.remove_key(key)
if len(keydata.keys) == 0: if len(keydata.keys) == 0:
shutil.rmtree(os.path.join(compiledir, directory)) shutil.rmtree(os.path.join(compiledir, directory))
......
...@@ -75,6 +75,10 @@ def add_standard_rpath(rpath): ...@@ -75,6 +75,10 @@ def add_standard_rpath(rpath):
class NVCC_compiler(object): class NVCC_compiler(object):
@staticmethod
def version_str():
return "nvcc " + nvcc_version
@staticmethod @staticmethod
def compile_args(): def compile_args():
""" """
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论