Skip to content
This repository was archived by the owner on Jan 25, 2023. It is now read-only.

Commit 2add24b

Browse files
author
Deb, Diptorup
committed
Merge branch 'rhoque/update/dppl_api_unit_test' into 'devel'
Added unit test to check dppl apis See merge request mlp-python/Numba-PyDPPL!82
2 parents bc6656e + 7d44454 commit 2add24b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from __future__ import print_function, division, absolute_import
2+
3+
import numpy as np
4+
5+
from numba.dppl.testing import unittest
6+
from numba.dppl.testing import DPPLTestCase
7+
import dppl.ocldrv as ocldrv
8+
9+
10+
@unittest.skipUnless(ocldrv.has_gpu_device, 'test only on GPU system')
11+
class TestPYDPPLAPI(DPPLTestCase):
12+
def test_pydppl_api(self):
13+
A = np.array(np.random.random(10), dtype=np.float32)
14+
with ocldrv.igpu_context(0) as device_env:
15+
# DeviceEnv APIs
16+
dA = device_env.copy_array_to_device(A)
17+
18+
device_env.copy_array_from_device(dA)
19+
20+
dB = device_env.create_device_array(A) # A is given here as meta-data
21+
22+
device_env.dump()
23+
24+
max_work_group_size = device_env.get_max_work_group_size()
25+
max_work_item_dims = device_env.get_max_work_item_dims()
26+
27+
28+
# DeviceArray APIs
29+
self.assertTrue(hex(id(A)) == hex(id(dA.get_ndarray())))
30+
31+
if __name__ == '__main__':
32+
unittest.main()

0 commit comments

Comments
 (0)