forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP] Have hidden helper team allocate new OS threads only (llvm#8…
…7119) The hidden helper team pre-allocates the gtid space [1, num_hidden_helpers] (inclusive). If regular host threads are allocated, then put back in the thread pool, then the hidden helper team is initialized, the hidden helper team tries to allocate the threads from the thread pool with gtids higher than [1, num_hidden_helpers]. Instead, have the hidden helper team fork OS threads so the correct gtid range used for hidden helper threads. Fixes: llvm#87117
- Loading branch information
Showing
2 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
openmp/runtime/test/tasking/hidden_helper_task/issue-87117.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %libomp-compile | ||
// RUN: env KMP_HOT_TEAMS_MODE=0 KMP_HOT_TEAMS_MAX_LEVEL=1 %libomp-run | ||
// | ||
// Force the defaults of: | ||
// KMP_HOT_TEAMS_MODE=0 means free extra threads after parallel | ||
// involving non-hot team | ||
// KMP_HOT_TEAMS_MAX_LEVEL=1 means only the initial outer team | ||
// is a hot team. | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <omp.h> | ||
|
||
int main() { | ||
int a; | ||
omp_set_max_active_levels(2); | ||
// This nested parallel creates extra threads on the thread pool | ||
#pragma omp parallel num_threads(2) | ||
{ | ||
#pragma omp parallel num_threads(2) | ||
{ | ||
#pragma omp atomic | ||
a++; | ||
} | ||
} | ||
|
||
// Causes assert if hidden helper thread tries to allocate from thread pool | ||
// instead of creating new OS threads | ||
#pragma omp parallel num_threads(1) | ||
{ | ||
#pragma omp target nowait | ||
{ a++; } | ||
} | ||
|
||
return EXIT_SUCCESS; | ||
} |