【发布时间】:2011-05-25 22:52:44
【问题描述】:
我的算法包括两个步骤:
- 数据生成。在这一步中,我循环生成数据数组作为一些函数结果
- 数据处理。对于这一步,我编写了 OpenCL 内核,它处理上一步生成的数据数组。
现在第一步在 CPU 上运行,因为它很难并行化。我想在 GPU 上运行它,因为生成的每一步都需要一些时间。我想立即为已经生成的数据运行第二步。
我可以在单独的线程中从当前运行的内核运行另一个 opencl 内核吗?还是在调用者内核的某个线程中运行?
一些伪代码来说明我的观点:
__kernel second(__global int * data, int index) {
//work on data[i]. This process takes a lot of time
}
__kernel first(__global int * data, const int length) {
for (int i = 0; i < length; i++) {
// generate data and store it in data[i]
// This kernel will be launched in some thread that caller or in new thread?
// If in same thread, there are ways to launch it in separated thread?
second(data, i);
}
}
【问题讨论】:
标签: concurrency opencl gpgpu gpu