-
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.
[Libomptarget] Add RPC-based
printf
implementation for OpenMP (#85638)
Summary: This patch adds an implementation of `printf` that's provided by the GPU C library runtime. This `pritnf` currently implemented using the same wrapper handling that OpenMP sets up. This will be removed once we have proper varargs support. This `printf` differs from the one CUDA offers in that it is synchronous and uses a finite size. Additionally we support pretty much every format specifier except the `%n` option. Depends on #85331
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// RUN: %libomptarget-compile-run-and-check-generic | ||
|
||
// REQUIRES: libc | ||
|
||
#include <stdio.h> | ||
|
||
int main() { | ||
// CHECK: PASS | ||
#pragma omp target | ||
{ printf("PASS\n"); } | ||
|
||
// CHECK: PASS | ||
#pragma omp target | ||
{ printf("%s\n", "PASS"); } | ||
|
||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
// CHECK: PASS | ||
#pragma omp target teams num_teams(4) | ||
#pragma omp parallel num_threads(2) | ||
{ printf("PASS\n"); } | ||
|
||
// CHECK: PASS | ||
char str[] = {'P', 'A', 'S', 'S', '\0'}; | ||
#pragma omp target map(to : str) | ||
{ printf("%s\n", str); } | ||
|
||
// CHECK: 11111111111 | ||
#pragma omp target | ||
{ printf("%s%-.0f%4b%c%ld\n", "1111", 1.0, 0xf, '1', 1lu); } | ||
} |