From: Artem Zhmurov Date: Tue, 17 Nov 2020 14:22:41 +0000 (+0300) Subject: Make corresponding device active before each TestDevice is created X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=84e7aa59e54ece4d4b8a6e3a65dcd524c97bd718;p=alexxy%2Fgromacs.git 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. --- 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)); }