driver.py 967 Bytes
Newer Older
dugupeiwen's avatar
dugupeiwen committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
Most of the driver API is unsupported in the simulator, but some stubs are
provided to allow tests to import correctly.
'''


def device_memset(dst, val, size, stream=0):
    dst.view('u1')[:size].fill(bytes([val])[0])


def host_to_device(dst, src, size, stream=0):
    dst.view('u1')[:size] = src.view('u1')[:size]


def device_to_host(dst, src, size, stream=0):
    host_to_device(dst, src, size)


def device_memory_size(obj):
    return obj.itemsize * obj.size


def device_to_device(dst, src, size, stream=0):
    host_to_device(dst, src, size)


class FakeDriver(object):
    def get_device_count(self):
        return 1


driver = FakeDriver()

Linker = None


class LinkerError(RuntimeError):
    pass


class NvrtcError(RuntimeError):
    pass


class CudaAPIError(RuntimeError):
    pass


def launch_kernel(*args, **kwargs):
    msg = 'Launching kernels directly is not supported in the simulator'
    raise RuntimeError(msg)


USE_NV_BINDING = False