File: info_opencl.py

package info (click to toggle)
python-xrt 1.6.0%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 17,572 kB
  • sloc: python: 59,424; xml: 4,786; lisp: 4,082; sh: 22; javascript: 18; makefile: 17
file content (38 lines) | stat: -rw-r--r-- 1,670 bytes parent folder | download | duplicates (2)
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
import pyopencl as cl  # Import the OpenCL GPU computing API

print('\n' + '=' * 60 + '\nOpenCL Platforms and Devices')
for platform in cl.get_platforms():  # Print each platform on this computer
    print('=' * 60)
    print('Platform - Name:  ' + platform.name)
    print('Platform - Vendor:  ' + platform.vendor)
    print('Platform - Version:  ' + platform.version)
    print('Platform - Extensions:  ' + platform.extensions)
    print('Platform - Profile:  ' + platform.profile)
    for device in platform.get_devices():  # Print each device per-platform
        print('    ' + '-' * 56)
        print('    Device - Name:  ' + device.name)
        print('    Device - Vendor:  ' + device.vendor)
        print('    Device - Type:  ' +
              cl.device_type.to_string(device.type, "%d"))
        print('    Device - Max Clock Speed:  {0} Mhz'.format(
            device.max_clock_frequency))
        print('    Device - Compute Units:  {0}'.format(
            device.max_compute_units))
        print('    Device - Local Memory:  {0:.0f} KB'.format(
            device.local_mem_size/1024))
        print('    Device - Constant Memory:  {0:.0f} KB'.format(
            device.max_constant_buffer_size/1024))
        print('    Device - Global Memory: {0:.0f} GB'.format(
            device.global_mem_size/1073741824.0))
        print('    Device - FP:  ' + str(device.double_fp_config))
print('\n')

#ctx = cl.create_some_context()

#test your iPlatform, iDevice here. Read the output. Is it your GPU?
iPlatform, iDevice = 0, 0
platform = cl.get_platforms()[iPlatform]
device = platform.get_devices()[iDevice]
ctx = cl.Context(devices=[device])

print(ctx)