[Support][Parallel] Initialize threadIndex and add assertion checking its usage.
That patch adds a check for threadIndex being used with only threads created by ThreadPoolExecutor. This helps catch two types of errors: 1. If a thread is created not by ThreadPoolExecutor its index may clash with the index of another thread. Using threadIndex, in that case, may lead to a data race. 2. Index of the main thread(threadIndex == 0) currently clashes with the index of thread0 in ThreadPoolExecutor threads. That may lead to a data race if main thread and thread0 are executed concurrently. This patch allows execution tasks on the main thread only in case parallel::strategy.ThreadsRequested == 1. In all other cases, assertions check that threadIndex != UINT_MAX(i.e. that task is executed on a thread created by ThreadPoolExecutor). Differential Revision: https://reviews.llvm.org/D148916
Loading
Please register or sign in to comment