Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import os
- import time
- from platform import architecture
- from imp import find_module
- timeformat = '%H:%M:%S'
- def getTimestamp():
- return '[%s] ' % time.strftime(timeformat, time.localtime(time.time()))
- def log(message):
- print getTimestamp() + str(message)
- def getPythonVersion():
- info = sys.version_info
- return str(info[0]) + '.' + str(info[1]) + '.' + str(info[2])
- def getPyOpenCLPath():
- try:
- file, pathname, descr = find_module('pyopencl')
- except:
- pathname = 'Not found'
- return str(pathname)
- def getBoostVersion(input):
- try:
- contents = os.listdir(input)
- except:
- return 'Not Found'
- for i in range(len(contents)):
- if 'boost_python' in contents[i].lower():
- return contents[i]
- return 'Not Found'
- path = getPyOpenCLPath()
- #Display global information
- log('Python OpenCL Info v0.1')
- log('Python Version: ' + getPythonVersion() + ' ' + architecture()[0])
- log('PyOpenCL Path: ' + path)
- log('Boost Python Version: ' + getBoostVersion(path))
- #Check for PyOpenCL not found
- if path == 'Not Found':
- log('Exiting')
- sys.exit()
- #Now we try to import PyOpenCL
- # THIS IS WHERE THE FAILURE OCCURS !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- import pyopencl
- import pyopencl.version
- #Continue printing
- log('PyOpenCL Version: ' + pyopencl.VERSION_TEXT)
- #get platfroms
- try:
- platforms = pyopencl.get_platforms()
- except:
- log('Stupid bug')
- # If no platforms exist then no OpenCL supporting devices are present
- if len(platforms) == 0:
- log('No OpenCL platforms found!')
- sys.exit()
- log('Listing platforms and devices:')
- count = 0
- # Iterate through platforms
- for i,p in enumerate(platforms):
- # Display platform
- log('')
- log('[cl:' + str(i) + '] ' + p.name.replace('\x00','').strip())
- # Get devices
- devices = platforms[i].get_devices()
- # Make sure we don't callback for a platform if no devices found
- if len(devices) > 0:
- # Iterate through devices
- for j,d in enumerate(devices):
- count += 1
- log(' [cl:' + str(i) + ':' + str(j) + '] ' + d.name.replace('\x00','').strip())
- log('')
- log('This program will exit in 300 seconds...')
- time.sleep(300)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement