Hi Dear all,
I am trying to test a matrix multiplication program which utilize GPU and
CPU to compute together. The purpose is to use CPU to further accelerate
the solo GPU computation. I allocate a large portion of computation to GPU
and the left to CPU. The computation can generate correct result.
However, no matter how much computation is allocated to CPU, it has a time
overhead of about 3 seconds. For better illustration, I listed the code
that uses CPU to do the whole computation as below. The red lines are the
execution time I measured for a 1024x1024 matrix multiplication case. I
also tested other matrix size, the time overhead is still about 3 seconds.
//-------------------------Run with CPU--------------------------
start_time = get_time();
errcode = clSetKernelArg(clCPUKernel, 0, sizeof(cl_mem), (void
*)&dCPU_C);
errcode |= clSetKernelArg(clCPUKernel, 1,sizeof(cl_mem), (void
*)&dCPU_A);
errcode |= clSetKernelArg(clCPUKernel, 2,sizeof(cl_mem), (void
*)&dCPU_B);
errcode |= clSetKernelArg(clCPUKernel, 3,sizeof(int), (void *)&wA);
errcode |= clSetKernelArg(clCPUKernel, 4,sizeof(int), (void *)&wC);
error = clEnqueueNDRangeKernel(clCPUCommandQue,
clCPUKernel, 2, NULL, globalWorkSize,
localWorkSize, 0, NULL, &GPUExecution[2]);
if (error != CL_SUCCESS) fatal_CL(error, __LINE__);
error = clFlush(clCPUCommandQue);
if (error != CL_SUCCESS) fatal_CL(error, __LINE__);
// 8. Retrieve result from device
error = clEnqueueReadBuffer(clCPUCommandQue,
dCPU_C, CL_TRUE, 0, mem_size_C,
hCPU_C, 0, NULL, &GPUExecution[3]);
if (error != CL_SUCCESS) fatal_CL(error, __LINE__);
printf("CPU compute+memory : %.3f + %.3f seconds\n",
executionTime(GPUExecution[2]),executionTime(GPUExecution[3]));
CPU compute+memory : 0.874 + 0.004 seconds
printf("CPU total time: %.3f seconds\n", ((float) (get_time() -
start_time)) / (1000*1000));
CPU total time: 3.649 seconds
* The time overhead I mean is: (3.649-0.874-0.004) = 2.771*
//-------------------------Run with CPU--------------------------
Thanks.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
pocl-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pocl-devel