Skip to content

Commit 01224e7

Browse files
authored
Merge pull request #186 from gonzalobg/prepare_scan
2 parents 200f453 + b635718 commit 01224e7

8 files changed

+565
-548
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ endmacro()
3131
# the final executable name
3232
set(EXE_NAME babelstream)
3333

34-
# for chrono and some basic CXX features, models can overwrite this if required
35-
set(CMAKE_CXX_STANDARD 11)
34+
# for chrono, make_unique, and some basic CXX features, models can overwrite this if required
35+
set(CMAKE_CXX_STANDARD 14)
3636

3737
if (NOT CMAKE_BUILD_TYPE)
3838
message("No CMAKE_BUILD_TYPE specified, defaulting to 'Release'")

src/Stream.h

-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ template <class T>
2020
class Stream
2121
{
2222
public:
23-
2423
virtual ~Stream(){}
2524

2625
// Kernels
@@ -35,10 +34,8 @@ class Stream
3534
// Copy memory between host and device
3635
virtual void init_arrays(T initA, T initB, T initC) = 0;
3736
virtual void read_arrays(std::vector<T>& a, std::vector<T>& b, std::vector<T>& c) = 0;
38-
3937
};
4038

41-
4239
// Implementation specific device functions
4340
void listDevices(void);
4441
std::string getDeviceName(const int);

src/StreamModels.h

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
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+
}

src/Unit.h

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#pragma once
2+
#include <iostream>
3+
4+
// Units for output:
5+
struct Unit {
6+
enum class Kind { MegaByte, GigaByte, TeraByte, MibiByte, GibiByte, TebiByte };
7+
8+
Kind value;
9+
10+
explicit Unit(Kind v) : value(v) {}
11+
12+
double fmt(double bytes) const {
13+
switch(value) {
14+
case Kind::MibiByte: return std::pow(2.0, -20.0) * bytes;
15+
case Kind::MegaByte: return 1.0E-6 * bytes;
16+
case Kind::GibiByte: return std::pow(2.0, -30.0) * bytes;
17+
case Kind::GigaByte: return 1.0E-9 * bytes;
18+
case Kind::TebiByte: return std::pow(2.0, -40.0) * bytes;
19+
case Kind::TeraByte: return 1.0E-12 * bytes;
20+
default: std::cerr << "Unimplemented!" << std::endl; std::abort();
21+
}
22+
}
23+
24+
char const* str() const {
25+
switch(value) {
26+
case Kind::MibiByte: return "MiB";
27+
case Kind::MegaByte: return "MB";
28+
case Kind::GibiByte: return "GiB";
29+
case Kind::GigaByte: return "GB";
30+
case Kind::TebiByte: return "TiB";
31+
case Kind::TeraByte: return "TB";
32+
default: std::cerr << "Unimplemented!" << std::endl; std::abort();
33+
}
34+
}
35+
};

0 commit comments

Comments
 (0)