-
Notifications
You must be signed in to change notification settings - Fork 1
/
Algorithms.h
58 lines (42 loc) · 2.05 KB
/
Algorithms.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef DEVICE_ALGORITHMS_HPP
#define DEVICE_ALGORITHMS_HPP
#include "AbstractAPI.h"
namespace device {
enum class ReductionType { Add, Max, Min };
class DeviceInstance;
class Algorithms {
public:
friend DeviceInstance;
template <typename T> T reduceVector(T *buffer, size_t size, ReductionType type, void* streamPtr);
template <typename T> void scaleArray(T *devArray, T scalar, size_t numElements, void* streamPtr);
template <typename T> void fillArray(T *devArray, T scalar, size_t numElements, void* streamPtr);
void incrementalAdd(real** out, real *base, size_t increment, size_t numElements, void* streamPtr);
void setToValue(real** out, real value, size_t elementSize, size_t numElements, void* streamPtr);
void touchMemory(real *ptr, size_t size, bool clean, void* streamPtr);
void touchBatchedMemory(real **basePtr,
unsigned elementSize,
unsigned numElements,
bool clean,
void* streamPtr);
void streamBatchedData(real **baseSrcPtr,
real **baseDstPtr,
unsigned elementSize,
unsigned numElements,
void* streamPtr);
void accumulateBatchedData(real **baseSrcPtr,
real **baseDstPtr,
unsigned elementSize,
unsigned numElements,
void* streamPtr);
template <typename T>
void copyUniformToScatter(T *src, T **dst, size_t srcOffset, size_t copySize, size_t numElements, void* streamPtr);
template <typename T>
void copyScatterToUniform(T **src, T *dst, size_t dstOffset, size_t copySize, size_t numElements, void* streamPtr);
void compareDataWithHost(const real *hostPtr, const real *devPtr, size_t numElements,
const std::string &dataName);
private:
void setDeviceApi(AbstractAPI *configuredApi) { api = configuredApi; }
AbstractAPI *api = nullptr;
};
} // namespace device
#endif // DEVICE_ALGORITHMS_HPP