问题
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.
Can I run these iterations on separate GPUs?
回答1:
You can run the involved kernels separately on two different GPUs.
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.
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.
来源:https://stackoverflow.com/questions/18607430/concurrently-running-two-for-loops-with-same-number-of-loop-cycles-involving-gpu