OpenCL异构计算资料收集

 

Easy OpenCL with Python

 

OpenCL与python联合工作:与CUDA的前景分析

http://www.opengpu.org/forum.php?mod=viewthread&tid=16571

 

如果你对python熟,可以用 PyOpenCL, 兼顾 host 端的简洁与 device 端的高效。
kernel 函数可以写在单独的 *.cl 文件里, 一句 python 命令就可以 load + build:
 prg_src = open( 'kernel_test1.cl', 'r').read()
 prg = cl.Program(ctx, prg_src).build()

 #!/usr/bin/env python

 import numpy as np
 import pyopencl as cl

 a_np = np.random.rand(50000).astype(np.float32)
 b_np = np.random.rand(50000).astype(np.float32)

 ctx = cl.create_some_context()
 queue = cl.CommandQueue(ctx)

 mf =  cl.mem_flags
 a_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=a_np)
 b_g = cl.Buffer(ctx, mf.READ_ONLY | mf.COPY_HOST_PTR, hostbuf=b_np)

 prg = cl.Program(ctx, """
         __kernel void sum(__global const float *a_g, 
                           __global const float *b_g, 
                           __global float *res_g) 
             {
                 int gid = get_global_id(0);
                 res_g[gid] = a_g[gid] + b_g[gid];
             }
             """).build()

 res_g = cl.Buffer(ctx, mf.WRITE_ONLY, a_np.nbytes)
 prg.sum(queue, a_np.shape, None, a_g, b_g, res_g)

 res_np = np.empty_like(a_np)
 cl.enqueue_copy(queue, res_np, res_g)

 # Check on CPU with Numpy:
 print(res_np - (a_np + b_np))
 print(np.linalg.norm(res_np - (a_np + b_np)))


 

GPGPU OpenCL/CUDA 高性能编程的10大注意事项

 

http://www.cnblogs.com/xudong-bupt/p/3630952.html

 

从零开始学习OpenCL开发(一)架构

 

http://blog.csdn.net/leonwei/article/details/8880012

 

在Android上使用OpenCL调用GPU加速

http://blog.csdn.net/dj0379/article/details/39484061

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值