Minor code cleanup
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
runtime/src/kmp_runtime.cpp | ||
---|---|---|
5537 ↗ | (On Diff #128968) | Is there a reason for not putting this into the __kmp_free_implicit_task function? |
runtime/src/kmp_tasking.cpp | ||
---|---|---|
990 ↗ | (On Diff #128968) | Moving above task=NULL here makes the data race visible. My suggestion: kmp_taskdata_t *task = NULL; <atomic_swap>(task, thread->th.th_current_task); if (task && task->td_dephash) { ... Whatever "atomic swap" function would be applicable. |
runtime/src/kmp_runtime.cpp | ||
---|---|---|
5537 ↗ | (On Diff #128968) | There are cases where the thread structure is cleaned to be re-used, then the zeroing makes sense. So to me it looks logical to have the assignment here. |
runtime/src/kmp_tasking.cpp | ||
990 ↗ | (On Diff #128968) | Sorry, I haven't got what is the data race you are talking about. |
runtime/src/kmp_runtime.cpp | ||
---|---|---|
5537 ↗ | (On Diff #128968) | This is the only place, where __kmp_free_implicit_task is called. So semantically, there is no difference for moving the assignment into the function. |
runtime/src/kmp_tasking.cpp | ||
990 ↗ | (On Diff #128968) | Moving above assignment into the function: void __kmp_free_implicit_task(kmp_info_t *thread) { kmp_taskdata_t *task = thread->th.th_current_task; if (task && task->td_dephash) { __kmp_dephash_free(thread, task->td_dephash); task->td_dephash = NULL; } thread->th.th_current_task = NULL; } From the comment in above code I understood, that various threads might call this function with the same argument? |
runtime/src/kmp_runtime.cpp | ||
---|---|---|
5537 ↗ | (On Diff #128968) | There is another use of this function in __kmp_reap_thread that does not nullify th_current_task after it. |
runtime/src/kmp_tasking.cpp | ||
---|---|---|
990 ↗ | (On Diff #128968) | In the context of __kmp_free_thread the assignment to NULL is safe. The context of __kmp_free_thread is either being called by a master thread allocating or changing team size under a lock, or freeing non-hot teams, so there should be no race. |