Exemple #1
0
    def test(self):
        from nitrous.module import jit_module

        @function(Long, a=Long, b=Long)
        def add(a, b):
            return a + b

        m = jit_module([add])

        self.assertEqual(m.add(3, 7), 10)
Exemple #2
0
    def test(self):
        from nitrous.module import jit_module

        @function(Long, a=Long, b=Long)
        def add(a, b):
            return a + b

        m = jit_module([add])

        self.assertEqual(m.add(3, 7), 10)
Exemple #3
0
    def test_run(self):
        from nitrous.module import jit_module, so_module
        from nitrous.function import function, c_function
        from nitrous.types import Float

        axpy = c_function("axpy", Float, [Float, Float, Float])
        multiply = c_function("multiply", Float, [Float, Float])

        @function(Float, a=Float, b=Float, c=Float)
        def foo(a, b, c):
            return axpy(a, b, c) + multiply(a, c)

        a, b, c = 11, 23, 7
        ref = (a * b + c) + a * c

        jit_m = jit_module([foo], libs=[self.lib])
        self.assertEqual(jit_m.foo(a, b, c), ref)

        so_m = so_module([foo], libs=[self.lib])
        self.assertEqual(so_m.foo(a, b, c), ref)
Exemple #4
0
    def test_run(self):
        from nitrous.module import jit_module, so_module
        from nitrous.function import function, c_function
        from nitrous.types import Float

        axpy = c_function("axpy", Float, [Float, Float, Float])
        multiply = c_function("multiply", Float, [Float, Float])

        @function(Float, a=Float, b=Float, c=Float)
        def foo(a, b, c):
            return axpy(a, b, c) + multiply(a, c)

        a, b, c = 11, 23, 7
        ref = (a * b + c) + a * c

        jit_m = jit_module([foo], libs=[self.lib])
        self.assertEqual(jit_m.foo(a, b, c), ref)

        so_m = so_module([foo], libs=[self.lib])
        self.assertEqual(so_m.foo(a, b, c), ref)