Skip to content

Commit

Permalink
Use Kokkos::printf unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
aprokop committed Apr 9, 2024
1 parent c24b152 commit 423b0af
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 56 deletions.
35 changes: 11 additions & 24 deletions benchmarks/dbscan/ArborX_DBSCANVerification.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,8 @@ bool verifyCorePointsNonnegativeIndex(ExecutionSpace const &exec_space,
bool self_is_core_point = (offset(i + 1) - offset(i) >= core_min_size);
if (self_is_core_point && labels(i) < 0)
{
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("Core point is marked as noise: %d [%d]\n", i, labels(i));
Kokkos::printf("Core point is marked as noise: %d [%d]\n", i,
labels(i));
update++;
}
},
Expand Down Expand Up @@ -83,14 +79,10 @@ bool verifyConnectedCorePointsShareIndex(ExecutionSpace const &exec_space,

if (neigh_is_core_point && labels(i) != labels(j))
{
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("Connected cores do not belong to the same cluster: "
"%d [%d] -> %d [%d]\n",
i, labels(i), j, labels(j));
Kokkos::printf(
"Connected cores do not belong to the same cluster: "
"%d [%d] -> %d [%d]\n",
i, labels(i), j, labels(j));
update++;
}
}
Expand Down Expand Up @@ -137,24 +129,19 @@ bool verifyBorderAndNoisePoints(ExecutionSpace const &exec_space,
}
}

#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif

// Border point must be connected to a core point
if (is_border && !have_shared_core)
{
printf("Border point does not belong to a cluster: %d [%d]\n", i,
labels(i));
Kokkos::printf(
"Border point does not belong to a cluster: %d [%d]\n", i,
labels(i));
update++;
}
// Noise points must have index -1
if (!is_border && labels(i) != -1)
{
printf("Noise point does not have index -1: %d [%d]\n", i,
labels(i));
Kokkos::printf("Noise point does not have index -1: %d [%d]\n", i,
labels(i));
update++;
}
}
Expand Down
28 changes: 4 additions & 24 deletions examples/callback/example_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ struct PrintfCallback
KOKKOS_FUNCTION void operator()(Predicate, int primitive,
OutputFunctor const &out) const
{
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("Found %d from functor\n", primitive);
Kokkos::printf("Found %d from functor\n", primitive);
out(primitive);
}
};
Expand Down Expand Up @@ -97,12 +92,7 @@ int main(int argc, char *argv[])
bvh, ExecutionSpace{}, FirstOctant{},
KOKKOS_LAMBDA(auto /*predicate*/, int primitive,
auto /*output_functor*/) {
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("Found %d from generic lambda\n", primitive);
Kokkos::printf("Found %d from generic lambda\n", primitive);
},
values, offsets);
#endif
Expand All @@ -119,12 +109,7 @@ int main(int argc, char *argv[])
bvh, ExecutionSpace{}, NearestToOrigin{k},
KOKKOS_LAMBDA(auto /*predicate*/, int primitive,
auto /*output_functor*/) {
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("Found %d from generic lambda\n", primitive);
Kokkos::printf("Found %d from generic lambda\n", primitive);
},
values, offsets);
#endif
Expand All @@ -139,12 +124,7 @@ int main(int argc, char *argv[])
bvh.query(
ExecutionSpace{}, FirstOctant{},
KOKKOS_LAMBDA(auto /*predicate*/, int j) {
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("%d %d %d\n", ++c(), -1, j);
Kokkos::printf("%d %d %d\n", ++c(), -1, j);
});
#endif
}
Expand Down
11 changes: 3 additions & 8 deletions examples/raytracing/example_raytracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,9 @@ int main(int argc, char *argv[])
fabs(energy_intersects(i));
if (abs_error > rel_tol * fabs(energy_intersects(i)))
{
#if KOKKOS_VERSION >= 40200
using Kokkos::printf;
#elif defined(__SYCL_DEVICE_ONLY__)
using sycl::ext::oneapi::experimental::printf;
#endif
printf("%d: %f != %f, relative error: %f\n", i,
energy_ordered_intersects(i), energy_intersects(i),
abs_error / fabs(energy_intersects(i)));
Kokkos::printf("%d: %f != %f, relative error: %f\n", i,
energy_ordered_intersects(i), energy_intersects(i),
abs_error / fabs(energy_intersects(i)));
++error;
}
},
Expand Down

0 comments on commit 423b0af

Please sign in to comment.