jgbit / vuda

VUDA is a header-only library based on Vulkan that provides a CUDA Runtime API interface for writing GPU-accelerated applications.
MIT License
865 stars 35 forks source link

Yet another syntax of launch… (C++ only) #20

Open ghost opened 3 years ago

ghost commented 3 years ago

In my opinion, a very strange startup syntax has been chosen.

#if defined(__NVCC__)
    add<<<blocks, threads>>>(dev_a, dev_b, dev_c, N);
#else
    const int stream_id = 0;
    vuda::launchKernel("add.spv", "main", stream_id, blocks, threads, dev_a, dev_b, dev_c, N);
#endif

I would suggest something like this… (C++ only)

auto add = vuda::makeKernel<int*,int*,int*,int>("add.spv", "main"); // import function
add(stream_id, blocks, threads)(dev_a, dev_b, dev_c, N); // use calling operator

I also offer a similar API for the C language. It is not clear just how the launch kernel will look in the C version.

jgbit commented 3 years ago

Thank you for your suggestion. I agree, the syntax is not ideal and it has a somewhat legacy look by now. When I come around to revisit it, I will take your suggested syntax into consideration.