From 60073f2b76e3148ac741a2308ef0ac1decf770c3 Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Mon, 20 Nov 2023 17:08:05 +0100 Subject: [PATCH] Support oneAPI SYCL --- examples/alpaka/nbody/nbody.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/alpaka/nbody/nbody.cpp b/examples/alpaka/nbody/nbody.cpp index b90355d8db..6512a2051a 100644 --- a/examples/alpaka/nbody/nbody.cpp +++ b/examples/alpaka/nbody/nbody.cpp @@ -27,15 +27,25 @@ constexpr auto steps = 5; ///< number of steps to calculate constexpr auto allowRsqrt = true; // rsqrt can be way faster, but less accurate constexpr auto runUpate = true; // run update step. Useful to disable for benchmarking the move step. -#if defined(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED) || defined(ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED) -# if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED) -# error Cannot enable CUDA together with other backends -# endif +#if defined(ALPAKA_ACC_CPU_B_SEQ_T_SEQ_ENABLED) || defined(ALPAKA_ACC_CPU_B_OMP2_T_SEQ_ENABLED) \ + || (defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_CPU)) +# define ANY_CPU_ENABLED 1 +#endif +#if defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED) \ + || (defined(ALPAKA_ACC_SYCL_ENABLED) && defined(ALPAKA_SYCL_ONEAPI_GPU)) +# define ANY_GPU_ENABLED 1 +#endif + +#if ANY_CPU_ENABLED && ANY_GPU_ENABLED +# error Cannot enable CPU and GPU backends at the same time +#endif + +#if ANY_CPU_ENABLED constexpr auto elementsPerThread = xsimd::batch::size; constexpr auto threadsPerBlock = 1; constexpr auto sharedElementsPerBlock = 1; constexpr auto aosoaLanes = xsimd::batch::size; // vectors -#elif defined(ALPAKA_ACC_GPU_CUDA_ENABLED) || defined(ALPAKA_ACC_GPU_HIP_ENABLED) +#elif ANY_GPU_ENABLED constexpr auto threadsPerBlock = 256; constexpr auto sharedElementsPerBlock = 512; constexpr auto elementsPerThread = 1;