摘要:矩阵转置 // kernel __kernel void transpose(__global float4 *g_mat, __local float4 *l_mat, uint size) { __global float4 *src, *dst; /* Determine row and co
        
阅读全文
 
        
            
            
摘要:基数排序原理: 分桶,遍历每一个有效位,根据该位中是0还是1进行分组。 设备代码: __kernel void radix_sort8(__global ushort8 *global_data) { typedef union { ushort8 vec; ushort array[8]; } v
        
阅读全文
 
        
            
            
摘要:参考:《opencl实战》 双调排序 一个序列:进行升序排列 6 1 4 5 7 2 3 8 a、左右两部分别 升序、降序 1 4 5 6 8 7 3 2 b 、左右度应位置比较,小的左移 1 4 3 2 8 7 5 6 c、左右都整成升序 1 2 3 4 5 6 7 8 注:四个元素如何排序 op
        
阅读全文
 
        
            
            
摘要:计算RGB图像的直方图 // kernel __kernel void histogram(__global uchar* imgdata, __global uint *histogram, __local uint *local_histogram, uint data_size_item, u
        
阅读全文
 
        
            
            
摘要:MapReduce 两个部分: 映射:产生键值对 归并:处理这些键值对 demo: 统计模式串在文本中的频次 // kernel __kernel void string_search(char16 pattern, __global char* text, int chars_per_item, 
        
阅读全文
 
        
            
            
摘要:读取图像 read_imagef (2D) : https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/read_imagef2d.html read_imagef (3D) :https://www.khronos.org/re
        
阅读全文
 
        
            
            
摘要:图像对象、采样器在主机和设备上使用不同的数据结构。 图像对象 主机: cl_mem https://www.cnblogs.com/feihu-h/p/12081652.html 设备: image2d_t 、image3d_t 采样器 主机: cl_sampler 设备: sampler_t 主机
        
阅读全文
 
        
            
            
摘要:混洗函数 可以参考: https://www.khronos.org/registry/OpenCL/sdk/1.1/docs/man/xhtml/shuffle.html // 创建一个包含x中元素的向量,包含哪些元素有 mask 控制 gentypen shuffle ( gentypem x,
        
阅读全文
 
        
            
            
摘要:OpenCL operators 参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/ int4 vec = (int4)(1, 2, 3, 4); vec += 4;//每一个元素加上4 vec &= (int4)(-
        
阅读全文
 
        
            
            
摘要:1、opencl 标量数据类型 bool char unsigned char/uchar short 16位有符号整数(补码) ushort int 32位有符号整数(补码) uint 32位无符号 long 64位有符号 ulong half 16位浮点数 float 32位浮点数 intptr
        
阅读全文
 
        
            
            
摘要:clEnqueueNDRangeKernel cl_int clEnqueueNDRangeKernel ( cl_command_queue command_queue, //命令队列 cl_kernel kernel, //核 cl_uint work_dim, //数据的维度 const si
        
阅读全文
 
        
            
            
摘要:Read读(从设备到主机) // 将缓存对象中的数据读到内存对象中 cl_int clEnqueueReadBuffer ( cl_command_queue command_queue, //命令队列 cl_mem buffer, // 缓存对象 cl_bool blocking_read, //
        
阅读全文
 
        
            
            
摘要:图像对象同样使用cl_mem数据结构 创建图像对象 // 创建2D的图像对象cl_mem clCreateImage2D ( cl_context context, //上下文 cl_mem_flags flags, // 对象性质标签 const cl_image_format *image_fo
        
阅读全文
 
        
            
            
摘要:创建缓存对象 参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clCreateBuffer.html // 创建缓存对象 cl_mem clCreateBuffer ( cl_context context, //上
        
阅读全文
 
        
            
            
摘要:创建命令队列 参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clCreateCommandQueue.html //创建命令队列 cl_command_queue clCreateCommandQueue( cl_
        
阅读全文
 
        
            
            
摘要:1、创建程序 // 从文本中创建程序 cl_program clCreateProgramWithSource ( cl_context context, // 上下文 cl_uint count, //文本个数 const char **strings, // 程序文本 const size_t 
        
阅读全文
 
        
            
            
摘要:1、获取平台 参考:https://www.khronos.org/registry/OpenCL/sdk/1.0/docs/man/xhtml/clGetPlatformInfo.html cl_int clGetPlatformIDs( cl_uint num_entries, //想要获取的平
        
阅读全文