|
| 1 | +#pragma once |
| 2 | +#include <memory> |
| 3 | + |
| 4 | +#if defined(CUDA) |
| 5 | +#include "CUDAStream.h" |
| 6 | +#elif defined(STD_DATA) |
| 7 | +#include "STDDataStream.h" |
| 8 | +#elif defined(STD_INDICES) |
| 9 | +#include "STDIndicesStream.h" |
| 10 | +#elif defined(STD_RANGES) |
| 11 | +#include "STDRangesStream.hpp" |
| 12 | +#elif defined(TBB) |
| 13 | +#include "TBBStream.hpp" |
| 14 | +#elif defined(THRUST) |
| 15 | +#include "ThrustStream.h" |
| 16 | +#elif defined(HIP) |
| 17 | +#include "HIPStream.h" |
| 18 | +#elif defined(HC) |
| 19 | +#include "HCStream.h" |
| 20 | +#elif defined(OCL) |
| 21 | +#include "OCLStream.h" |
| 22 | +#elif defined(USE_RAJA) |
| 23 | +#include "RAJAStream.hpp" |
| 24 | +#elif defined(KOKKOS) |
| 25 | +#include "KokkosStream.hpp" |
| 26 | +#elif defined(ACC) |
| 27 | +#include "ACCStream.h" |
| 28 | +#elif defined(SYCL) |
| 29 | +#include "SYCLStream.h" |
| 30 | +#elif defined(SYCL2020) |
| 31 | +#include "SYCLStream2020.h" |
| 32 | +#elif defined(OMP) |
| 33 | +#include "OMPStream.h" |
| 34 | +#elif defined(FUTHARK) |
| 35 | +#include "FutharkStream.h" |
| 36 | +#endif |
| 37 | + |
| 38 | +template <typename T> |
| 39 | +std::unique_ptr<Stream<T>> make_stream(int array_size, int deviceIndex) { |
| 40 | +#if defined(CUDA) |
| 41 | + // Use the CUDA implementation |
| 42 | + return std::make_unique<CUDAStream<T>>(array_size, deviceIndex); |
| 43 | + |
| 44 | +#elif defined(HIP) |
| 45 | + // Use the HIP implementation |
| 46 | + return std::make_unique<HIPStream<T>>(array_size, deviceIndex); |
| 47 | + |
| 48 | +#elif defined(HC) |
| 49 | + // Use the HC implementation |
| 50 | + return std::make_unique<HCStream<T>>(array_size, deviceIndex); |
| 51 | + |
| 52 | +#elif defined(OCL) |
| 53 | + // Use the OpenCL implementation |
| 54 | + return std::make_unique<OCLStream<T>>(array_size, deviceIndex); |
| 55 | + |
| 56 | +#elif defined(USE_RAJA) |
| 57 | + // Use the RAJA implementation |
| 58 | + return std::make_unique<RAJAStream<T>>(array_size, deviceIndex); |
| 59 | + |
| 60 | +#elif defined(KOKKOS) |
| 61 | + // Use the Kokkos implementation |
| 62 | + return std::make_unique<KokkosStream<T>>(array_size, deviceIndex); |
| 63 | + |
| 64 | +#elif defined(STD_DATA) |
| 65 | + // Use the C++ STD data-oriented implementation |
| 66 | + return std::make_unique<STDDataStream<T>>(array_size, deviceIndex); |
| 67 | + |
| 68 | +#elif defined(STD_INDICES) |
| 69 | + // Use the C++ STD index-oriented implementation |
| 70 | + return std::make_unique<STDIndicesStream<T>>(array_size, deviceIndex); |
| 71 | + |
| 72 | +#elif defined(STD_RANGES) |
| 73 | + // Use the C++ STD ranges implementation |
| 74 | + return std::make_unique<STDRangesStream<T>>(array_size, deviceIndex); |
| 75 | + |
| 76 | +#elif defined(TBB) |
| 77 | + // Use the C++20 implementation |
| 78 | + return std::make_unique<TBBStream<T>>(array_size, deviceIndex); |
| 79 | + |
| 80 | +#elif defined(THRUST) |
| 81 | + // Use the Thrust implementation |
| 82 | + return std::make_unique<ThrustStream<T>>(array_size, deviceIndex); |
| 83 | + |
| 84 | +#elif defined(ACC) |
| 85 | + // Use the OpenACC implementation |
| 86 | + return std::make_unique<ACCStream<T>>(array_size, deviceIndex); |
| 87 | + |
| 88 | +#elif defined(SYCL) || defined(SYCL2020) |
| 89 | + // Use the SYCL implementation |
| 90 | + return std::make_unique<SYCLStream<T>>(array_size, deviceIndex); |
| 91 | + |
| 92 | +#elif defined(OMP) |
| 93 | + // Use the OpenMP implementation |
| 94 | + return std::make_unique<OMPStream<T>>(array_size, deviceIndex); |
| 95 | + |
| 96 | +#elif defined(FUTHARK) |
| 97 | + // Use the Futhark implementation |
| 98 | + return std::make_unique<FutharkStream<T>>(array_size, deviceIndex); |
| 99 | + |
| 100 | +#else |
| 101 | + |
| 102 | + #error unknown benchmark |
| 103 | + |
| 104 | +#endif |
| 105 | +} |
0 commit comments