-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCLSourceArray.hpp
80 lines (70 loc) · 1.68 KB
/
CLSourceArray.hpp
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef TCL_SOURCE_ARRAY_HPP
#define TCL_SOURCE_ARRAY_HPP
#include <vector>
#include "CLSource.hpp"
namespace tcl
{
/**
* 複数ソースコードを使いたい場合の配列
*/
class CLSourceArray
{
private:
std::vector<CLSource> sources;
std::vector<size_t> sourceSizes;
std::vector<const char*> sourcePtrs;
std::string kernelName;
SourceType type;
public:
/**
* ソースコードのポインタ配列を返す
* \return ソースコードのポインタ配列
*/
inline const char** Pointers() const {
// これ安全かどうかわからないなぁ……
return sourcePtrs.begin()._Ptr;
}
/**
* ソースコードのサイズの配列を返す
* \return ソースコードのサイズの配列
*/
inline const size_t* Sizes() const {
return sourceSizes.begin()._Ptr;
}
/**
* ソースコードの種類を返す
* \return ソースコードの種類を返す
*/
inline const SourceType Type() const {
return type;
}
/**
* カーネルの名前を返す
* \return カーネルの名前を返す
*/
inline const std::string KernelName() const {
return kernelName;
}
/**
* 利用したいソースコードを追加します
* \param[in] filename ソースコードのファイル名
*/
inline void Append(const std::string& filename) {
sources.emplace_back(CLSource(filename, kernelName, type));
auto s = sources[sources.size() - 1];
sourcePtrs.emplace_back(s.Code().c_str());
sourceSizes.emplace_back(s.Size());
}
public:
/**
* 一つのカーネルに複数のソースコードを実行させたいときに使います
* \param[in] kernelName エントリーポイントとなるカーネル名
* \param[in] useSourceCodeType ソースコードの種類
*/
CLSourceArray(const std::string& kernelName, const SourceType useSourceCodeType)
: type(useSourceCodeType), kernelName(kernelName)
{
}
};
}
#endif