@@ -17,82 +17,6 @@ using SemaphoreId = uint32_t;
17
17
// / actual.
18
18
using MemoryId = uint32_t ;
19
19
20
- using TriggerType = uint64_t ;
21
- constexpr TriggerType TriggerData = 0x1 ; // Trigger a data transfer.
22
- constexpr TriggerType TriggerFlag = 0x2 ; // Trigger a signaling.
23
- constexpr TriggerType TriggerSync = 0x4 ; // Trigger a flush.
24
-
25
- constexpr unsigned int TriggerBitsSize = 32 ;
26
- constexpr unsigned int TriggerBitsOffset = 32 ;
27
- constexpr unsigned int TriggerBitsMemoryId = 9 ;
28
- constexpr unsigned int TriggerBitsType = 3 ;
29
- constexpr unsigned int TriggerBitsSemaphoreId = 10 ;
30
- constexpr unsigned int TriggerBitsFifoReserved = 1 ;
31
-
32
- // / Basic structure of each work element in the FIFO.
33
- union ChannelTrigger {
34
- ProxyTrigger value;
35
- // The summation of number of bits must be 128 or less.
36
- struct {
37
- // First 64 bits: value[0]
38
- uint64_t size : TriggerBitsSize;
39
- uint64_t srcOffset : TriggerBitsOffset;
40
- uint64_t : (64 - TriggerBitsSize - TriggerBitsOffset); // ensure 64-bit alignment
41
- // Second 64 bits: value[1]
42
- uint64_t dstOffset : TriggerBitsOffset;
43
- uint64_t srcMemoryId : TriggerBitsMemoryId;
44
- uint64_t dstMemoryId : TriggerBitsMemoryId;
45
- uint64_t type : TriggerBitsType;
46
- uint64_t semaphoreId : TriggerBitsSemaphoreId;
47
- uint64_t : (64 - TriggerBitsOffset - TriggerBitsMemoryId - TriggerBitsMemoryId - TriggerBitsType -
48
- TriggerBitsSemaphoreId - TriggerBitsFifoReserved); // ensure 64-bit alignment
49
- uint64_t reserved : TriggerBitsFifoReserved;
50
- } fields;
51
-
52
- #if defined(MSCCLPP_DEVICE_COMPILE)
53
- // / Default constructor.
54
- MSCCLPP_INLINE ChannelTrigger () = default ;
55
-
56
- // / Copy constructor.
57
- MSCCLPP_DEVICE_INLINE ChannelTrigger (ProxyTrigger value) : value (value) {}
58
-
59
- // / Constructor.
60
- // / @param type The type of the trigger.
61
- // / @param dst The destination memory region.
62
- // / @param dstOffset The offset into the destination memory region.
63
- // / @param src The source memory region.
64
- // / @param srcOffset The offset into the source memory region.
65
- // / @param bytes The bytes of the transfer.
66
- // / @param semaphoreId The ID of the semaphore.
67
- MSCCLPP_DEVICE_INLINE ChannelTrigger (TriggerType type, MemoryId dst, uint64_t dstOffset, MemoryId src,
68
- uint64_t srcOffset, uint64_t bytes, int semaphoreId) {
69
- MSCCLPP_ASSERT_DEVICE (type < (1ULL << TriggerBitsType), " type is too large" );
70
- MSCCLPP_ASSERT_DEVICE (dst < (1ULL << TriggerBitsMemoryId), " dst is too large" );
71
- MSCCLPP_ASSERT_DEVICE (dstOffset < (1ULL << TriggerBitsOffset), " dstOffset is too large" );
72
- MSCCLPP_ASSERT_DEVICE (src < (1ULL << TriggerBitsMemoryId), " src is too large" );
73
- MSCCLPP_ASSERT_DEVICE (srcOffset < (1ULL << TriggerBitsOffset), " srcOffset is too large" );
74
- MSCCLPP_ASSERT_DEVICE (bytes != 0 , " bytes must not be zero" );
75
- MSCCLPP_ASSERT_DEVICE (bytes < (1ULL << TriggerBitsSize), " bytes is too large" );
76
- MSCCLPP_ASSERT_DEVICE (semaphoreId < (1ULL << TriggerBitsSemaphoreId), " semaphoreId is too large" );
77
- constexpr uint64_t maskSize = (1ULL << TriggerBitsSize) - 1 ;
78
- constexpr uint64_t maskSrcOffset = (1ULL << TriggerBitsOffset) - 1 ;
79
- constexpr uint64_t maskDstOffset = (1ULL << TriggerBitsOffset) - 1 ;
80
- constexpr uint64_t maskSrcMemoryId = (1ULL << TriggerBitsMemoryId) - 1 ;
81
- constexpr uint64_t maskDstMemoryId = (1ULL << TriggerBitsMemoryId) - 1 ;
82
- constexpr uint64_t maskType = (1ULL << TriggerBitsType) - 1 ;
83
- constexpr uint64_t maskSemaphoreId = (1ULL << TriggerBitsSemaphoreId) - 1 ;
84
- value.fst = (((srcOffset & maskSrcOffset) << TriggerBitsSize) + (bytes & maskSize));
85
- value.snd = (((((((((semaphoreId & maskSemaphoreId) << TriggerBitsType) + ((uint64_t )type & maskType))
86
- << TriggerBitsMemoryId) +
87
- (dst & maskDstMemoryId))
88
- << TriggerBitsMemoryId) +
89
- (src & maskSrcMemoryId))
90
- << TriggerBitsOffset) +
91
- (dstOffset & maskDstOffset));
92
- }
93
- #endif // defined(MSCCLPP_DEVICE_COMPILE)
94
- };
95
-
96
20
struct BasePortChannelDeviceHandle {
97
21
SemaphoreId semaphoreId_;
98
22
@@ -111,77 +35,77 @@ struct BasePortChannelDeviceHandle {
111
35
112
36
#if defined(MSCCLPP_DEVICE_COMPILE)
113
37
// / Push a TriggerData to the FIFO.
114
- // / @param dst The destination memory region.
38
+ // / @param dstId The ID of destination memory region.
115
39
// / @param dstOffset The offset into the destination memory region.
116
- // / @param src The source memory region.
40
+ // / @param srcId The ID of source memory region.
117
41
// / @param srcOffset The offset into the source memory region.
118
42
// / @param size The size of the transfer.
119
- MSCCLPP_DEVICE_INLINE void put (MemoryId dst, uint64_t dstOffset, MemoryId src, uint64_t srcOffset, uint64_t size) {
120
- fifo_.push (ChannelTrigger (TriggerData, dst, dstOffset, src, srcOffset, size, semaphoreId_).value );
43
+ MSCCLPP_DEVICE_INLINE void put (MemoryId dstId, uint64_t dstOffset, MemoryId srcId, uint64_t srcOffset,
44
+ uint64_t size) {
45
+ fifo_.push ({TriggerData, dstId, dstOffset, srcId, srcOffset, size, semaphoreId_});
121
46
}
122
47
123
48
// / Push a TriggerData to the FIFO.
124
- // / @param dst The destination memory region.
125
- // / @param src The source memory region.
49
+ // / @param dstId The ID of destination memory region.
50
+ // / @param srcId The ID of source memory region.
126
51
// / @param offset The common offset into the destination and source memory regions.
127
52
// / @param size The size of the transfer.
128
- MSCCLPP_DEVICE_INLINE void put (MemoryId dst , MemoryId src , uint64_t offset, uint64_t size) {
129
- put (dst , offset, src , offset, size);
53
+ MSCCLPP_DEVICE_INLINE void put (MemoryId dstId , MemoryId srcId , uint64_t offset, uint64_t size) {
54
+ put (dstId , offset, srcId , offset, size);
130
55
}
131
56
132
57
// / Push a TriggerFlag to the FIFO.
133
- MSCCLPP_DEVICE_INLINE void signal () { fifo_.push (ChannelTrigger ( TriggerFlag, 0 , 0 , 0 , 0 , 1 , semaphoreId_). value ); }
58
+ MSCCLPP_DEVICE_INLINE void signal () { fifo_.push ({ TriggerFlag, 0 , 0 , 0 , 0 , 1 , semaphoreId_} ); }
134
59
135
60
// / Push a TriggerData and a TriggerFlag at the same time to the FIFO.
136
- // / @param dst The destination memory region.
61
+ // / @param dstId The ID of destination memory region.
137
62
// / @param dstOffset The offset into the destination memory region.
138
- // / @param src The source memory region.
63
+ // / @param srcId The ID of source memory region.
139
64
// / @param srcOffset The offset into the source memory region.
140
65
// / @param size The size of the transfer.
141
- MSCCLPP_DEVICE_INLINE void putWithSignal (MemoryId dst , uint64_t dstOffset, MemoryId src , uint64_t srcOffset,
66
+ MSCCLPP_DEVICE_INLINE void putWithSignal (MemoryId dstId , uint64_t dstOffset, MemoryId srcId , uint64_t srcOffset,
142
67
uint64_t size) {
143
- fifo_.push (ChannelTrigger ( TriggerData | TriggerFlag, dst , dstOffset, src , srcOffset, size, semaphoreId_). value );
68
+ fifo_.push ({ TriggerData | TriggerFlag, dstId , dstOffset, srcId , srcOffset, size, semaphoreId_} );
144
69
}
145
70
146
71
// / Push a TriggerData and a TriggerFlag at the same time to the FIFO.
147
- // / @param dst The destination memory region.
148
- // / @param src The source memory region.
72
+ // / @param dstId The ID of destination memory region.
73
+ // / @param srcId The ID of source memory region.
149
74
// / @param offset The common offset into the destination and source memory regions.
150
75
// / @param size The size of the transfer.
151
- MSCCLPP_DEVICE_INLINE void putWithSignal (MemoryId dst , MemoryId src , uint64_t offset, uint64_t size) {
152
- putWithSignal (dst , offset, src , offset, size);
76
+ MSCCLPP_DEVICE_INLINE void putWithSignal (MemoryId dstId , MemoryId srcId , uint64_t offset, uint64_t size) {
77
+ putWithSignal (dstId , offset, srcId , offset, size);
153
78
}
154
79
155
80
// / Push a TriggerData, a TriggerFlag, and a TriggerSync at the same time to the FIFO.
156
- // / @param dst The destination memory region.
81
+ // / @param dstId The ID of destination memory region.
157
82
// / @param dstOffset The offset into the destination memory region.
158
- // / @param src The source memory region.
83
+ // / @param srcId The ID of source memory region.
159
84
// / @param srcOffset The offset into the source memory region.
160
85
// / @param size The size of the transfer.
161
86
// / @param maxSpinCount The maximum number of spin counts before asserting. Never assert if negative.
162
- MSCCLPP_DEVICE_INLINE void putWithSignalAndFlush (MemoryId dst, uint64_t dstOffset, MemoryId src, uint64_t srcOffset,
163
- uint64_t size, int64_t maxSpinCount = 1000000 ) {
164
- uint64_t curFifoHead = fifo_.push (
165
- ChannelTrigger (TriggerData | TriggerFlag | TriggerSync, dst, dstOffset, src, srcOffset, size, semaphoreId_)
166
- .value );
87
+ MSCCLPP_DEVICE_INLINE void putWithSignalAndFlush (MemoryId dstId, uint64_t dstOffset, MemoryId srcId,
88
+ uint64_t srcOffset, uint64_t size, int64_t maxSpinCount = 1000000 ) {
89
+ uint64_t curFifoHead =
90
+ fifo_.push ({TriggerData | TriggerFlag | TriggerSync, dstId, dstOffset, srcId, srcOffset, size, semaphoreId_});
167
91
fifo_.sync (curFifoHead, maxSpinCount);
168
92
}
169
93
170
94
// / Push a TriggerData, a TriggerFlag, and a TriggerSync at the same time to the FIFO.
171
- // / @param dst The destination memory region.
172
- // / @param src The source memory region.
95
+ // / @param dstId The ID of destination memory region.
96
+ // / @param srcId The ID of source memory region.
173
97
// / @param offset The common offset into the destination and source memory regions.
174
98
// / @param size The size of the transfer.
175
99
// / @param maxSpinCount The maximum number of spin counts before asserting. Never assert if negative.
176
- MSCCLPP_DEVICE_INLINE void putWithSignalAndFlush (MemoryId dst , MemoryId src , uint64_t offset, uint64_t size,
100
+ MSCCLPP_DEVICE_INLINE void putWithSignalAndFlush (MemoryId dstId , MemoryId srcId , uint64_t offset, uint64_t size,
177
101
int64_t maxSpinCount = 1000000 ) {
178
- putWithSignalAndFlush (dst , offset, src , offset, size, maxSpinCount);
102
+ putWithSignalAndFlush (dstId , offset, srcId , offset, size, maxSpinCount);
179
103
}
180
104
181
105
// / Push a TriggerSync to the FIFO.
182
106
// / @param maxSpinCount The maximum number of spin counts before asserting. Never assert if negative.
183
107
MSCCLPP_DEVICE_INLINE void flush (int64_t maxSpinCount = 1000000 ) {
184
- uint64_t curFifoHead = fifo_.push (ChannelTrigger ( TriggerSync, 0 , 0 , 0 , 0 , 1 , semaphoreId_). value );
108
+ uint64_t curFifoHead = fifo_.push ({ TriggerSync, 0 , 0 , 0 , 0 , 1 , semaphoreId_} );
185
109
fifo_.sync (curFifoHead, maxSpinCount);
186
110
}
187
111
0 commit comments