?Code by jupyter on the PyCharm at the AMD platform
import pyopencl as cl
# get all platform on your computer
platforms = cl.get_platforms()
for platform in platforms:
# print platform
print(platform)
# print platform's name
print(platform.name)
#%%
# version of OpenCL Header
version = cl.get_cl_header_version()
print(version)
#%%
# create context with specified platform
# answers is the index of platform
# platform is in the range of platforms = cl.get_platforms()
ctx = cl.create_some_context(answers=[1])
ctx
#%%
# all devices on specified platform
ctx.devices
#%%
# the number of devices on the platform
ctx.num_devices
#%%
import pyopencl.characterize.performance as perf
prof_overhead, latency = perf.get_profiling_overhead(ctx)
# command latency:命令延迟
print("command latency: %g s" % latency)
#%%
#%%
import pyopencl as cl
#%%
# see platforms and devices on the computer
platforms = cl.get_platforms()
for platform in platforms:
devices = platform.get_devices()
print("Platform {} has {} devices".format(platform.name,len(devices)))
for device in devices:
print(device.name)
|