同时运行两个具有相同数量循环的for循环,涉及两个GPU上的GPU和CPU任务 [英] Concurrently running two for loops with same number of loop cycles involving GPU and CPU tasks on two GPU

查看:503
本文介绍了同时运行两个具有相同数量循环的for循环,涉及两个GPU上的GPU和CPU任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 for 循环在我的代码运行相同数量的循环。这两个循环是独立的(每个循环在不同的输入数据上工作)。在一个循环中,有CPU功能和几个内核不同时运行。

I have two for loops in my code running the same number of loop cycles. These two loops are independent (each loop works on different input data). Within one loop, there are CPU functions and several kernels not running concurrently.

我可以在不同的GPU上执行这些迭代吗?

Can I run these iterations on separate GPUs?

推荐答案

您可以在两个不同的GPU上分别运行涉及的内核。

You can run the involved kernels separately on two different GPUs.

您必须注意CPU处理在两个GPU的部分结果上的同步。由于存在顺序部分,在使用 2 2 的最大可能加速因子> GPU。

You have to take care about synchronization of the CPU processings on the partial outcomes of the two GPUs. Due to the presence of a sequential part, you will perhaps not experience the maximum possible speedup factor of 2 when working with 2 GPUs.

从CUDA 4.0开始,您可以使用 cudaSetDevice()设置与给定设备,而不需要创建流以启用多gpu处理。

Starting with CUDA 4.0, you can use cudaSetDevice() to set the current context corresponding to a given device without the need of creating streams to enable multi-gpu processing.

这篇关于同时运行两个具有相同数量循环的for循环,涉及两个GPU上的GPU和CPU任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆