小编use*_*504的帖子

在 CPU 上使用 OpenCL 将一个数组复制到另一个数组比 C++ 代码慢得多

我比较了在 CPU 上运行的 OpenCL 代码的性能,该代码只是将数据从一个 2D 数组复制到另一个数组中,并将其转换为执行相同操作的纯 C++ 代码。我在 OpenCL 代码中使用了一个工作组来进行公平比较。我使用了英特尔的 OpenCL 驱动程序和英特尔编译器。OpenCL 代码大约比 CPU 代码慢 5 倍。编译器为复制循环提供以下消息:

loop was transformed to memset or memcpy.
Run Code Online (Sandbox Code Playgroud)

关于如何使 OpenCL 代码与 C++ 代码同步的任何建议?

谢谢

OpenCL 主机代码:

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cmath>
#include <ctime>
#include <CL/cl.hpp>

int main(int argc, char **argv)
{
    // Create the two input vectors
    const int N = 8192;
    double *in = new double[N*N]; 
    double *out = new double[N*N];

    for(int i = 0; i < …
Run Code Online (Sandbox Code Playgroud)

c++ arrays performance opencl

2
推荐指数
1
解决办法
4077
查看次数

标签 统计

arrays ×1

c++ ×1

opencl ×1

performance ×1