我正在尝试分配一个 double8 类型,最终用于使用 pyopencl 的某些 AVX2 并行化。我正在编写代码以在两个向量 va 和 vb 之间有效地找到点积,并返回结果 vc。
代码如下:
# create context
ctx = cl.create_some_context()
mf = cl.mem_flags
# define vectors to dot product
va=np.array([1, 2, 3, 4, 5, 6, 7, 8],dtype=np.float32)
vb=np.array([1, 2, 3, 4, 5, 6, 7, 8],dtype=np.float32)
# create memory buffers for input vectors and output buffer
va_buf=cl.Buffer(ctx,mf.READ_ONLY|mf.COPY_HOST_PTR,hostbuf=va)
vb_buf=cl.Buffer(ctx,mf.READ_ONLY|mf.COPY_HOST_PTR,hostbuf=vb)
vc_buf=cl.Buffer(ctx,mf.WRITE_ONLY,vb.nbytes)
# define my kernel / C function that will perform dot product
kernel="""
__kernel void adder(const __global float* va,
const __global float* vb, …Run Code Online (Sandbox Code Playgroud)