示例#1
0
    def test_ptx(self):
        if le.initialize_target('PTX', noraise=True):
            arch = 'ptx64'
        elif le.initialize_target('NVPTX', noraise=True):
            arch = 'nvptx64'
        else:
            return # skip this test

        print(arch)
        m, func = self._build_module()
        func.calling_convention = lc.CC_PTX_KERNEL # set calling conv
        ptxtm = le.TargetMachine.lookup(arch=arch, cpu='sm_20')
        self.assertTrue(ptxtm.triple)
        self.assertTrue(ptxtm.cpu)
        ptxasm = ptxtm.emit_assembly(m)
        self.assertIn('foo', ptxasm)
        if arch == 'nvptx64':
            self.assertIn('.address_size 64', ptxasm)
        self.assertIn('sm_20', ptxasm)
示例#2
0
import unittest
import llvm.core as lc
import llvm.ee as le
from llvm.core import Type, Builder
from .support import TestCase, tests, skip_if

# Check PTX backend
if le.initialize_target('PTX', noraise=True):
    PTX_ARCH = 'ptx64'
elif le.initialize_target('NVPTX', noraise=True):
    PTX_ARCH = 'nvptx64'
else:
    PTX_ARCH = None


class TestTargetMachines(TestCase):
    '''Exercise target machines

    Require PTX backend
    '''
    def test_native(self):
        m, _ = self._build_module()
        tm = le.EngineBuilder.new(m).select_target()

        self.assertTrue(tm.target_name)
        self.assertTrue(tm.target_data)
        self.assertTrue(tm.target_short_description)
        self.assertTrue(tm.triple)
        self.assertIn('foo', tm.emit_assembly(m))
        self.assertTrue(le.get_host_cpu_name())
示例#3
0
import unittest
import llvm.core as lc
import llvm.ee as le
from llvm.core import Type, Builder
from .support import TestCase, tests, skip_if

# Check PTX backend
if le.initialize_target('PTX', noraise=True):
    PTX_ARCH = 'ptx64'
elif le.initialize_target('NVPTX', noraise=True):
    PTX_ARCH = 'nvptx64'
else:
    PTX_ARCH = None

class TestTargetMachines(TestCase):
    '''Exercise target machines

    Require PTX backend
    '''
    def test_native(self):
        m, _ = self._build_module()
        tm = le.EngineBuilder.new(m).select_target()

        self.assertTrue(tm.target_name)
        self.assertTrue(tm.target_data)
        self.assertTrue(tm.target_short_description)
        self.assertTrue(tm.triple)
        self.assertIn('foo', tm.emit_assembly(m))
        self.assertTrue(le.get_host_cpu_name())

    @skip_if(not PTX_ARCH, msg='LLVM is not compiled with PTX enabled')