Skip to content

Vk cuda interop#274

Open
kevyuu wants to merge 9 commits intomasterfrom
vk_cuda_interop
Open

Vk cuda interop#274
kevyuu wants to merge 9 commits intomasterfrom
vk_cuda_interop

Conversation

@kevyuu
Copy link
Copy Markdown
Contributor

@kevyuu kevyuu commented Apr 23, 2026

Vk Cuda Interop Sample test

Comment thread 76_CudaInterop/main.cpp
}

#define ASSERT_NV_SUCCESS(expr, log) { auto re = check_nv_err((expr), cudaHandler, m_logger, __FILE__, __LINE__, log); assert(re); }

Copy link
Copy Markdown
Member

@devshgraphicsprogramming devshgraphicsprogramming May 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might want to make an nbl/examples/cuda for this

Comment thread 76_CudaInterop/main.cpp
Comment on lines +52 to +83
smart_refctd_ptr<CCUDAHandler> cudaHandler;
smart_refctd_ptr<CCUDADevice> cudaDevice;

IQueue* queue;


// a device filter helps you create a set of physical devices that satisfy your requirements in terms of features, limits etc.
virtual void filterDevices(core::set<video::IPhysicalDevice*>& physicalDevices) const
{
device_base_t::filterDevices(physicalDevices);
auto& cuDevices = cudaHandler->getAvailableDevices();
std::erase_if(physicalDevices, [&cuDevices](auto pdev) {
return cuDevices.end() == std::find_if(cuDevices.begin(), cuDevices.end(), [pdev](auto& cuDev) { return !memcmp(pdev->getProperties().deviceUUID, &cuDev.uuid, 16); });
});
}

bool onAppInitialized(smart_refctd_ptr<ISystem>&& system) override
{
// Remember to call the base class initialization!
if (!asset_base_t::onAppInitialized(smart_refctd_ptr(system)))
return false;

cudaHandler = CCUDAHandler::create(m_system.get(), smart_refctd_ptr<ILogger>(m_logger));
if (!cudaHandler)
return logFail("Could not create a CUDA handler!");

if (!device_base_t::onAppInitialized(std::move(system)))
return false;

cudaDevice = cudaHandler->createDevice(smart_refctd_ptr_dynamic_cast<CVulkanConnection>(m_api), m_physicalDevice);
if (!cudaDevice)
return logFail("Could not create a CUDA Device!");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add to application_templates ? MonoCUDADeviceApplciation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically whatever you need for your CUDA GEMM 1 and 4 bit example, commonalize into the application_templates and examples/cuda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants