From 015bde8d5a46f32979c00dbb1feb4b3d80729c44 Mon Sep 17 00:00:00 2001 From: skallweitNV <64953474+skallweitNV@users.noreply.github.com> Date: Fri, 4 Nov 2022 17:34:53 +0100 Subject: Add AdapterLUID to identify GPU adapters (#2492) * Add AdapterLUID to identify GPU adapters * Remove adapter option in render-test --- tools/gfx/cuda/cuda-device.cpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'tools/gfx/cuda/cuda-device.cpp') 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(buffer); - + List blobData; blobData.setCount((Index)size); -- cgit v1.2.3