-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfoCL.py
More file actions
75 lines (53 loc) · 2.25 KB
/
infoCL.py
File metadata and controls
75 lines (53 loc) · 2.25 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
global ErrorImportCL
import numpy as np
try:
import pyopencl as cl
ErrorImportCL = False
print("ErrorImportCL--------->", ErrorImportCL)
except ImportError:
ErrorImportCL = True
print("ErrorImportCL--------->", ErrorImportCL)
import copy
def importCL():
global ErrorImportCL
return not ErrorImportCL
def getPlatforms():
return cl.get_platforms()
def getPlatformsInfo():
for p in cl.get_platforms():
# Print out some information about the platforms
print("Platform:", p.name)
print("Vendor:", p.vendor)
print("Version:", p.version)
def getDevices():
return [device for platform in cl.get_platforms() for device in platform.get_devices()]
def getPlatformsAndDevices():
return [(platform, device) for platform in cl.get_platforms() for device in platform.get_devices()]
def getDevice(DEVICE):
try:
return [device for platform in cl.get_platforms()
for device in platform.get_devices()
if cl.device_type.to_string(device.type) == DEVICE]
except:
return cl.get_platforms()[0].get_devices()
def getDevicesName():
return [cl.device_type.to_string(device.type) for platform in cl.get_platforms()
for device in platform.get_devices()]
def getDevicesInfo():
for platform in cl.get_platforms():
for d in platform.get_devices():
print("\t-------------------------")
# Print out some information about the devices
print("\t\tName:", d.name)
print("\t\tVersion:", d.opencl_c_version)
print("\t\tMax. Compute Units:", d.max_compute_units)
print("\t\tLocal Memory Size:", d.local_mem_size / 1024, "KB")
print("\t\tGlobal Memory Size:", d.global_mem_size / (1024 * 1024), "MB")
print("\t\tMax Alloc Size:", d.max_mem_alloc_size / (1024 * 1024), "MB")
print("\t\tMax Work-group Size:", d.max_work_group_size)
# Find the maximum dimensions of the work-groups
dim = d.max_work_item_sizes
print("\t\tMax Work-item Dims:(", dim[0], " ".join(map(str, dim[1:])), ")")
print("\t-------------------------")
print(dim)
print("\n-------------------------")