| [ Web Proxy ] |
| Viewing: https://raw.githubusercontent.com/ModuleWorks/taskflow/task_isolation/docs/CUDASTDSingleTask.html | [Back] [Original] |
Taskflow provides a standard template method for running a callable using a single GPU thread.
You need to include the header file, taskflow/cuda/algorithm/for_each.hpp, for creating a single-threaded task.
#include <taskflow/cuda/algorithm/for_each.hpp>
You can launch a kernel with only one GPU thread running it, which is handy when you want to set up a single or a few variables that do not need multiple threads. The following example creates a single-task kernel that sets a device variable to 1.
tf::cudaStream stream; tf::cudaDefaultExecutionPolicy policy(stream); // launch the single-task kernel asynchronously through the policy tf::cuda_single_task(policy, [gpu_variable] __device__ () { *gpu_Variable = 1; }); // wait for the kernel completes stream.synchronize();
Since the callable runs on GPU, it must be declared with a __device__ specifier.
Search for symbols, directories, files, pages or
modules. You can omit any prefix from the symbol or file path; adding a
: or / suffix lists all members of given symbol or
directory.
Use ↓ / ↑ to navigate through the list, Enter to go. Tab autocompletes common prefix, you can copy a link to the result using L while M produces a Markdown link.
Taskflow handbook is part of the Taskflow project, copyright Dr. Tsung-Wei Huang, 2018–2025.
Generated by Doxygen 1.12.0 and m.css.
| Web Proxy Viewer | New URL | Original Page |