Script.thread_group¶
- Script.thread_group(thread_begin, num_threads)¶
Create a thread group context.
This method creates a thread group context that is used to narrow down the threads that execute the instructions within the context.
Syntax:
class MyScript(tilus.Script): def __call__(self, ...): # instructions executed by all threads in the thread block ... with self.thread_group(thread_begin, num_threads=num_threads): # instructions executed by threads in the specified thread group starting from `thread_begin` # and including `num_threads` threads ... with self.thread_group(...): # we can continue to partition the current thread group into sub thread groups ... ... self.sync() # synchronize all threads in the current thread group ... # instructions executed by all threads in the thread block ...
At the root level of the kernel, there is one thread group that includes all threads in the thread block. We can partition the threads in the current thread group into multiple sub thread groups by specifying the first thread using thread_begin and the number of threads in each sub thread group using the num_threads parameter.
All instructions within the context will be executed by all threads in the specified thread group.
- Parameters:
thread_begin (int) – The index of the first thread in the thread group.
num_threads (int) – The number of threads in the thread group.
- Returns:
ret – The thread group context created.
- Return type:
ThreadGroupContext