这里可能是非常简单的问题,但我已经搜索了几个小时但没有任何结果。
我有这段代码,我希望有一个 256 位(8 uint32)bitstring_gpu 作为设备中的本地内存指针:
def Get_Bitstring_GPU_Buffer(ctx, bitstring):
bitstring_gpu = cl.Buffer(ctx, mem_flags.READ_ONLY | mem_flags.COPY_HOST_PTR, hostbuf=bitstring)
return bitstring_gpu
这稍后将在内核调用中使用:
prg.get_active_hard_locations_64bit(queue, (HARD_LOCATIONS,), None, memory_addresses_gpu.data, bitstring_gpu, distances_gpu.data, hash_table_gpu.data ).wait()
...而 bitstring 只是一个随机的 256 位比特串(通过 sha256 生成,然后转换为 numpy 数组。
def Get_Random_Bitstring():
bitstring = address_space_through_sha256_SDM.get_bitstring(str(random.randrange(2**32-1)))
return bitstring
如何使 bitstring_buf 进入快速的本地内存?
相关但不同的问题;这里正在内核内部创建缓冲区......
如何在 pyopencl 中创建可变大小的 __local 内存? https://stackoverflow.com/questions/5912968/how-to-create-variable-sized-local-memory-in-pyopencl