尝试查找打开的CL代码的运行时出错

时间:2015-07-22 12:58:53

标签: c++ time clock

我有一个路径查找器程序,我使用clock_gettime()函数来发现代码的这个特定部分的运行时。但是,当我尝试执行代码时,我收到错误,我不确定如何修复。任何建议都非常感谢。

No 'Access-Control-Allow-Origin' header is present on the requested resource.

我收到的错误:

struct timespec start, stop;
double accum;

if( clock_gettime( CLOCK_REALTIME, &start) == -1 ) {
  perror( "clock gettime" );
  exit( EXIT_FAILURE );
}

int src = 1, final_ret = 0;
for (int t = 0; t < rows - 1; t += pyramid_height)
{
    int temp = src;
    src = final_ret;
    final_ret = temp;

    // Calculate this for the kernel argument...
    int arg0 = MIN(pyramid_height, rows-t-1);
    int theHalo = HALO;

    // Set the kernel arguments.
    clSetKernelArg(cl.kernel(kn), 0,  sizeof(cl_int), (void*) &arg0);
    clSetKernelArg(cl.kernel(kn), 1,  sizeof(cl_mem), (void*) &d_gpuWall);
    clSetKernelArg(cl.kernel(kn), 2,  sizeof(cl_mem), (void*) &d_gpuResult[src]);
    clSetKernelArg(cl.kernel(kn), 3,  sizeof(cl_mem), (void*) &d_gpuResult[final_ret]);
    clSetKernelArg(cl.kernel(kn), 4,  sizeof(cl_int), (void*) &cols);
    clSetKernelArg(cl.kernel(kn), 5,  sizeof(cl_int), (void*) &rows);
    clSetKernelArg(cl.kernel(kn), 6,  sizeof(cl_int), (void*) &t);
    clSetKernelArg(cl.kernel(kn), 7,  sizeof(cl_int), (void*) &borderCols);
    clSetKernelArg(cl.kernel(kn), 8,  sizeof(cl_int), (void*) &theHalo);
    clSetKernelArg(cl.kernel(kn), 9,  sizeof(cl_int) * (cl.localSize()), 0);
    clSetKernelArg(cl.kernel(kn), 10, sizeof(cl_int) * (cl.localSize()), 0);
    clSetKernelArg(cl.kernel(kn), 11, sizeof(cl_mem), (void*) &d_outputBuffer);
    cl.launch(kn);
}

if( clock_gettime( CLOCK_REALTIME, &stop) == -1 ) {
  perror( "clock gettime" );
  exit( EXIT_FAILURE );
}

提前致谢

1 个答案:

答案 0 :(得分:0)

您收到链接器错误,而不是执行错误。 发生这种情况是因为您没有将应用程序链接到提供type功能的库(这个是clock_gettime)。 因此,您只需要将另一个库与librt标志链接:

-lrt