-
Notifications
You must be signed in to change notification settings - Fork 52
/
CLWrapper.h
56 lines (45 loc) · 1.46 KB
/
CLWrapper.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
// Copyright Hugh Perkins 2014, 2015 hughperkins at gmail
//
// This Source Code Form is subject to the terms of the Mozilla Public License,
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
// obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
// #include "EasyCL.h"
#include "EasyCL_export.h"
namespace easycl {
//class cl_mem;
//class cl_int;
class EasyCL;
class EasyCL_EXPORT CLWrapper {
protected:
const int N;
const bool onHost;
bool onDevice;
bool deviceDirty; // have we updated the device copy, without copying to host?
cl_mem devicearray;
EasyCL *cl; // NOT owned by this object, so dont free!
cl_int error;
public:
virtual int getElementSize() = 0;
virtual void *getHostArray() = 0;
virtual void const *getHostArrayConst() = 0;
virtual void copyTo(CLWrapper *target);
virtual void copyTo(CLWrapper *target, int srcOffset, int dstOffset, int count);
CLWrapper(int N, EasyCL *cl);
CLWrapper(const CLWrapper &source);
CLWrapper &operator=(const CLWrapper &two);
virtual ~CLWrapper();
virtual EasyCL *getCl();
virtual void deleteFromDevice();
virtual cl_mem *getDeviceArray();
virtual void createOnDevice();
virtual void copyToHost();
virtual cl_mem getBuffer();
virtual void copyToDevice();
virtual int size();
virtual bool isOnHost();
virtual bool isOnDevice();
virtual bool isDeviceDirty();
virtual void markDeviceDirty();
};
}