1
- // ===-- Executor .h - The Executor class -------------------------*- C++ -*-===//
1
+ // ===-- Device .h - The Device class ---- -------------------------*- C++ -*-===//
2
2
//
3
3
// The LLVM Compiler Infrastructure
4
4
//
8
8
// ===----------------------------------------------------------------------===//
9
9
// /
10
10
// / \file
11
- // / The Executor class which represents a single device of a specific platform.
11
+ // / The Device class which represents a single device of a specific platform.
12
12
// /
13
13
// ===----------------------------------------------------------------------===//
14
14
15
- #ifndef STREAMEXECUTOR_EXECUTOR_H
16
- #define STREAMEXECUTOR_EXECUTOR_H
15
+ #ifndef STREAMEXECUTOR_DEVICE_H
16
+ #define STREAMEXECUTOR_DEVICE_H
17
17
18
18
#include " streamexecutor/KernelSpec.h"
19
19
#include " streamexecutor/PlatformInterfaces.h"
@@ -24,10 +24,10 @@ namespace streamexecutor {
24
24
class KernelInterface ;
25
25
class Stream ;
26
26
27
- class Executor {
27
+ class Device {
28
28
public:
29
- explicit Executor (PlatformExecutor *PExecutor );
30
- virtual ~Executor ();
29
+ explicit Device (PlatformDevice *PDevice );
30
+ virtual ~Device ();
31
31
32
32
// / Gets the kernel implementation for the underlying platform.
33
33
virtual Expected<std::unique_ptr<KernelInterface>>
@@ -42,15 +42,15 @@ class Executor {
42
42
template <typename T>
43
43
Expected<GlobalDeviceMemory<T>> allocateDeviceMemory (size_t ElementCount) {
44
44
Expected<GlobalDeviceMemoryBase> MaybeBase =
45
- PExecutor ->allocateDeviceMemory (ElementCount * sizeof (T));
45
+ PDevice ->allocateDeviceMemory (ElementCount * sizeof (T));
46
46
if (!MaybeBase)
47
47
return MaybeBase.takeError ();
48
48
return GlobalDeviceMemory<T>(*MaybeBase);
49
49
}
50
50
51
51
// / Frees memory previously allocated with allocateDeviceMemory.
52
52
template <typename T> Error freeDeviceMemory (GlobalDeviceMemory<T> Memory) {
53
- return PExecutor ->freeDeviceMemory (Memory);
53
+ return PDevice ->freeDeviceMemory (Memory);
54
54
}
55
55
56
56
// / Allocates an array of ElementCount entries of type T in host memory.
@@ -59,15 +59,15 @@ class Executor {
59
59
// / copies on streams. See Stream::thenCopyD2H and Stream::thenCopyH2D.
60
60
template <typename T> Expected<T *> allocateHostMemory (size_t ElementCount) {
61
61
Expected<void *> MaybeMemory =
62
- PExecutor ->allocateHostMemory (ElementCount * sizeof (T));
62
+ PDevice ->allocateHostMemory (ElementCount * sizeof (T));
63
63
if (!MaybeMemory)
64
64
return MaybeMemory.takeError ();
65
65
return static_cast <T *>(*MaybeMemory);
66
66
}
67
67
68
68
// / Frees memory previously allocated with allocateHostMemory.
69
69
template <typename T> Error freeHostMemory (T *Memory) {
70
- return PExecutor ->freeHostMemory (Memory);
70
+ return PDevice ->freeHostMemory (Memory);
71
71
}
72
72
73
73
// / Registers a previously allocated host array of type T for asynchronous
@@ -77,15 +77,15 @@ class Executor {
77
77
// / memory copies on streams. See Stream::thenCopyD2H and Stream::thenCopyH2D.
78
78
template <typename T>
79
79
Error registerHostMemory (T *Memory, size_t ElementCount) {
80
- return PExecutor ->registerHostMemory (Memory, ElementCount * sizeof (T));
80
+ return PDevice ->registerHostMemory (Memory, ElementCount * sizeof (T));
81
81
}
82
82
83
83
// / Unregisters host memory previously registered by registerHostMemory.
84
84
template <typename T> Error unregisterHostMemory (T *Memory) {
85
- return PExecutor ->unregisterHostMemory (Memory);
85
+ return PDevice ->unregisterHostMemory (Memory);
86
86
}
87
87
88
- // / \anchor ExecutorHostSyncCopyGroup
88
+ // / \anchor DeviceHostSyncCopyGroup
89
89
// / \name Host-synchronous device memory copying functions
90
90
// /
91
91
// / These methods block the calling host thread while copying data to or from
@@ -125,9 +125,9 @@ class Executor {
125
125
return make_error (
126
126
" copying too many elements, " + llvm::Twine (ElementCount) +
127
127
" , to a host array of element count " + llvm::Twine (Dst.size ()));
128
- return PExecutor ->synchronousCopyD2H (
129
- Src. getBaseMemory (), Src.getElementOffset () * sizeof (T), Dst. data (), 0 ,
130
- ElementCount * sizeof (T));
128
+ return PDevice ->synchronousCopyD2H (Src. getBaseMemory (),
129
+ Src.getElementOffset () * sizeof (T),
130
+ Dst. data (), 0 , ElementCount * sizeof (T));
131
131
}
132
132
133
133
template <typename T>
@@ -179,9 +179,9 @@ class Executor {
179
179
llvm::Twine (ElementCount) +
180
180
" , to a device array of element count " +
181
181
llvm::Twine (Dst.getElementCount ()));
182
- return PExecutor ->synchronousCopyH2D (Src.data (), 0 , Dst.getBaseMemory (),
183
- Dst.getElementOffset () * sizeof (T),
184
- ElementCount * sizeof (T));
182
+ return PDevice ->synchronousCopyH2D (Src.data (), 0 , Dst.getBaseMemory (),
183
+ Dst.getElementOffset () * sizeof (T),
184
+ ElementCount * sizeof (T));
185
185
}
186
186
187
187
template <typename T>
@@ -234,7 +234,7 @@ class Executor {
234
234
llvm::Twine (ElementCount) +
235
235
" , to a device array of element count " +
236
236
llvm::Twine (Dst.getElementCount ()));
237
- return PExecutor ->synchronousCopyD2D (
237
+ return PDevice ->synchronousCopyD2D (
238
238
Src.getBaseMemory (), Src.getElementOffset () * sizeof (T),
239
239
Dst.getBaseMemory (), Dst.getElementOffset () * sizeof (T),
240
240
ElementCount * sizeof (T));
@@ -292,9 +292,9 @@ class Executor {
292
292
// /@} End host-synchronous device memory copying functions
293
293
294
294
private:
295
- PlatformExecutor *PExecutor ;
295
+ PlatformDevice *PDevice ;
296
296
};
297
297
298
298
} // namespace streamexecutor
299
299
300
- #endif // STREAMEXECUTOR_EXECUTOR_H
300
+ #endif // STREAMEXECUTOR_DEVICE_H
0 commit comments