• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyopencl.get_platforms函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyopencl.get_platforms函数的典型用法代码示例。如果您正苦于以下问题:Python get_platforms函数的具体用法?Python get_platforms怎么用?Python get_platforms使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_platforms函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pytest_generate_tests_for_pyopencl

def pytest_generate_tests_for_pyopencl(metafunc):
    class ContextGetter:
        def __init__(self, device):
            self.device = device

        def __call__(self):
            return cl.Context([device])

        def __str__(self):
            return "<context getter for %s>" % self.device
    if ("device" in metafunc.funcargnames
            or "ctx_getter" in metafunc.funcargnames):
        arg_dict = {}

        for platform in cl.get_platforms():
            if "platform" in metafunc.funcargnames:
                arg_dict["platform"] = platform

            for device in platform.get_devices():
                if "device" in metafunc.funcargnames:
                    arg_dict["device"] = device

                if "ctx_getter" in metafunc.funcargnames:
                    arg_dict["ctx_getter"] = ContextGetter(device)

                metafunc.addcall(funcargs=arg_dict.copy(),
                        id=", ".join("%s=%s" % (arg, value)
                                for arg, value in arg_dict.iteritems()))

    elif "platform" in metafunc.funcargnames:
        for platform in cl.get_platforms():
            metafunc.addcall(
                    funcargs=dict(platform=platform),
                    id=str(platform))
开发者ID:initcrash,项目名称:pyopencl,代码行数:34,代码来源:tools.py


示例2: __init__

    def __init__(self, cl_mode = True, cl_device = None):
        """Initialize the class.
        """
        if cl_mode:
            import pyopencl as cl
            import pyopencl.array
            if cl_device == 'gpu':
                gpu_devices = []
                for platform in cl.get_platforms():
                    try: gpu_devices += platform.get_devices(device_type=cl.device_type.GPU)
                    except: pass
                self.ctx = cl.Context(gpu_devices)
            elif cl_device == 'cpu':
                cpu_devices = []
                for platform in cl.get_platforms():
                    try: cpu_devices += platform.get_devices(device_type=cl.device_type.CPU)
                    except: pass
                self.ctx = cl.Context([cpu_devices[0]])
            else:
                self.ctx = cl.create_some_context()

            self.queue = cl.CommandQueue(self.ctx)
            self.mf = cl.mem_flags
            self.device = self.ctx.get_info(cl.context_info.DEVICES)[0]
            self.device_type = self.device.type
            self.device_compute_units = self.device.max_compute_units

        self.cl_mode = cl_mode
        self.obs = []
        self.samples = {}
开发者ID:tqian86,项目名称:MPBST,代码行数:30,代码来源:predictor.py


示例3: __init__

    def __init__(self, cl_mode=False, cl_device=None, sample_size=1000, cutoff=None,
                 output_to_stdout=False,
                 search=False, search_tolerance = 100, search_data_fit_only = False,
                 annealing = False, debug_mumble = False):
        """Initialize the class.
        """
        if debug_mumble:
            logging.basicConfig(level=logging.INFO)
        
        if cl_mode:
            import pyopencl as cl
            import pyopencl.array, pyopencl.tools, pyopencl.clrandom
            if cl_device == 'gpu':
                gpu_devices = []
                for platform in cl.get_platforms():
                    try: gpu_devices += platform.get_devices(device_type=cl.device_type.GPU)
                    except: pass
                self.ctx = cl.Context(gpu_devices)
            elif cl_device == 'cpu':
                cpu_devices = []
                for platform in cl.get_platforms():
                    try: cpu_devices += platform.get_devices(device_type=cl.device_type.CPU)
                    except: pass
                self.ctx = cl.Context([cpu_devices[0]])
            else:
                self.ctx = cl.create_some_context()

            self.queue = cl.CommandQueue(self.ctx)
            self.mf = cl.mem_flags
            self.device = self.ctx.get_info(cl.context_info.DEVICES)[0]
            self.device_type = self.device.type
            self.device_compute_units = self.device.max_compute_units

        self.cl_mode = cl_mode
        self.cutoff = cutoff
        self.data = []
        self.N = 0 # number of data points

        # sampling parameters
        self.sample_size = sample_size
        self.output_to_stdout = output_to_stdout
        self.iteration = 0
        self.thining = 1
        self.burnin = 0
        self.gpu_time = 0
        self.total_time = 0

        # stochastic search parameters
        self.best_sample = (None, None, None) # (sample, logprobability of model, loglikelihood of data)
        self.search = search
        self.search_data_fit_only = search_data_fit_only
        self.best_diff = []
        self.no_improv = 0
        self.search_tolerance = search_tolerance
       
        # annealing parameters, if used
        self.annealing = annealing
        self.annealing_temp = 1
        
        self.debug_mumble = debug_mumble
开发者ID:tqian86,项目名称:clsampler,代码行数:60,代码来源:__init__.py


示例4: __init__

	def __init__(self, gpuOnly=True, sharedGlContext=False, hidePlatformDetails=False):
		super(BaseCalculator, self).__init__()
		self.platform = cl.get_platforms()[0]
		self.devices = self.platform.get_devices()

		if not hidePlatformDetails:
			for platform in cl.get_platforms():
				for device in platform.get_devices():
					print("===============================================================")
					print("Platform name:", platform.name)
					print("Platform profile:", platform.profile)
					print("Platform vendor:", platform.vendor)
					print("Platform version:", platform.version)
					print("---------------------------------------------------------------")
					print("Device name:", device.name)
					print("Device type:", cl.device_type.to_string(device.type))
					print("Device memory: ", device.global_mem_size//1024//1024, 'MB')
					print("Device max clock speed:", device.max_clock_frequency, 'MHz')
					print("Device compute units:", device.max_compute_units)
					print("Device max work group size:", device.max_work_group_size)
					print("Device max work item sizes:", device.max_work_item_sizes)

		properties = None
		if sharedGlContext:
			assert cl.have_gl()
			properties = get_gl_sharing_context_properties()

		devices = self.devices
		if gpuOnly and len(self.devices) > 1:
			devices = [self.devices[1]]

		self.context = cl.Context(properties=properties, devices=devices)

		self.queue = None
开发者ID:keksnicoh,项目名称:gl_plotting_experimental,代码行数:34,代码来源:cl_handler.py


示例5: __getOpenClDevice

 def __getOpenClDevice(self, platformId, deviceId):
     if pyopencl is None:
         return None
     if not (0 <= platformId < len(pyopencl.get_platforms())):
         return None
     platform = pyopencl.get_platforms()[platformId]
     if not (0 <= deviceId < len(platform.get_devices())):
         return None
     return platform.get_devices()[deviceId]
开发者ID:kif,项目名称:pyFAI,代码行数:9,代码来源:OpenClDeviceLabel.py


示例6: __init__

  def __init__(self,threads=0,platform_directory_string="Platforms/OpenCLGPU/opencl_code/",root_directory_string="../../..",platform_name="",device_type=pyopencl.device_type.GPU):
    self.threads = threads
    self.platform_directory_string = platform_directory_string
    self.root_directory_string = root_directory_string
    
    self.platform_name = platform_name
    
    self.platform = None
    
    flag = False
    for p in pyopencl.get_platforms():
	for d in p.get_devices():
	  if(self.platform_name in str(p).lower() and d.get_info(pyopencl.device_info.TYPE)==device_type):
	    self.platform = p
	    self.device_type = device_type
	    flag = True
	    break
	
	if(flag): break
    
    if not(self.platform): #If the preferred platform isn't available, just take the first one with the preferred device type
      for p in pyopencl.get_platforms():
	for d in p.get_devices():
	  if(d.get_info(pyopencl.device_info.TYPE)==device_type):
	    self.platform = p
	    self.device_type = device_type
	    flag = True
	    break
	
	if(flag): break
	  
    if not(self.platform): #Failing that, just take the first one that has a CPU and use that
      for p in pyopencl.get_platforms():
	for d in p.get_devices():
	  if(d.get_info(pyopencl.device_info.TYPE)==pyopencl.device_type.CPU):
	    self.platform = p
	    self.device_type = pyopencl.device_type.CPU
	    flag = True
	    break
	
	if(flag): break
      
    self.platform_name = self.platform.get_info(pyopencl.platform_info.VENDOR)
    #if("Advanced Micro Devices" in self.platform_name): self.platform_name = self.platform.get_info(pyopencl.platform_info.NAME)
    self.device = self.platform.get_devices(self.device_type)[0] #Takes the first device available for the specified platform and type
    #except: #If the preferred device type isn't available, just take the first available CPU to that platform
      #self.device_type = pyopencl.device_type.CPU
      #self.device = self.platform.get_devices(pyopencl.device_type.CPU)[0]
    
    self.context = pyopencl.Context(devices=[self.device])
    
    self.amd_gpu_flag = False
    if((("AMD" in self.platform_name) and (self.device_type==pyopencl.device_type.GPU)) or self.amd_gpu_flag):
      self.cpu_device = self.platform.get_devices(pyopencl.device_type.CPU)[0] #Taking the first CPU available, needed for AMD GPUs
      self.cpu_context = pyopencl.Context(devices=[self.cpu_device])
      self.amd_gpu_flag = True
开发者ID:atavacron,项目名称:ForwardFinancialFramework,代码行数:56,代码来源:OpenCLGPU.py


示例7: compute

def compute(trans_matrix, config_vector, validapps, num_valid_apps):
	# computation
	device = cl.get_platforms()[1].get_devices()[0]
	# print device.max_work_item_sizes
	ctx = cl.Context([device])

	platform = cl.get_platforms()[1]
	device = platform.get_devices()[0]

	queue = cl.CommandQueue(ctx,
	        properties=cl.command_queue_properties.PROFILING_ENABLE)

	trans_np = np.array(trans_matrix, dtype = np.integer).flatten()
	config_vector_np = np.array(config_vector, dtype=np.integer)
	validapps_np = np.array(validapps, dtype=np.integer)
	result_config_vectors_np = np.empty(num_valid_apps * row).astype(np.integer)

	kernel = """

		__kernel void compute(__global int* trans_matrix, __global int* config_vector, __global int* validapps, __global int* result_config_vectors){

		int dot_result[COL_SIZE];
		int grpid = get_group_id(0);

		if(get_local_id(0) == 0) {
			for(int j = 0; j < COL_SIZE; j ++) {
				int sum = 0;
				for(int i = 0; i < ROW_SIZE; i ++) sum += validapps[grpid * ROW_SIZE + i] * trans_matrix[i * COL_SIZE + j];
				dot_result[j] = sum;
			}
			for(int i = 0; i < COL_SIZE; i ++) result_config_vectors[grpid * COL_SIZE + i] = config_vector[i] + dot_result[i];
		}
	} 
	"""
	mat_size = "#define MAT_SIZE " + str(len(trans_np)) + '\n'
	column_size = "#define COL_SIZE " + str(row) + '\n'
	row_size = "#define ROW_SIZE " + str(col) + '\n'

	kernel = mat_size + column_size + row_size + kernel
	program = cl.Program(ctx, kernel).build()

	queue = cl.CommandQueue(ctx)

	# create memory buffers
	mf = cl.mem_flags
	trans_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf = trans_np)
	config_vector_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf = config_vector_np)
	validapps_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf = validapps_np)
	result_config_vectors_buf = cl.Buffer(ctx, mf.WRITE_ONLY, result_config_vectors_np.nbytes)

	# execute the kernel
	program.compute(queue, validapps_np.shape, (col, ), trans_buf, config_vector_buf, validapps_buf, result_config_vectors_buf)
	cl.enqueue_copy(queue, result_config_vectors_np, result_config_vectors_buf)

	return result_config_vectors_np
开发者ID:lienwakin,项目名称:ecpe,代码行数:55,代码来源:global_par.py


示例8: __init__

	def __init__(self,threads=0,platform_directory_string="Platforms/OpenCLGPU/opencl_code",root_directory_string=None,platform_name="",device_type=pyopencl.device_type.GPU,ssh_alias="",remote=False,hostname=None):
		"""Constructor
		
		Parameters
			platform_directory_string, root_directory_String, ssh_alias, remote, hostname - same as Platform class
			platform_name - (string) name of OpenCL SDK to use
			device_type - (pyopencl.device_type) OpenCL device type to use
		"""
		self.threads = threads
		Platform.Platform.__init__(self,platform_directory_string,root_directory_string,ssh_alias,remote,hostname)

		self.platform_name = platform_name

		self.platform = None

		#Selecting the specified platform and device
		flag = False
    		for p in pyopencl.get_platforms():
			for d in p.get_devices():
	  			if(self.platform_name in str(p).lower() and d.get_info(pyopencl.device_info.TYPE)==device_type):
	    				self.platform = p
	    				self.device_type = device_type
	    				flag = True
	    				break
	
			if(flag): break
    
		if not(self.platform): #If the preferred platform isn't available, just take the first one with the preferred device type
      			for p in pyopencl.get_platforms():
				for d in p.get_devices():
	  				if(d.get_info(pyopencl.device_info.TYPE)==device_type):
	    					self.platform = p
	    					self.device_type = device_type
	    					flag = True
	    					break
				if(flag): break
	  
		if not(self.platform): #Failing that, just take the first one that has a CPU and use that
      			for p in pyopencl.get_platforms():
				for d in p.get_devices():
	  				if(d.get_info(pyopencl.device_info.TYPE)==pyopencl.device_type.CPU):
	    					self.platform = p
	    					self.device_type = pyopencl.device_type.CPU
	    					flag = True
	    					break
	
				if(flag): break
      
    		self.platform_name = self.platform.get_info(pyopencl.platform_info.VENDOR)
    		self.device = self.platform.get_devices(self.device_type)[0] #Takes the first device available for the specified platform and type
    
   		self.context = pyopencl.Context(devices=[self.device])
    	
		"""
开发者ID:Gordonei,项目名称:ForwardFinancialFramework,代码行数:54,代码来源:OpenCLGPU.py


示例9: get_devices

def get_devices():
    if len(cl.get_platforms()) > 1:
        for found_platform in cl.get_platforms():
            if found_platform.name == 'NVIDIA CUDA':
                my_platform = found_platform
                print("Selected platform:", my_platform.name)
    else: my_platform = cl.get_platforms()[0]

    devices = {}
    for device in my_platform.get_devices():
      devices[cl.device_type.to_string(device.type)] = device
    return devices
开发者ID:mdsmith,项目名称:MatMulLibPy,代码行数:12,代码来源:oclFunctions.py


示例10: get_test_platforms_and_devices

def get_test_platforms_and_devices(plat_dev_string=None):
    """Parse a string of the form 'PYOPENCL_TEST=0:0,1;intel:i5'.

    :return: list of tuples (platform, [device, device, ...])
    """

    if plat_dev_string is None:
        import os
        plat_dev_string = os.environ.get("PYOPENCL_TEST", None)

    def find_cl_obj(objs, identifier):
        try:
            num = int(identifier)
        except Exception:
            pass
        else:
            return objs[num]

        found = False
        for obj in objs:
            if identifier.lower() in (obj.name + ' ' + obj.vendor).lower():
                return obj
        if not found:
            raise RuntimeError("object '%s' not found" % identifier)

    if plat_dev_string:
        result = []

        for entry in plat_dev_string.split(";"):
            lhsrhs = entry.split(":")

            if len(lhsrhs) == 1:
                platform = find_cl_obj(cl.get_platforms(), lhsrhs[0])
                result.append((platform, platform.get_devices()))

            elif len(lhsrhs) != 2:
                raise RuntimeError("invalid syntax of PYOPENCL_TEST")
            else:
                plat_str, dev_strs = lhsrhs

                platform = find_cl_obj(cl.get_platforms(), plat_str)
                devs = platform.get_devices()
                result.append(
                        (platform,
                            [find_cl_obj(devs, dev_id)
                                for dev_id in dev_strs.split(",")]))

        return result

    else:
        return [
                (platform, platform.get_devices())
                for platform in cl.get_platforms()]
开发者ID:DirkHaehnel,项目名称:pyopencl,代码行数:53,代码来源:tools.py


示例11: __init__

    def __init__(self, nBands, cType, isFloat):
        # Get opencl devices and count
        devices = [j for i in cl.get_platforms() for j in i.get_devices()]
        self.nDevices = len(devices)
        self.inBuffer = queue.Queue(self.nDevices)
        self.outBuffer = queue.Queue(self.nDevices)
        
        #Create context for each device
        contexts = [cl.Context([device]) for device in devices]

        #Compile the program for each context
        cSrcCode = cSrc.format(nBands, cType, int(isFloat))
        programs = [cl.Program(context, cSrcCode) for context in contexts]
        [program.build() for program in programs]
    
        # Queues for contexts
        queues = [cl.CommandQueue(context) for context in contexts]
        
        

        #Create a processingUnit for each program/context/queue
        self.workerExec = [
            ProcessingUnit(
                programs[i], contexts[i], queues[i], self.inBuffer, self.outBuffer
                ) for i in range(self.nDevices)
                ]
        
        for i in self.workerExec:
            i.start()
开发者ID:caiohamamura,项目名称:kuwaharafilter,代码行数:29,代码来源:filter_opencl.py


示例12: InitCL

	def InitCL(self, DEVICE="CPU"):

		try:
			for platform in cl.get_platforms():
				for device in platform.get_devices():
					if cl.device_type.to_string(device.type)== DEVICE:
						my_device =	 device
						print my_device.name, "	 ", cl.device_type.to_string(my_device.type)

		except:
			my_device = cl.get_platforms()[0].get_devices()
			print my_device.name, "	 ", cl.device_type.to_string(my_device.type)

		self.ctx   = cl.Context([my_device])
		self.queue = cl.CommandQueue(self.ctx)
		self.mf	   = cl.mem_flags
开发者ID:cageo,项目名称:Iturraran-Viveros-2013,代码行数:16,代码来源:FD25D_CL.py


示例13: test_opencl_0

def test_opencl_0(zz, a, b, c_result):
 
    for platform in cl.get_platforms():
        for device in [platform.get_devices()[1]]:
            print("===============================================================")
            print("Platform name:", platform.name)
            print("Platform profile:", platform.profile)
            print("Platform vendor:", platform.vendor)
            print("Platform version:", platform.version)
            print("---------------------------------------------------------------")
            print("Device name:", device.name)
            print("Device type:", cl.device_type.to_string(device.type))
            print("Device memory: ", device.global_mem_size//1024//1024, 'MB')
            print("Device max clock speed:", device.max_clock_frequency, 'MHz')
            print("Device compute units:", device.max_compute_units)

        # Simnple speed test
            ctx = cl.Context([device])
            queue = cl.CommandQueue(ctx, 
                                    properties=cl.command_queue_properties.PROFILING_ENABLE)

            mf = cl.mem_flags
            a_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a)
            b_buf = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b)
            dest_buf = cl.Buffer(ctx, mf.WRITE_ONLY, b.nbytes)

            prg = cl.Program(ctx, """
                __kernel void sum(__global const double *a,
                __global const double *b, __global double *c)
                {
                            int loop;
                            int gid = get_global_id(0);
                            for(loop=0; loop<%s;loop++)
                            {
                                    c[gid] = a[gid] + b[gid];
                                    c[gid] = c[gid] * (a[gid] + b[gid]);
                                    c[gid] = c[gid] * (a[gid] / 2);
                                    c[gid] = log(exp(c[gid]));
                            }
                }
            """ % (zz)).build()

            exec_evt = prg.sum(queue, a.shape, None, a_buf, b_buf, dest_buf)
            exec_evt.wait()
            elapsed = 1e-9*(exec_evt.profile.end - exec_evt.profile.start)

            print("Execution time of test: %g s" % elapsed)

            c = numpy.empty_like(a)
            cl.enqueue_read_buffer(queue, dest_buf, c).wait()
            error = 0
            for i in range(zz):
                if c[i] != c_result[i]:
                        print("c_i: ", c[i], " c_results_i: ", c_result[i]) 
                        print("diff: ", numpy.abs(c[i] - c_result[i]))
                        error = 1
            if error:
                print("Results doesn't match!!")
            else:
                print("Results OK")
开发者ID:GongYiLiao,项目名称:Python_Daily,代码行数:60,代码来源:test_opencl_benchmark_fp64_transmath.py


示例14: get_cl_context

def get_cl_context(gl_context):
    """Creates a CL context, with or without given GL context."""
    if gl_context is not None: # ... with OpenGL interop?
        with gl_context:
            assert cl.have_gl(), "GL interoperability not enabled."
            from pyopencl.tools import get_gl_sharing_context_properties
            cl_platform = cl.get_platforms()[0]
            cl_properties = [(cl.context_properties.PLATFORM, cl_platform)] + get_gl_sharing_context_properties()
            cl_devices = [cl_platform.get_devices()[-1]]  # Only one is allowed!
            cl_context = cl.Context(properties=cl_properties, devices=cl_devices)
    else: # ... or in stand-alone mode, CL context without GL?
        cl_platform = cl.get_platforms()[0]  # @UndefinedVariable
        cl_properties = [(cl.context_properties.PLATFORM, cl_platform)]
        cl_devices = [cl_platform.get_devices()[-1]]  # Only one is allowed!
        cl_context = cl.Context(properties=cl_properties, devices=cl_devices)
    return cl_context
开发者ID:adamlwgriffiths,项目名称:glitter,代码行数:16,代码来源:opencltexture2.py


示例15: run

    def run(self, args):
        device_type = cl.device_type.ALL
        if args.device_type == 'cpu':
            device_type = cl.device_type.CPU
        elif args.device_type == 'gpu':
            device_type = cl.device_type.GPU

        platform = cl.get_platforms()[0]
        devices = platform.get_devices(device_type=device_type)
        context = cl.Context(devices=devices)
        queue = cl.CommandQueue(context)

        simulator = physics.Simulator(context, queue, num_worlds=args.num_worlds, num_robots=args.num_robots, ta=args.ta, tb=args.tb, test=False, random_targets=args.random_targets)

        if args.params is not None:
            pos = args.params.decode('hex')
        else:
            pos = ''
            for i in xrange(physics.ANN_PARAMS_SIZE):
                pos += chr(random.randint(0,255))

        decoded = np.zeros(len(pos))
        for i in xrange(len(pos)):
            decoded[i] = float(ord(pos[i])) / 255

        if args.save is None:
            fitness = simulator.simulate([ decoded for i in xrange(args.num_worlds) ], targets_distance=args.targets_distance, targets_angle=args.targets_angle)

        else:
            fitness = simulator.simulate_and_save(args.save, [ decoded for i in xrange(args.num_worlds) ], targets_distance=args.targets_distance, targets_angle=args.targets_angle)

        print 'fitness = ', fitness
开发者ID:bazk,项目名称:srs2d,代码行数:32,代码来源:test.py


示例16: __init__

    def __init__(self, max_elements, cta_size, dtype):
        self.WARP_SIZE = 32
        self.SCAN_WG_SIZE = 256
        self.MIN_LARGE_ARRAY_SIZE = 4 * self.SCAN_WG_SIZE
        self.bit_step = 4
        self.cta_size = cta_size
        self.uintsz = dtype.itemsize

        plat = cl.get_platforms()[0]
        device = plat.get_devices()[0]
        self.ctx = cl.Context(devices=[device])
        self.queue = cl.CommandQueue(self.ctx, device)

        self.loadProgram()

        if (max_elements % (cta_size * 4)) == 0:
            num_blocks = max_elements / (cta_size * 4)
        else:
            num_blocks = max_elements / (cta_size * 4) + 1

        #print "num_blocks: ", num_blocks
        self.d_tempKeys = cl.Buffer(self.ctx, mf.READ_WRITE, size=self.uintsz * max_elements)
        self.d_tempValues = cl.Buffer(self.ctx, mf.READ_WRITE, size=self.uintsz * max_elements)

        self.mCounters = cl.Buffer(self.ctx, mf.READ_WRITE, size=self.uintsz * self.WARP_SIZE * num_blocks)
        self.mCountersSum = cl.Buffer(self.ctx, mf.READ_WRITE, size=self.uintsz * self.WARP_SIZE * num_blocks)
        self.mBlockOffsets = cl.Buffer(self.ctx, mf.READ_WRITE, size=self.uintsz * self.WARP_SIZE * num_blocks)

        numscan = max_elements/2/cta_size*16
        #print "numscan", numscan
        if numscan >= self.MIN_LARGE_ARRAY_SIZE:
        #MAX_WORKGROUP_INCLUSIVE_SCAN_SIZE 1024
            self.scan_buffer = cl.Buffer(self.ctx, mf.READ_WRITE, size = self.uintsz * numscan / 1024)
开发者ID:AytacKi,项目名称:adventures_in_opencl,代码行数:33,代码来源:radix.py


示例17: main

def main():
    # Get module name to load
    if len(sys.argv)<2:
        print "Please specify a model (.py) file"
        exit(0)
    else:
        moduleName = sys.argv[1]

    # Get OpenCL platform/device numbers
    if len(sys.argv)<3:
        # User input of OpenCL setup
        import pyopencl as cl
        # Platform
        platforms = cl.get_platforms()
        print "Select OpenCL platform:"
        for i in range(len(platforms)):
            print 'press '+str(i)+' for '+str(platforms[i])
        platnum = int(input('Platform Number: '))

        # Device
        devices = platforms[platnum].get_devices()
        print "Select OpenCL device:"
        for i in range(len(devices)):
            print 'press '+str(i)+' for '+str(devices[i])
        devnum = int(input('Device Number: '))
    else:
        platnum = int(sys.argv[2])
        devnum = int(sys.argv[3])

    # Set up complete, now run the simulation
    simulate(moduleName, platnum, devnum)
开发者ID:sr639,项目名称:CellModeller,代码行数:31,代码来源:batch.py


示例18: cl_init

def cl_init(type = 'GPU'):
	if type == 'GPU':
		my_type = cl.device_type.GPU
	elif type == 'CPU':
		my_type = cl.device_type.CPU
	
	try:
		platform = cl.get_platforms()[0]
		devices = platform.get_devices(device_type=my_type)
		ctx = cl.Context(devices = devices)
	except:
		ctx = cl.create_some_context(interactive=True)
	
	device = devices[0]
	print("===============================================================")
	print("Platform name: " + platform.name)
	print("Platform vendor: " + platform.vendor)
	print("Platform version: " + platform.version)
	print("---------------------------------------------------------------")
	print("Device name: " + device.name)
	print("Device type: " + cl.device_type.to_string(device.type))
	print("Local memory: " + str(device.local_mem_size//1024) + ' KB')
	print("Device memory: " + str(device.global_mem_size//1024//1024) + ' MB')
	print("Device max clock speed:" + str(device.max_clock_frequency) + ' MHz')
	print("Device compute units:" + str(device.max_compute_units))
	
	return ctx
开发者ID:spetz911,项目名称:CL,代码行数:27,代码来源:lab1.py


示例19: init_cl

    def init_cl(self, platnum, devnum):
        # Check that specified platform exists
        platforms = cl.get_platforms()
        if len(platforms) <= platnum:
            print "Specified OpenCL platform number (%d) does not exist."
            print "Options are:"
            for p in range(len(platforms)):
                print "%d: %s" % (p, str(platforms[p]))
            return False
        else:
            platform = platforms[platnum]

        # Check that specified device exists on that platform
        devices = platforms[platnum].get_devices()
        if len(devices) <= devnum:
            print "Specified OpenCL device number (%d) does not exist on platform %s." % (devnum, platform)
            print "Options are:"
            for d in range(len(devices)):
                print "%d: %s" % (d, str(devices[d]))
            return False
        else:
            device = devices[devnum]

        # Create a context and queue
        self.CLContext = cl.Context(properties=[(cl.context_properties.PLATFORM, platform)], devices=[device])
        self.CLQueue = cl.CommandQueue(self.CLContext)
        print "Set up OpenCL context:"
        print "  Platform: %s" % (str(platform.name))
        print "  Device: %s" % (str(device.name))
        return True
开发者ID:cesarr,项目名称:CellModeller,代码行数:30,代码来源:Simulator.py


示例20: save_device_fetch

def save_device_fetch(type):
	devices = []
	for platform in cl.get_platforms():
		devices = devices + platform.get_devices(device_type=type)

	# Just use the first GPU device, they are all good
	return [devices[0]]
开发者ID:AndreasMadsen,项目名称:fire-simulator,代码行数:7,代码来源:simulator.py



注:本文中的pyopencl.get_platforms函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pyopencl.get_supported_image_formats函数代码示例发布时间:2022-05-27
下一篇:
Python pyopencl.get_cl_header_version函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap