本文整理汇总了Python中pyopencl.enqueue_write_buffer函数的典型用法代码示例。如果您正苦于以下问题:Python enqueue_write_buffer函数的具体用法?Python enqueue_write_buffer怎么用?Python enqueue_write_buffer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enqueue_write_buffer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: mineThread
def mineThread(self):
for data in self.qr:
for i in range(data.iterations):
self.kernel.search(
self.commandQueue, (data.size, ), (self.WORKSIZE, ),
data.state[0], data.state[1], data.state[2], data.state[3],
data.state[4], data.state[5], data.state[6], data.state[7],
data.state2[1], data.state2[2], data.state2[3],
data.state2[5], data.state2[6], data.state2[7],
data.base[i],
data.f[0],
data.f[1],data.f[2],
data.f[3],data.f[4],
self.output_buf)
cl.enqueue_read_buffer(
self.commandQueue, self.output_buf, self.output)
self.commandQueue.finish()
# The OpenCL code will flag the last item in the output buffer when
# it finds a valid nonce. If that's the case, send it to the main
# thread for postprocessing and clean the buffer for the next pass.
if self.output[self.OUTPUT_SIZE]:
reactor.callFromThread(self.postprocess, self.output.copy(),
data.nr)
self.output.fill(0)
cl.enqueue_write_buffer(
self.commandQueue, self.output_buf, self.output)
开发者ID:lid,项目名称:phoenix-miner,代码行数:28,代码来源:__init__.py
示例2: compute
def compute(self):
glMatrixMode(GL_MODELVIEW)
glPushMatrix()
glLoadIdentity()
self.applySceneTransforms()
mat = np.array(glGetFloat(GL_MODELVIEW_MATRIX).transpose(), order='C')
glPopMatrix()
inv = np.array(np.linalg.inv(mat), order='C')
e1 = cl.enqueue_write_buffer(queue, self.matrix, mat)
e2 = cl.enqueue_write_buffer(queue, self.inv_matrix, inv)
e3 = self.program.pdbTracer(queue, self.dst.shape[:2], self.dst_buf,
self.matrix, self.inv_matrix,
np.array(len(self.mol.spheres)), self.spheredata,
self.envmap, self.phimap, self.sampler)
e4 = cl.enqueue_read_buffer(queue, self.dst_buf, self.dst)
queue.finish()
e4.wait()
for e in [e3]:
print (e.profile.END - e.profile.START)*1e-9
glBindTexture(GL_TEXTURE_2D, self.dstTex)
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, N, N, GL_RGBA, GL_UNSIGNED_BYTE, self.dst)
开发者ID:amiller,项目名称:graphicsii,代码行数:25,代码来源:clrender.py
示例3: allocations
def allocations(s):
s.eh_fieldss = []
s.ce_fieldss = []
mf = cl.mem_flags
for i, nx in enumerate(s.nxs):
f = np.zeros((nx, s.ny, s.nz), 'f')
cf = np.ones_like(f) * 0.5
if i < s.ngpu:
s.eh_fieldss.append( [cl.Buffer(s.context, mf.READ_WRITE, f.nbytes) for m in range(6)] )
s.ce_fieldss.append( [cl.Buffer(s.context, mf.READ_ONLY, cf.nbytes) for m in range(3)] )
for eh_field in s.eh_fieldss[-1]:
cl.enqueue_write_buffer(s.queues[i], eh_field, f)
for ce_field in s.ce_fieldss[-1]:
cl.enqueue_write_buffer(s.queues[i], ce_field, cf)
else:
s.eh_fieldss.append( [f.copy() for i in xrange(6)] )
s.ce_fieldss.append( [cf.copy() for i in xrange(3)] )
del f, cf
s.offsets = []
s.tmpfs = []
for nx in s.nxs:
s.offsets.append( (nx-1) * s.ny * s.nz * np.nbytes['float32'] )
s.tmpfs.append( [np.zeros((s.ny, s.nz), dtype=np.float32) for m in range(2)] )
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:26,代码来源:fdtd3d.py
示例4: __init__
def __init__(s, fdtd, nx, ny, nz):
super(TestSetFields, s).__init__(nx, ny, nz)
s.fdtd = fdtd
for strf in s.strf_list:
randarr = np.random.rand(nx, ny, nz).astype(s.fdtd.dtype)
cl.enqueue_write_buffer(s.fdtd.queue, s.fdtd.get_buffer(strf), randarr)
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:7,代码来源:test_get_set_fields.py
示例5: exchange_boundary_h
def exchange_boundary_h(s):
for queue, eh_fields, tmpf, offset in zip(s.queues, s.eh_fields_gpus, s.tmpfs, s.offsets)[:-1]:
cl.enqueue_read_buffer(queue, eh_fields[4], tmpf[0], offset) # hy_gpu
cl.enqueue_read_buffer(queue, eh_fields[5], tmpf[1], offset) # hz_gpu
for queue, eh_fields, tmpf in zip(s.queues[1:], s.eh_fields_gpus[1:], s.tmpfs[:-1]):
cl.enqueue_write_buffer(queue, eh_fields[4], tmpf[0])
cl.enqueue_write_buffer(queue, eh_fields[5], tmpf[1])
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:7,代码来源:fdtd3d_gpu_cpu_non-pinned.py
示例6: exchange_boundary_e
def exchange_boundary_e(s):
for queue, eh_fields, tmpf in zip(s.queues, s.eh_fields_gpus, s.tmpfs)[1:]:
cl.enqueue_read_buffer(queue, eh_fields[1], tmpf[0]) # ey_gpu
cl.enqueue_read_buffer(queue, eh_fields[2], tmpf[1]) # ez_gpu
for queue, eh_fields, tmpf, offset in zip(s.queues[:-1], s.eh_fields_gpus[:-1], s.tmpfs[1:], s.offsets[:-1]):
cl.enqueue_write_buffer(queue, eh_fields[1], tmpf[0], offset)
cl.enqueue_write_buffer(queue, eh_fields[2], tmpf[1], offset)
开发者ID:wbkifun,项目名称:fdtd_accelerate,代码行数:7,代码来源:fdtd3d_gpu_cpu_non-pinned.py
示例7: update
def update(self, sub_pos, angle, min_dist, max_dist, width, in_weight, out_weight):
'''
Perform one update on the probabilities by using the evidence that
the sub is at position sub_pos, the target is seen at an absolute heading
of `angle` and is most likely between min_dist and max_dist away.
in_weight gives the chance that for every point in the region,
if the buoy is there then we would get this result
i.e. in_weight = P(this measurement | buoy at point p) for p in our region
out_weight is the same but for points outside the region
'''
n,e = sub_pos
cl_program.evidence(cl_queue, self.norths.shape, None,
self.norths_buf, self.easts_buf, self.prob_buf,
float32(n), float32(e),
float32(radians(angle)),
float32(min_dist**2),
float32(max_dist**2),
float32(width),
float32(in_weight),
float32(out_weight))
#TODO ?
cl.enqueue_read_buffer(cl_queue, self.prob_buf, self.probabilities).wait()
#Normalize
total_prob = numpy.sum( self.probabilities )
self.probabilities /= total_prob
cl.enqueue_write_buffer(cl_queue, self.prob_buf, self.probabilities)
开发者ID:athityakumar,项目名称:software,代码行数:29,代码来源:locator_cl.py
示例8: mineThread
def mineThread(self):
for data in self.qr:
for i in range(data.iterations):
offset = (unpack('I', data.base[i])[0],) if self.GOFFSET else None
self.kernel.search(
self.commandQueue, (data.size, ), (self.WORKSIZE, ),
data.state[0], data.state[1], data.state[2], data.state[3],
data.state[4], data.state[5], data.state[6], data.state[7],
data.state2[1], data.state2[2], data.state2[3],
data.state2[5], data.state2[6], data.state2[7],
data.base[i],
data.f[0], data.f[1], data.f[2], data.f[3],
data.f[4], data.f[5], data.f[6], data.f[7],
self.output_buf, global_offset=offset)
cl.enqueue_read_buffer(self.commandQueue, self.output_buf,
self.output, is_blocking=False)
self.commandQueue.finish()
# The OpenCL code will flag the last item in the output buffer
# when it finds a valid nonce. If that's the case, send it to
# the main thread for postprocessing and clean the buffer
# for the next pass.
if self.output[self.WORKSIZE]:
reactor.callFromThread(self.postprocess,
self.output.copy(), data.nr)
self.output.fill(0)
cl.enqueue_write_buffer(self.commandQueue, self.output_buf,
self.output, is_blocking=False)
开发者ID:BlackhatEspeed,项目名称:phoenix,代码行数:29,代码来源:__init__.py
示例9: set_target
def set_target(self, target):
flags = mf.READ_ONLY | mf.COPY_HOST_PTR
self.target = np.array(target, np.float32)
if self.target_buffer is None:
self.target_buffer = self.buffer(self.target)
else:
cl.enqueue_write_buffer(self.queue, self.target_buffer, self.target)
开发者ID:steveorsomethin,项目名称:neuralpy,代码行数:8,代码来源:main.py
示例10: randomize_weights
def randomize_weights( self, context ):
"""
Initialize weights of layer by random values
"""
weights = numpy.random.rand( context._weights_buf_size ).astype( numpy.float32 )
weights -= 0.5
weights *= 4.0 / numpy.sqrt( numpy.float32( context._weights_buf_size / context._neurons_buf_size ) )
pyopencl.enqueue_write_buffer( context.opencl.queue, context._weights_buf, weights, is_blocking = True )
开发者ID:remtcs,项目名称:gpgpu-neuralnet,代码行数:10,代码来源:training.py
示例11: set_weights
def set_weights( self, weights ):
"""
Set weights for entire layer.
@param weights
NumPy.NDArray of float32 values, size equals to inputs_per_neuron * neuron_count
"""
pyopencl.enqueue_write_buffer(
self.opencl.queue, self.context._weights_buf, weights,
device_offset = int( self._weights_offset * 4 ), is_blocking = True
)
开发者ID:remtcs,项目名称:gpgpu-neuralnet,代码行数:11,代码来源:layer.py
示例12: __init__
def __init__(self, baseTab):
self.baseTab = baseTab
self.ctx = cl.create_some_context()
self.queue = cl.CommandQueue(self.ctx)
f = open("gutarp.cl", 'r')
fstr = "".join(f.readlines())
self.guTarpCL = cl.Program(self.ctx, fstr).build()
self.baseTabBuffer = cl.Buffer(self.ctx, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=self.baseTab)
cl.enqueue_write_buffer(self.queue, self.baseTabBuffer, self.baseTab)
开发者ID:Hiestaa,项目名称:TARP-ODNL,代码行数:11,代码来源:guTarp.py
示例13: push_particles
def push_particles(self, pos, vel, color):
nn = pos.shape[0]
if self.num + nn > self.sph.max_num:
return
self.acquire_gl()
cl.enqueue_write_buffer(self.queue, self.position_u, pos, self.num)
self.release_gl()
self.num += nn
self.update_sphp()
self.queue.finish()
开发者ID:JorgeFRod,项目名称:EnjaParticles,代码行数:12,代码来源:clsph.py
示例14: test_process
def test_process( self ):
weights = numpy.random.rand( self.nnc._weights_buf_size ).astype( numpy.float32 )
weights -= 0.5
weights *= 4.0 / numpy.sqrt( numpy.float32( self.nnc._weights_buf_size / self.nnc._neurons_buf_size ) )
pyopencl.enqueue_write_buffer( self.ocl.queue, self.nnc._weights_buf, weights, is_blocking = True )
self.nnc.input_layer.set_inputs( numpy.array( [x * x for x in range( 0, 10 )], numpy.float32 ), is_blocking = True )
self.nnc.input_layer.process()
self.assertArrayEqual( self.i.get_outputs()[:3], self.h1.get_inputs() )
self.assertArrayEqual( self.i.get_outputs()[:5], self.h2.get_inputs() )
self.assertArrayEqual( self.i.get_outputs()[4:10], self.h3.get_inputs()[:6] )
开发者ID:remtcs,项目名称:gpgpu-neuralnet,代码行数:13,代码来源:layer.py
示例15: sobel
def sobel(im, cl=None):
if cl is None:
cl = setup(im)
im = im.astype(numpy.float32)
pyopencl.enqueue_write_buffer(cl['queue'], cl['im_dev'], im)
cl['prg'].sobel(cl['queue'], im.shape, (3,), \
cl['im_dev'], cl['m_dev'], cl['x_dev'], cl['y_dev'])
m = numpy.empty_like(im)
x = numpy.empty_like(im)
y = numpy.empty_like(im)
pyopencl.enqueue_read_buffer(cl['queue'], cl['m_dev'], m).wait()
pyopencl.enqueue_read_buffer(cl['queue'], cl['x_dev'], x).wait()
pyopencl.enqueue_read_buffer(cl['queue'], cl['y_dev'], y).wait()
return m, x, y
开发者ID:braingram,项目名称:eyetracker,代码行数:14,代码来源:sobel.py
示例16: exchange_boundary
def exchange_boundary(snx, ny, queues, f_gpus, tmp_hs, tmp_ts):
ngpu = len(queues)
for i, queue in enumerate(queues):
if i>0:
cl.enqueue_read_buffer(queue, f_gpus[i], tmp_hs[i], device_offset=ny*4)
if i<ngpu-1:
cl.enqueue_read_buffer(queue, f_gpus[i], tmp_ts[i], device_offset=(snx-2)*ny*4)
for i, queue in enumerate(queues):
if i>0:
cl.enqueue_write_buffer(queue, f_gpus[i], tmp_ts[i-1])
if i<ngpu-1:
cl.enqueue_write_buffer(queue, f_gpus[i], tmp_hs[i+1], device_offset=(snx-1)*ny*4)
开发者ID:wbkifun,项目名称:my_stuff,代码行数:14,代码来源:140_wave2d_pyopencl_multi_gpu.py
示例17: compute
def compute(self, idTab) :
idTabBuffer = cl.Buffer(self.ctx, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=idTab)
cl.enqueue_write_buffer(self.queue, idTabBuffer, idTab)
result = numpy.empty([idTab.shape[0], 1], dtype=numpy.int32)
resultBuffer = cl.Buffer(self.ctx, cl.mem_flags.READ_WRITE | cl.mem_flags.COPY_HOST_PTR, hostbuf=result)
cl.enqueue_write_buffer(self.queue, resultBuffer, result)
self.guTarpCL.gutarp(self.queue, (idTab.shape[0],), None, self.baseTabBuffer, idTabBuffer,
numpy.int32(self.baseTab.shape[0]), numpy.int32(self.baseTab.shape[1]), resultBuffer)
cl.enqueue_read_buffer(self.queue, resultBuffer, result).wait()
return result
开发者ID:Hiestaa,项目名称:TARP-ODNL,代码行数:15,代码来源:guTarp.py
示例18: compute_raytrace
def compute_raytrace(mat):
assert mat.dtype == np.float32
assert mat.shape == (4,4)
mat = np.ascontiguousarray(mat)
cl.enqueue_write_buffer(queue, mat_buf, mat)
cl.enqueue_write_buffer(queue, inv_mat_buf,
np.ascontiguousarray(np.linalg.inv(mat))).wait()
evt = program.raytrace(queue, (H,W), None,
img_buf,
mat_buf, inv_mat_buf,
np.int32(num_faces), vert_buf, face_buf)
evt.wait()
return evt
开发者ID:amiller,项目名称:mesh,代码行数:16,代码来源:opencl.py
示例19: calc_radii_gpu
def calc_radii_gpu(self):
if self.openCLInitialized == 0:
self.initialize_opencl()
cl.enqueue_write_buffer(self.queue, self.ptcllist_d,
self.ptcllist).wait()
blockSize = 1024
numBlocks = int(
math.ceil(numpy.float64(self.nptcls) /
numpy.float64(blockSize)))
print(blockSize)
print(numBlocks)
self.prg.calc_radii_kernel(
self.queue,
(numBlocks * blockSize,),
(blockSize,),
self.ptcllist_d,
numpy.int32(self.nptcls),
numpy.float64(self.k))
cl.enqueue_read_buffer(self.queue, self.ptcllist_d, self.ptcllist).wait()
开发者ID:johannjc,项目名称:Coding-Examples,代码行数:19,代码来源:newp3m.py
示例20: add
def add(a, b):
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)
test1 = struct.pack('ffffi', .5, 10., .1, .2, 3)
print test1, len(test1), struct.calcsize('ffff')
test_buf = cl.Buffer(ctx, mf.READ_ONLY, len(test1))
cl.enqueue_write_buffer(queue, test_buf, test1).wait()
global_size = a.shape
local_size = None
prg.sum(queue, global_size, local_size, a_buf, b_buf, dest_buf, test_buf)
queue.finish()
c = np.empty_like(a)
cl.enqueue_read_buffer(queue, dest_buf, c).wait()
return c
开发者ID:AytacKi,项目名称:adventures_in_opencl,代码行数:19,代码来源:structs.py
注:本文中的pyopencl.enqueue_write_buffer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论