Exemple #1
0
    def test_atomic_add3(self):
        ary = np.random.randint(0, 32, size=32).astype(np.uint32).reshape(4, 8)
        orig = ary.copy()
        hsa_atomic_add3 = hsa.jit('void(uint32[:,:])')(atomic_add3)
        hsa_atomic_add3[1, (4, 8)](ary)

        self.assertTrue(np.all(ary == orig + 1))
Exemple #2
0
    def test_atomic_add3(self):
        ary = np.random.randint(0, 32, size=32).astype(np.uint32).reshape(4, 8)
        orig = ary.copy()
        hsa_atomic_add3 = hsa.jit('void(uint32[:,:])')(atomic_add3)
        hsa_atomic_add3[1, (4, 8)](ary)

        self.assertTrue(np.all(ary == orig + 1))
Exemple #3
0
    def test_atomic_add(self):
        ary = np.random.randint(0, 32, size=32).astype(np.uint32)
        orig = ary.copy()
        hsa_atomic_add = hsa.jit('void(uint32[:])')(atomic_add)
        hsa_atomic_add[1, 32](ary)

        gold = np.zeros(32, dtype=np.uint32)
        for i in range(orig.size):
            gold[orig[i]] += 1

        self.assertTrue(np.all(ary == gold))
Exemple #4
0
    def test_atomic_add(self):
        ary = np.random.randint(0, 32, size=32).astype(np.uint32)
        orig = ary.copy()
        hsa_atomic_add = hsa.jit('void(uint32[:])')(atomic_add)
        hsa_atomic_add[1, 32](ary)

        gold = np.zeros(32, dtype=np.uint32)
        for i in range(orig.size):
            gold[orig[i]] += 1

        self.assertTrue(np.all(ary == gold))
 def test_autojit_kernel(self):
     kernel = hsa.jit(copy_kernel)
     inp = np.arange(10)
     out = np.zeros_like(inp)
     kernel.forall(out.size)(out, inp)
     np.testing.assert_equal(inp, out)
Exemple #6
0
 def _compile_kernel(self, fnobj, sig):
     return hsa.jit(sig)(fnobj)
Exemple #7
0
 def _compile_core(self, sig):
     hsadevfn = hsa.jit(sig, device=True)(self.pyfunc)
     return hsadevfn, hsadevfn.cres.signature.return_type
Exemple #8
0
 def _get_globals(self, sig):
     corefn = hsa.jit(sig, device=True)(self.pyfunc)
     glbls = self.py_func.__globals__.copy()
     glbls.update({'__hsa__': hsa,
                   '__core__': corefn})
     return glbls
Exemple #9
0
 def _compile_kernel(self, fnobj, sig):
     return hsa.jit(sig)(fnobj)
Exemple #10
0
 def _compile_core(self, sig):
     hsadevfn = hsa.jit(sig, device=True)(self.pyfunc)
     return hsadevfn, hsadevfn.cres.signature.return_type
Exemple #11
0
 def _get_globals(self, sig):
     corefn = hsa.jit(sig, device=True)(self.pyfunc)
     glbls = self.py_func.__globals__.copy()
     glbls.update({'__hsa__': hsa,
                   '__core__': corefn})
     return glbls