Skip to content

Commit

Permalink
Merge pull request #6567 from testhound/testhound/refactor_llvm_replace
Browse files Browse the repository at this point in the history
Refactor llvm replacement code into separate function
  • Loading branch information
sklam committed Jan 12, 2021
2 parents 4e2d6d2 + 92d93af commit 24764ad
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions numba/cuda/cudadrv/nvvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,19 +514,10 @@ def _replace_datalayout(llvmir):
return '\n'.join(lines)


def llvm_to_ptx(llvmir, **opts):
if opts.pop('fastmath', False):
opts.update({
'ftz': True,
'fma': True,
'prec_div': False,
'prec_sqrt': False,
})

cu = CompilationUnit()
libdevice = LibDevice(arch=opts.get('arch', 'compute_20'))
# New LLVM generate a shorthand for datalayout that NVVM does not know
def llvm_replace(llvmir):
#New LLVM generate a shorthand for datalayout that NVVM does not know
llvmir = _replace_datalayout(llvmir)

# Replace with our cmpxchg and atomic implementations because LLVM 3.5 has
# a new semantic for cmpxchg.
replacements = [
Expand Down Expand Up @@ -588,6 +579,23 @@ def llvm_to_ptx(llvmir, **opts):
llvmir = llvmir.replace('llvm.numba_nvvm.atomic', 'llvm.nvvm.atomic')

llvmir = llvm39_to_34_ir(llvmir)

return llvmir


def llvm_to_ptx(llvmir, **opts):
if opts.pop('fastmath', False):
opts.update({
'ftz': True,
'fma': True,
'prec_div': False,
'prec_sqrt': False,
})

cu = CompilationUnit()
libdevice = LibDevice(arch=opts.get('arch', 'compute_20'))

llvmir = llvm_replace(llvmir)
cu.add_module(llvmir.encode('utf8'))
cu.add_module(libdevice.get())

Expand Down

0 comments on commit 24764ad

Please sign in to comment.