From 84e7aa59e54ece4d4b8a6e3a65dcd524c97bd718 Mon Sep 17 00:00:00 2001 From: Artem Zhmurov Date: Tue, 17 Nov 2020 17:22:41 +0300 Subject: [PATCH] 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/src/testutils/test_hardware_environment.cpp b/src/testutils/test_hardware_environment.cpp index 267c73cf27..5a06c35131 100644 --- a/src/testutils/test_hardware_environment.cpp +++ b/src/testutils/test_hardware_environment.cpp @@ -99,6 +99,7 @@ void TestHardwareEnvironment::SetUp() // Constructing contexts for all compatible GPUs - will be empty on non-GPU builds for (const DeviceInformation& compatibleDeviceInfo : getCompatibleDevices(hardwareInfo_->deviceInfoList)) { + setActiveDevice(compatibleDeviceInfo); std::string description = getDeviceInformationString(compatibleDeviceInfo); testDeviceList_.emplace_back(std::make_unique(description.c_str(), compatibleDeviceInfo)); } -- 2.11.4.GIT