transform_hsa.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pynufft 作者: jyhmiinlin 项目源码 文件源码
def test_cAddScalar():

    dtype = numpy.complex64

    try:
        device=pyopencl.get_platforms()[1].get_devices()

    except:
        device=pyopencl.get_platforms()[0].get_devices()
    print('using cl device=',device,device[0].max_work_group_size, device[0].max_compute_units,pyopencl.characterize.get_simd_group_size(device[0], dtype.size))

    ctx = pyopencl.Context(device) #pyopencl.create_some_context()
    queue = pyopencl.CommandQueue(ctx)
    wavefront = pyopencl.characterize.get_simd_group_size(device[0], dtype.size)

#     B = routine(wavefront)
    import cl_subroutine.cAddScalar
    prg = pyopencl.Program(ctx, cl_subroutine.cAddScalar.R).build()

    AddScalar = prg.cAddScalar
    AddScalar.set_scalar_arg_dtypes(cl_subroutine.cAddScalar.scalar_arg_dtypes)
#     indata= numpy.arange(0,128).astype(dtype)
    indata = (numpy.random.randn(128,)+numpy.random.randn(128,)*1.0j).astype(dtype)      
    indata_g = pyopencl.array.to_device(queue, indata)
    scal= 0.1+0.1j
    AddScalar(queue, (128,),None,scal, indata_g.data)
    print(-indata[0]+indata_g.get()[0])

# if __name__ == '__main__':
#     import cProfile
# #     cProfile.run('benchmark()')
#     test_init()
#     test_cAddScalar()
#     cProfile.run('test_init()')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号