From dbf0d5713a7b0930f321cf5654976d0506ffee7f Mon Sep 17 00:00:00 2001 From: Eyal Rozenberg Date: Mon, 23 Sep 2024 15:34:09 +0300 Subject: [PATCH] Another promotional code fragment --- README.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 649426de..86f387b8 100644 --- a/README.md +++ b/README.md @@ -128,7 +128,18 @@ Don't you wish you were able to type in, say: auto callback = [&foo] { std::cout << "Hello " << foo << " world!\n"; } my_stream.enqueue.host_invokable(callback); ``` -... and have that just work? Well, now it does! +... and have that just work? And don't you wish CUDA API invocations could be plain and straightforward one-liners? Like this sequence? +```cpp +auto compilation_output = my_program.compile(); +auto module = cuda::module::create(context, compilation_output); +auto my_kernel = module.get_kernel(mangled_kernel_name); +auto gpu_side_buffer = cuda::memory::make_unique_span(device, n); +cuda::memory::copy(gpu_side_buffer, host_side_buffer); +auto launch_config = cuda::launch_config_builder().overall_size(n).block_size(256).build(); +cuda::launch(my_kernel, launch_config, gpu_side_buffer.data()); +cuda::memory::copy(host_side_buffer, gpu_side_buffer); +``` +Well, now all of the above is valid code! :-) To be a little more thorough than just an anecdote, let's relate back to some of the design principles listed above: