diff options
| author | skallweitNV <64953474+skallweitNV@users.noreply.github.com> | 2022-11-04 17:34:53 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-04 17:34:53 +0100 |
| commit | 015bde8d5a46f32979c00dbb1feb4b3d80729c44 (patch) | |
| tree | b95713bb080d0fbcb11d9b2519b9166e11fe5dde /tools/gfx/cuda/cuda-device.cpp | |
| parent | 9a3a4b08c8817905c2f608549c0e57216f8068c5 (diff) | |
Add AdapterLUID to identify GPU adapters (#2492)
* Add AdapterLUID to identify GPU adapters
* Remove adapter option in render-test
Diffstat (limited to 'tools/gfx/cuda/cuda-device.cpp')
| -rw-r--r-- | tools/gfx/cuda/cuda-device.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp index 32454109b..76538cfad 100644 --- a/tools/gfx/cuda/cuda-device.cpp +++ b/tools/gfx/cuda/cuda-device.cpp @@ -150,13 +150,30 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) SLANG_RETURN_ON_FAIL(_initCuda(reportType)); - SLANG_RETURN_ON_FAIL(_findMaxFlopsDeviceIndex(&m_deviceIndex)); + if (desc.adapterLUID) + { + int deviceCount = -1; + cuDeviceGetCount(&deviceCount); + for (int deviceIndex = 0; deviceIndex < deviceCount; ++deviceIndex) + { + if (cuda::getAdapterLUID(deviceIndex) == *desc.adapterLUID) + { + m_deviceIndex = deviceIndex; + break; + } + } + if (m_deviceIndex >= deviceCount) + return SLANG_E_INVALID_ARG; + } + else + { + SLANG_RETURN_ON_FAIL(_findMaxFlopsDeviceIndex(&m_deviceIndex)); + } + SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL(cudaSetDevice(m_deviceIndex), reportType); m_context = new CUDAContext(); - int count = -1; - cuDeviceGetCount(&count); SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGet(&m_device, m_deviceIndex)); SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL( @@ -1103,7 +1120,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::readBufferResource( ISlangBlob** outBlob) { auto bufferImpl = static_cast<BufferResourceImpl*>(buffer); - + List<uint8_t> blobData; blobData.setCount((Index)size); |
