示例#1
0
文件: nvvm.py 项目: genba/numba
def set_cuda_kernel(lfunc):
    from llvm.core import MetaData, MetaDataString, Constant, Type

    m = lfunc.module

    ops = lfunc, MetaDataString.get(m, "kernel"), Constant.int(Type.int(), 1)
    md = MetaData.get(m, ops)

    nmd = m.get_or_insert_named_metadata('nvvm.annotations')
    nmd.add(md)
示例#2
0
文件: nvvm.py 项目: B-Rich/numba
def set_cuda_kernel(lfunc):
    from llvm.core import MetaData, MetaDataString, Constant, Type

    m = lfunc.module

    ops = lfunc, MetaDataString.get(m, "kernel"), Constant.int(Type.int(), 1)
    md = MetaData.get(m, ops)

    nmd = m.get_or_insert_named_metadata('nvvm.annotations')
    nmd.add(md)
示例#3
0
 def test_metadata(self):
     m = Module.new("a")
     t = Type.int()
     metadata = MetaData.get(m, [Constant.int(t, 100), MetaDataString.get(m, "abcdef"), None])
     MetaData.add_named_operand(m, "foo", metadata)
     self.assertEqual(MetaData.get_named_operands(m, "foo"), [metadata])
     self.assertEqual(MetaData.get_named_operands(m, "bar"), [])
     self.assertEqual(len(metadata.operands), 3)
     self.assertEqual(metadata.operands[0].z_ext_value, 100)
     self.assertEqual(metadata.operands[1].string, "abcdef")
     self.assertTrue(metadata.operands[2] is None)
示例#4
0
 def test_metadata(self):
     m = Module.new('a')
     t = Type.int()
     metadata = MetaData.get(
         m, [Constant.int(t, 100),
             MetaDataString.get(m, 'abcdef'), None])
     MetaData.add_named_operand(m, 'foo', metadata)
     self.assertEqual(MetaData.get_named_operands(m, 'foo'), [metadata])
     self.assertEqual(MetaData.get_named_operands(m, 'bar'), [])
     self.assertEqual(len(metadata.operands), 3)
     self.assertEqual(metadata.operands[0].z_ext_value, 100)
     self.assertEqual(metadata.operands[1].string, 'abcdef')
     self.assertTrue(metadata.operands[2] is None)