-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP][FIX] Ensure thread states do not crash on the GPU
The nested parallelism causes thread states which still do not properly work but at least don't crash anymore.
- Loading branch information
Showing
4 changed files
with
48 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
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
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
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: %libomptarget-compile-run-and-check-generic | ||
// RUN: %libomptarget-compileopt-run-and-check-generic | ||
|
||
// These are supported and work, but we compute bogus results on the GPU. For | ||
// now we disable the CPU and enable it once the GPU is fixed. | ||
// | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu | ||
// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO | ||
// UNSUPPORTED: x86_64-pc-linux-gnu | ||
// UNSUPPORTED: x86_64-pc-linux-gnu-LTO | ||
|
||
#include <omp.h> | ||
#include <stdio.h> | ||
|
||
int main() { | ||
// TODO: Test all ICVs | ||
int lvl = 333, tid = 666, nt = 999; | ||
#pragma omp target teams map(tofrom : lvl, tid, nt) num_teams(2) | ||
{ | ||
if (omp_get_team_num() == 0) { | ||
#pragma omp parallel num_threads(128) | ||
if (omp_get_thread_num() == 17) { | ||
#pragma omp parallel num_threads(64) | ||
if (omp_get_thread_num() == omp_get_num_threads() - 1) { | ||
lvl = omp_get_level(); | ||
tid = omp_get_thread_num(); | ||
nt = omp_get_num_threads(); | ||
} | ||
} | ||
} | ||
} | ||
// TODO: This is wrong, but at least it doesn't crash | ||
// CHECK: lvl: 333, tid: 666, nt: 999 | ||
printf("lvl: %i, tid: %i, nt: %i\n", lvl, tid, nt); | ||
return 0; | ||
} |