-
Notifications
You must be signed in to change notification settings - Fork 744
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL] Support __builtin_printf for SYCL device (#7483)
- Loading branch information
1 parent
7b47ebb
commit d8fd9bc
Showing
3 changed files
with
41 additions
and
2 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
18 changes: 18 additions & 0 deletions
18
clang/test/CodeGenSYCL/remove-restriction-builtin-printf.cpp
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,18 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -emit-llvm %s -o - | FileCheck %s | ||
// This test checks if __builtin_printf is emitted in the IR. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace sycl; | ||
queue q; | ||
|
||
int main() { | ||
q.submit([&](handler &h) { | ||
// CHECK: define {{.*}}spir_kernel {{.*}} | ||
h.single_task<class kernelA>([=]() { | ||
// CHECK: printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef 24) | ||
__builtin_printf("hello, %d\n", 24); | ||
}); | ||
}); | ||
return 0; | ||
} |
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,19 @@ | ||
// RUN: %clang_cc1 -fsycl-is-device -internal-isystem %S/Inputs -sycl-std=2020 -verify -fsyntax-only %s | ||
// This test checks if __builtin_printf does not throw an error when | ||
// called from within device code. | ||
|
||
#include "sycl.hpp" | ||
|
||
using namespace sycl; | ||
queue q; | ||
|
||
int main() { | ||
// expected-no-diagnostics | ||
q.submit([&](handler &h) { | ||
h.single_task<class kernelA>([=]() { | ||
__builtin_printf("hello, %d\n", 23); | ||
}); | ||
}); | ||
return 0; | ||
} | ||
|