Add arch as compiler option

This commit is contained in:
Steven Robertson 2012-05-20 12:53:23 -07:00
parent 7c0d86b929
commit 805742d4ce

View File

@ -80,7 +80,8 @@ def assemble_code(*libs):
DEFAULT_CMP_OPTIONS = ('-use_fast_math', '-maxrregcount', '42')
DEFAULT_SAVE_KERNEL = True
def compile(name, src, opts=DEFAULT_CMP_OPTIONS, save=DEFAULT_SAVE_KERNEL):
def compile(name, src, opts=DEFAULT_CMP_OPTIONS, save=DEFAULT_SAVE_KERNEL,
arch=None):
"""
Compile a module. Returns a copy of the source (for inspection or
display) and the compiled cubin.
@ -89,7 +90,7 @@ def compile(name, src, opts=DEFAULT_CMP_OPTIONS, save=DEFAULT_SAVE_KERNEL):
if save:
with open(os.path.join(dir, name + '_kern.cu'), 'w') as fp:
fp.write(src)
cubin = pycuda.compiler.compile(src, options=list(opts))
cubin = pycuda.compiler.compile(src, options=list(opts), arch=arch)
if save:
with open(os.path.join(dir, name + '_kern.cubin'), 'w') as fp:
fp.write(cubin)