pyrqa/opencl.py
def create_environment_command_line(self):
        """ Create OpenCL environment from command line """
        platforms = cl.get_platforms()
        if platforms:
            platform_strings = []
            for platform_idx in np.arange(len(platforms)):
                platform_strings.append("[%d] %s" % (platform_idx, platforms[platform_idx]))

            platform_select = int(raw_input("\nAvailable platform(s):\n%s\n\nChoose platform, e.g., '0': " % "\n".join(platform_strings)))

            if platform_select not in np.arange(len(platforms)):
                raise OpenCLPlatformIndexOutOfBoundsException("Platform index '%d' is out of bounds." % platform_select)

            self.platform = platforms[platform_select]

            devices = self.platform.get_devices(cl.device_type.ALL)
            if devices:
                device_strings = []
                for device_idx in np.arange(len(devices)):
                    device_strings.append("[%d] %s" % (device_idx, devices[device_idx]))

                device_select = raw_input("\nAvailable device(s):\n%s\n\nChoose device(s), comma-separated, e.g., '0,1': " % "\n".join(device_strings))

                device_indices = [int(x) for x in device_select.split(',')]

                self.devices = []
                for device_idx in device_indices:
                    if device_idx not in np.arange(len(devices)):
                        raise OpenCLDeviceIndexOutOfBoundsException("Device index '%d' is out of bounds.")
                    else:
                        self.devices.append(devices[device_idx])

                self.create_contexts()
            else:
                raise NoOpenCLDeviceDetectedException("No OpenCL device was detected.")
        else:
            raise NoOpenCLPlatformDetectedException("No OpenCL platform was detected.")
 Create OpenCL environment from command line 
Create OpenCL environment from command line
Create OpenCL environment from command line
def create_environment_command_line(self):
        platforms = cl.get_platforms()
        if platforms:
            platform_strings = []
            for platform_idx in np.arange(len(platforms)):
                platform_strings.append("[%d] %s" % (platform_idx, platforms[platform_idx]))
            platform_select = int(raw_input("\nAvailable platform(s):\n%s\n\nChoose platform, e.g., '0': " % "\n".join(platform_strings)))
            if platform_select not in np.arange(len(platforms)):
                raise OpenCLPlatformIndexOutOfBoundsException("Platform index '%d' is out of bounds." % platform_select)
            self.platform = platforms[platform_select]
            devices = self.platform.get_devices(cl.device_type.ALL)
            if devices:
                device_strings = []
                for device_idx in np.arange(len(devices)):
                    device_strings.append("[%d] %s" % (device_idx, devices[device_idx]))
                device_select = raw_input("\nAvailable device(s):\n%s\n\nChoose device(s), comma-separated, e.g., '0,1': " % "\n".join(device_strings))
                device_indices = [int(x) for x in device_select.split(',')]
                self.devices = []
                for device_idx in device_indices:
                    if device_idx not in np.arange(len(devices)):
                        raise OpenCLDeviceIndexOutOfBoundsException("Device index '%d' is out of bounds.")
                    else:
                        self.devices.append(devices[device_idx])
                self.create_contexts()
            else:
                raise NoOpenCLDeviceDetectedException("No OpenCL device was detected.")
        else:
            raise NoOpenCLPlatformDetectedException("No OpenCL platform was detected.")
def create_environment_command_line ( self ) : platforms = cl . get_platforms ( ) if platforms : platform_strings = [ ] for platform_idx in np . arange ( len ( platforms ) ) : platform_strings . append ( "[%d] %s" % ( platform_idx , platforms [ platform_idx ] ) ) platform_select = int ( raw_input ( "\nAvailable platform(s):\n%s\n\nChoose platform, e.g., '0': " % "\n" . join ( platform_strings ) ) ) if platform_select not in np . arange ( len ( platforms ) ) : raise OpenCLPlatformIndexOutOfBoundsException ( "Platform index '%d' is out of bounds." % platform_select ) self . platform = platforms [ platform_select ] devices = self . platform . get_devices ( cl . device_type . ALL ) if devices : device_strings = [ ] for device_idx in np . arange ( len ( devices ) ) : device_strings . append ( "[%d] %s" % ( device_idx , devices [ device_idx ] ) ) device_select = raw_input ( "\nAvailable device(s):\n%s\n\nChoose device(s), comma-separated, e.g., '0,1': " % "\n" . join ( device_strings ) ) device_indices = [ int ( x ) for x in device_select . split ( ',' ) ] self . devices = [ ] for device_idx in device_indices : if device_idx not in np . arange ( len ( devices ) ) : raise OpenCLDeviceIndexOutOfBoundsException ( "Device index '%d' is out of bounds." ) else : self . devices . append ( devices [ device_idx ] ) self . create_contexts ( ) else : raise NoOpenCLDeviceDetectedException ( "No OpenCL device was detected." ) else : raise NoOpenCLPlatformDetectedException ( "No OpenCL platform was detected." )
Create OpenCL environment from command line
Create OpenCL environment from command line
""" Create OpenCL environment from command line """
self