10.07.2015 Views

ATI Stream Computing OpenCL Programming Guide - CiteSeerX

ATI Stream Computing OpenCL Programming Guide - CiteSeerX

ATI Stream Computing OpenCL Programming Guide - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ATI</strong> STREAM COMPUTINGdbg_buf = clCreateBuffer( context,CL_MEM_WRITE_ONLY,global_work_size * sizeof(cl_uint),NULL, NULL );clSetKernelArg(minp, 0, sizeof(void *), (void*) &src_buf);clSetKernelArg(minp, 1, sizeof(void *), (void*) &dst_buf);clSetKernelArg(minp, 2, 1*sizeof(cl_uint), (void*) NULL);clSetKernelArg(minp, 3, sizeof(void *), (void*) &dbg_buf);clSetKernelArg(minp, 4, sizeof(num_src_items), (void*) &num_src_items);clSetKernelArg(minp, 5, sizeof(dev),(void*) &dev);clSetKernelArg(reduce, 0, sizeof(void *),clSetKernelArg(reduce, 1, sizeof(void *),(void*) &src_buf);(void*) &dst_buf);CPerfCounter t;t.Reset();t.Start();// 6. Main timing loop.#define NLOOPS 500cl_event ev;int nloops = NLOOPS;while(nloops--){clEnqueueNDRangeKernel( queue,minp,1,NULL,&global_work_size,&local_work_size,0, NULL, &ev);}clEnqueueNDRangeKernel( queue,reduce,1,NULL,&num_groups,NULL, 1, &ev, NULL);clFinish( queue );t.Stop();printf("B/W %.2f GB/sec, ", ((float) num_src_items *sizeof(cl_uint) * NLOOPS) /t.GetElapsedTime() / 1e9 );// 7. Look at the results via synchronous buffer map.dst_ptr = (cl_uint *) clEnqueueMapBuffer( queue,dst_buf,CL_TRUE,CL_MAP_READ,0,num_groups * sizeof(cl_uint),0, NULL, NULL, NULL );1.9 Example Programs 1-33Copyright © 2010 Advanced Micro Devices, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!