Skip to content
This repository was archived by the owner on Mar 28, 2023. It is now read-only.

Commit 813b2f6

Browse files
authored
[SYCL][CUDA] Enable printf test for CUDA (#1096)
This path allows to enable printf testing for CUDA by avoiding the vector format specifiers (%v), which are actually not supported by CUDA printf.
1 parent fd36103 commit 813b2f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

SYCL/DeviceLib/built-ins/printf.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// UNSUPPORTED: cuda || hip
2-
// CUDA and HIP don't support printf.
1+
// UNSUPPORTED: hip
2+
// HIP doesn't support printf.
3+
// CUDA doesn't support vector format specifiers ("%v").
34
//
45
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out
56
// RUN: %HOST_RUN_PLACEHOLDER %t.out %HOST_CHECK_PLACEHOLDER
@@ -59,7 +60,7 @@ int main() {
5960
{
6061
// You can declare format string in non-global scope, but in this case
6162
// static keyword is required
62-
static const CONSTANT char format[] = "%f\n";
63+
static const CONSTANT char format[] = "%.1f\n";
6364
ext::oneapi::experimental::printf(format, 33.4f);
6465
ext::oneapi::experimental::printf(format, -33.4f);
6566
}
@@ -68,8 +69,8 @@ int main() {
6869

6970
// Vectors
7071
sycl::vec<int, 4> v4{5, 6, 7, 8};
71-
#ifdef __SYCL_DEVICE_ONLY__
72-
// On device side, vectors can be printed via native OpenCL types:
72+
#if defined(__SYCL_DEVICE_ONLY__) && defined(__SPIR__)
73+
// On SPIRV devices, vectors can be printed via native OpenCL types:
7374
using ocl_int4 = sycl::vec<int, 4>::vector_t;
7475
{
7576
static const CONSTANT char format[] = "%v4d\n";
@@ -83,7 +84,7 @@ int main() {
8384
(int32_t)v4.x());
8485
}
8586
#else
86-
// On host side you always have to print them by-element:
87+
// Otherwise you always have to print them by-element:
8788
ext::oneapi::experimental::printf(format_vec, (int32_t)v4.x(),
8889
(int32_t)v4.y(), (int32_t)v4.z(),
8990
(int32_t)v4.w());

0 commit comments

Comments
 (0)