Make corresponding device active before each TestDevice is created
commit84e7aa59e54ece4d4b8a6e3a65dcd524c97bd718
authorArtem Zhmurov <zhmurov@gmail.com>
Tue, 17 Nov 2020 14:22:41 +0000 (17 17:22 +0300)
committerSzilárd Páll <pall.szilard@gmail.com>
Mon, 23 Nov 2020 17:56:11 +0000 (23 17:56 +0000)
tree72f02781c527f81fc3efda63a980ef3a08b67f77
parentd9c847c4998350ec323d4396afad574fdeead4b7
Make corresponding device active before each TestDevice is created

When populating the list of GPU devices for tests, the DeviceContext and
DeviceStream objects are created for each TestDevice. In CUDA, the
active device has to be explicitly set by the API since the DeviceStream
is created for the active device. Otherwise, all the streams are created
for the first device. When these streams are later used for the devices
other than first, CUDA API returns an invalid argument error. The bug only
affects unit tests in CUDA builds for systems with more than one GPU.
Does not affect OpenCL/SYCL builds, because they use DeviceContext to
attach the device to the stream (queue).

Fixes #3781, #3782 and #3805.
src/testutils/test_hardware_environment.cpp