harmonize-python 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- harmonize/__init__.py +65 -0
- harmonize/__main__.py +39 -0
- harmonize/adapt.py +105 -0
- harmonize/array.py +588 -0
- harmonize/atomics.py +206 -0
- harmonize/codegen.py +409 -0
- harmonize/config.py +220 -0
- harmonize/cpp/async/future.h +64 -0
- harmonize/cpp/async/mod.h +9 -0
- harmonize/cpp/async/promise.h +747 -0
- harmonize/cpp/harmonize.h +4 -0
- harmonize/cpp/mem/mod.h +14 -0
- harmonize/cpp/mem/work.h +168 -0
- harmonize/cpp/preamble/adapt.h +162 -0
- harmonize/cpp/preamble/mod.h +133 -0
- harmonize/cpp/program/async.h +2923 -0
- harmonize/cpp/program/event.h +560 -0
- harmonize/cpp/program/mod.h +84 -0
- harmonize/cpp/sync/barrier.h +704 -0
- harmonize/cpp/sync/mod.h +9 -0
- harmonize/cpp/util/cli.h +510 -0
- harmonize/cpp/util/host.h +287 -0
- harmonize/cpp/util/iter.h +565 -0
- harmonize/cpp/util/mem.h +1050 -0
- harmonize/cpp/util/mod.h +148 -0
- harmonize/diagnostics.py +487 -0
- harmonize/errors.py +12 -0
- harmonize/logging.py +51 -0
- harmonize/pointer.py +108 -0
- harmonize/prim.py +59 -0
- harmonize/printing.py +104 -0
- harmonize/python/__init__.py +48 -0
- harmonize/runtime.py +1501 -0
- harmonize/templates.py +369 -0
- harmonize/timing.py +10 -0
- harmonize/types.py +16 -0
- harmonize_python-0.1.0.dist-info/METADATA +161 -0
- harmonize_python-0.1.0.dist-info/RECORD +40 -0
- harmonize_python-0.1.0.dist-info/WHEEL +4 -0
- harmonize_python-0.1.0.dist-info/licenses/LICENSE +29 -0
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
#ifndef HARMONIZE_UTIL_ITER
|
|
4
|
+
#define HARMONIZE_UTIL_ITER
|
|
5
|
+
|
|
6
|
+
namespace util {
|
|
7
|
+
|
|
8
|
+
namespace iter {
|
|
9
|
+
|
|
10
|
+
template<typename INDEX_TYPE> struct GroupIter;
|
|
11
|
+
template<typename INDEX_TYPE> struct AtomicIter;
|
|
12
|
+
|
|
13
|
+
template<typename INDEX_TYPE>
|
|
14
|
+
struct Iter
|
|
15
|
+
{
|
|
16
|
+
|
|
17
|
+
typedef INDEX_TYPE IndexType;
|
|
18
|
+
|
|
19
|
+
IndexType value;
|
|
20
|
+
IndexType limit;
|
|
21
|
+
|
|
22
|
+
__host__ __device__ Iter<IndexType> (IndexType v, IndexType l)
|
|
23
|
+
: value(v), limit(l) {}
|
|
24
|
+
|
|
25
|
+
__host__ __device__ Iter<IndexType> ( Iter<IndexType> const &iter )
|
|
26
|
+
: value(iter.value)
|
|
27
|
+
, limit(iter.limit)
|
|
28
|
+
{}
|
|
29
|
+
|
|
30
|
+
Iter<IndexType> () = default;
|
|
31
|
+
|
|
32
|
+
__device__ void reset(IndexType start_val, IndexType limit_val) {
|
|
33
|
+
value = start_val;
|
|
34
|
+
limit = limit_val;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
__host__ __device__ bool step(IndexType& iter_val){
|
|
38
|
+
if( value >= limit ){
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
iter_val = value;
|
|
43
|
+
value += 1;
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
__host__ __device__ Iter<IndexType> leap(IndexType length) {
|
|
49
|
+
IndexType sub_limit = value + length;
|
|
50
|
+
sub_limit = (sub_limit > limit) ? limit : sub_limit;
|
|
51
|
+
IndexType old_value = value;
|
|
52
|
+
value = sub_limit;
|
|
53
|
+
return Iter<IndexType>(old_value,sub_limit);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
__host__ __device__ bool done() const {
|
|
57
|
+
return (value >= limit);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
template<typename INDEX_TYPE>
|
|
65
|
+
struct GroupIter
|
|
66
|
+
{
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
typedef INDEX_TYPE IndexType;
|
|
70
|
+
|
|
71
|
+
IndexType value;
|
|
72
|
+
IndexType limit;
|
|
73
|
+
|
|
74
|
+
__host__ __device__ GroupIter<IndexType> ( Iter<IndexType> iter )
|
|
75
|
+
: value(iter.value)
|
|
76
|
+
, limit(iter.limit)
|
|
77
|
+
{}
|
|
78
|
+
|
|
79
|
+
GroupIter<IndexType> () = default;
|
|
80
|
+
|
|
81
|
+
__device__ void reset(IndexType start_val, IndexType limit_val) {
|
|
82
|
+
__syncthreads();
|
|
83
|
+
if( current_leader() ){
|
|
84
|
+
value = start_val;
|
|
85
|
+
limit = limit_val;
|
|
86
|
+
}
|
|
87
|
+
__syncthreads();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
__device__ bool step(IndexType& iter_val) {
|
|
92
|
+
|
|
93
|
+
if( value < limit ){
|
|
94
|
+
IndexType val = value + threadIdx.x;
|
|
95
|
+
if ( val < limit ){
|
|
96
|
+
iter_val = val;
|
|
97
|
+
}
|
|
98
|
+
__syncthreads();
|
|
99
|
+
if( current_leader() ){
|
|
100
|
+
value += blockDim.x;
|
|
101
|
+
}
|
|
102
|
+
__syncthreads();
|
|
103
|
+
return val < limit;
|
|
104
|
+
}
|
|
105
|
+
return false;
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
__device__ Iter<IndexType> leap(IndexType length) {
|
|
111
|
+
|
|
112
|
+
Iter<IndexType> result(0,0,blockDim.x);
|
|
113
|
+
if( value < limit ){
|
|
114
|
+
IndexType start_val = value + threadIdx.x;
|
|
115
|
+
IndexType limit_val = start_val + blockDim.x * length;
|
|
116
|
+
result.value = (start_val < limit) ? start_val : limit;
|
|
117
|
+
result.limit = (limit_val < limit) ? limit_val : limit;
|
|
118
|
+
__syncthreads();
|
|
119
|
+
if( current_leader() ){
|
|
120
|
+
value += blockDim.x * length;
|
|
121
|
+
}
|
|
122
|
+
__syncthreads();
|
|
123
|
+
}
|
|
124
|
+
return result;
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
__host__ __device__ bool done() const {
|
|
130
|
+
return ( value >= limit );
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
template<typename INDEX_TYPE>
|
|
139
|
+
struct AtomicIter
|
|
140
|
+
{
|
|
141
|
+
|
|
142
|
+
typedef INDEX_TYPE IndexType;
|
|
143
|
+
|
|
144
|
+
IndexType value;
|
|
145
|
+
IndexType limit;
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
AtomicIter<IndexType> () = default;
|
|
149
|
+
|
|
150
|
+
__host__ __device__ AtomicIter<IndexType> ( IndexType start_val, IndexType limit_val )
|
|
151
|
+
: value(start_val)
|
|
152
|
+
, limit(limit_val)
|
|
153
|
+
{}
|
|
154
|
+
|
|
155
|
+
__host__ __device__ AtomicIter<IndexType> ( Iter<IndexType> iter )
|
|
156
|
+
: value(iter.value)
|
|
157
|
+
, limit(iter.limit)
|
|
158
|
+
{}
|
|
159
|
+
|
|
160
|
+
__host__ __device__ AtomicIter<IndexType>& operator= ( Iter<IndexType> iter )
|
|
161
|
+
{
|
|
162
|
+
value = iter.value;
|
|
163
|
+
limit = iter.limit;
|
|
164
|
+
return *this;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
__device__ void reset(IndexType start_val, IndexType limit_val) {
|
|
168
|
+
__threadfence_system();
|
|
169
|
+
IndexType old_limit = atomicAdd(&limit,0);
|
|
170
|
+
if( old_limit > limit_val ){
|
|
171
|
+
IndexType old_old_limit = atomicExch(&limit,limit_val);
|
|
172
|
+
} else if ( old_limit < limit_val ) {
|
|
173
|
+
IndexType old_old_value = atomicExch(&value,limit_val);
|
|
174
|
+
IndexType old_old_limit = atomicExch(&limit,limit_val);
|
|
175
|
+
}
|
|
176
|
+
IndexType old_old_start = atomicExch(&value,start_val);
|
|
177
|
+
__threadfence_system();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
__device__ Iter<IndexType> leap(IndexType leap_size) {
|
|
182
|
+
|
|
183
|
+
IndexType start_val = 0;
|
|
184
|
+
IndexType limit_val = 0;
|
|
185
|
+
|
|
186
|
+
if( value < limit ){
|
|
187
|
+
start_val = atomicAdd(&value,leap_size);
|
|
188
|
+
limit_val = start_val + leap_size;
|
|
189
|
+
start_val = (start_val < limit) ? start_val : limit;
|
|
190
|
+
limit_val = (limit_val < limit) ? limit_val : limit;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return Iter<IndexType>(start_val,limit_val);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
__device__ bool step(IndexType& iter_val) {
|
|
198
|
+
|
|
199
|
+
if( value >= limit ){
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
__threadfence_system();
|
|
204
|
+
IndexType try_val = atomicAdd(&value,1);
|
|
205
|
+
__threadfence_system();
|
|
206
|
+
|
|
207
|
+
if( try_val >= limit ){
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
iter_val = try_val;
|
|
212
|
+
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
__device__ bool done() const {
|
|
217
|
+
__threadfence();
|
|
218
|
+
bool result = ( value >= limit );
|
|
219
|
+
__threadfence();
|
|
220
|
+
return result;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
template< typename T, template < typename > typename ITER_TYPE = Iter, typename INDEX_TYPE = unsigned int >
|
|
229
|
+
struct ArrayIter {
|
|
230
|
+
|
|
231
|
+
typedef INDEX_TYPE IndexType;
|
|
232
|
+
typedef ITER_TYPE<IndexType> IterType;
|
|
233
|
+
|
|
234
|
+
T* array;
|
|
235
|
+
IterType iter;
|
|
236
|
+
|
|
237
|
+
template<template < typename > class OTHER_ITER_TYPE>
|
|
238
|
+
__host__ __device__ ArrayIter<T,ITER_TYPE,INDEX_TYPE> (ArrayIter<T,OTHER_ITER_TYPE,INDEX_TYPE>&& other_iter)
|
|
239
|
+
: array(other_iter.array)
|
|
240
|
+
, iter(other_iter.iter)
|
|
241
|
+
{}
|
|
242
|
+
|
|
243
|
+
template<template < typename > class OTHER_ITER_TYPE>
|
|
244
|
+
__host__ __device__ ArrayIter<T,ITER_TYPE,INDEX_TYPE>& operator= (ArrayIter<T,OTHER_ITER_TYPE,INDEX_TYPE>&& other_iter)
|
|
245
|
+
{
|
|
246
|
+
array = other_iter.array;
|
|
247
|
+
iter = other_iter.iter;
|
|
248
|
+
return *this;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
__host__ __device__ ArrayIter<T,ITER_TYPE,INDEX_TYPE> (T* adr, IterType other_iter)
|
|
253
|
+
: array(adr)
|
|
254
|
+
, iter (other_iter)
|
|
255
|
+
{}
|
|
256
|
+
|
|
257
|
+
ArrayIter<T,ITER_TYPE,INDEX_TYPE> () = default;
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
__device__ void reset(T* new_array, IterType new_iter) {
|
|
261
|
+
array = new_array;
|
|
262
|
+
iter = new_iter;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
__device__ bool step_val(T &val){
|
|
267
|
+
IndexType index;
|
|
268
|
+
if( iter.step(index) ){
|
|
269
|
+
val = array[index];
|
|
270
|
+
return true;
|
|
271
|
+
}
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
__device__ bool step_idx_val(IndexType& idx, T &val){
|
|
277
|
+
IndexType index;
|
|
278
|
+
if( iter.step(index) ){
|
|
279
|
+
idx = index;
|
|
280
|
+
val = array[index];
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
__device__ bool step_ptr(T *&val){
|
|
288
|
+
IndexType index;
|
|
289
|
+
if( iter.step(index) ){
|
|
290
|
+
val = &(array[index]);
|
|
291
|
+
return true;
|
|
292
|
+
}
|
|
293
|
+
return false;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
__device__ bool step_idx_ptr(IndexType& idx, T *&val){
|
|
297
|
+
IndexType index;
|
|
298
|
+
if( iter.step(index) ){
|
|
299
|
+
idx = index;
|
|
300
|
+
val = &(array[index]);
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
__device__ ArrayIter<T,Iter,IndexType> leap(IndexType leap_size) {
|
|
307
|
+
return ArrayIter<T,Iter,IndexType>(array,iter.leap(leap_size));
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
__device__ bool done() {
|
|
311
|
+
return iter.done();
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
template<typename T, typename INDEX_TYPE = unsigned int>
|
|
321
|
+
struct IOBuffer
|
|
322
|
+
{
|
|
323
|
+
|
|
324
|
+
typedef INDEX_TYPE IndexType;
|
|
325
|
+
|
|
326
|
+
bool toggle; //True means A is in and B is out. False indicates vice-versa.
|
|
327
|
+
T *data_a;
|
|
328
|
+
T *data_b;
|
|
329
|
+
|
|
330
|
+
IndexType capacity;
|
|
331
|
+
|
|
332
|
+
AtomicIter<IndexType> input_iter;
|
|
333
|
+
AtomicIter<IndexType> output_iter;
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
__host__ __device__ IOBuffer<T,IndexType>()
|
|
337
|
+
: capacity(0)
|
|
338
|
+
, toggle(false)
|
|
339
|
+
, input_iter (0,0)
|
|
340
|
+
, output_iter(0,0)
|
|
341
|
+
, data_a(NULL)
|
|
342
|
+
, data_b(NULL)
|
|
343
|
+
{}
|
|
344
|
+
|
|
345
|
+
__device__ IOBuffer<T,IndexType>(IndexType cap,T* a, T* b)
|
|
346
|
+
: capacity(cap)
|
|
347
|
+
, toggle(false)
|
|
348
|
+
, input_iter (0,0 )
|
|
349
|
+
, output_iter(0,cap)
|
|
350
|
+
, data_a(a)
|
|
351
|
+
, data_b(b)
|
|
352
|
+
{}
|
|
353
|
+
|
|
354
|
+
__host__ IOBuffer<T,IndexType>(IndexType cap)
|
|
355
|
+
: capacity(cap)
|
|
356
|
+
, toggle(false)
|
|
357
|
+
, input_iter (0,0 )
|
|
358
|
+
, output_iter(0,cap)
|
|
359
|
+
{}
|
|
360
|
+
|
|
361
|
+
__host__ void host_init()
|
|
362
|
+
{
|
|
363
|
+
data_a = host::hardMalloc<T>( capacity );
|
|
364
|
+
data_b = host::hardMalloc<T>( capacity );
|
|
365
|
+
#ifdef HARMONIZE_ALLOC_DEBUG
|
|
366
|
+
printf("{{Allocated IO buffers at %p and %p, both with size %zu}}\n",data_a,data_b,capacity*sizeof(T));
|
|
367
|
+
#endif
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
__host__ void host_free()
|
|
371
|
+
{
|
|
372
|
+
#ifdef HARMONIZE_ALLOC_DEBUG
|
|
373
|
+
printf("{{Freeing IO buffers at %p and %p, both with size %zu}}\n",data_a,data_b,capacity*sizeof(T));
|
|
374
|
+
#endif
|
|
375
|
+
if ( data_a != NULL ) {
|
|
376
|
+
host::auto_throw( adapt::GPUrtFree( data_a ) );
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
if ( data_b != NULL ) {
|
|
380
|
+
host::auto_throw( adapt::GPUrtFree( data_b ) );
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
__host__ __device__ T* input_pointer(){
|
|
386
|
+
return toggle ? data_b : data_a;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
__host__ __device__ T* output_pointer(){
|
|
390
|
+
return toggle ? data_a : data_b;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
__device__ ArrayIter<T,Iter,IndexType> pull_span(IndexType pull_size)
|
|
394
|
+
{
|
|
395
|
+
Iter<IndexType> pull_iter = input_iter.leap(pull_size);
|
|
396
|
+
return ArrayIter<T,Iter,IndexType>(input_pointer(),pull_iter);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
__device__ ArrayIter<T,Iter,IndexType> push_span(IndexType push_size)
|
|
400
|
+
{
|
|
401
|
+
Iter<IndexType> push_iter = output_iter.leap(push_size);
|
|
402
|
+
return ArrayIter<T,Iter>(output_pointer(),push_iter);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
__device__ bool pull(T& value){
|
|
406
|
+
__threadfence_system();
|
|
407
|
+
IndexType index;
|
|
408
|
+
if( ! input_iter.step(index) ){
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
value = input_pointer()[index];
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
__device__ bool pull_index(IndexType& index){
|
|
416
|
+
__threadfence_system();
|
|
417
|
+
return input_iter.step(index);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
__device__ bool push(T value){
|
|
421
|
+
__threadfence_system();
|
|
422
|
+
IndexType index;
|
|
423
|
+
if( ! input_iter.step(index) ){
|
|
424
|
+
return false;
|
|
425
|
+
}
|
|
426
|
+
input_pointer()[index] = value;
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
|
|
432
|
+
__device__ bool push_index(IndexType& index){
|
|
433
|
+
__threadfence_system();
|
|
434
|
+
return output_iter.step(index);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
__device__ void flip()
|
|
438
|
+
{
|
|
439
|
+
IndexType in_count = output_iter.value >= capacity ? capacity : output_iter.value;
|
|
440
|
+
input_iter.reset(0,0);
|
|
441
|
+
toggle = !toggle;
|
|
442
|
+
__threadfence_system();
|
|
443
|
+
input_iter.reset(0,in_count);
|
|
444
|
+
output_iter.reset(0,capacity);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
__device__ bool input_empty()
|
|
448
|
+
{
|
|
449
|
+
return input_iter.done();
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
__device__ bool output_full()
|
|
453
|
+
{
|
|
454
|
+
return output_iter.done();
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
__device__ float output_fill_fraction(){
|
|
458
|
+
return ((float) atomicAdd(&(output_iter.value),0u)) / ((float) capacity);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
__device__ float output_fill_fraction_sync(){
|
|
463
|
+
|
|
464
|
+
__shared__ INDEX_TYPE progress;
|
|
465
|
+
|
|
466
|
+
__syncthreads();
|
|
467
|
+
if( threadIdx.x == 0 ){
|
|
468
|
+
progress = atomicAdd(&(output_iter.value),0u);
|
|
469
|
+
}
|
|
470
|
+
__syncthreads();
|
|
471
|
+
|
|
472
|
+
return ((float) progress) / ((float) capacity);
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
#if 0
|
|
480
|
+
template<typename T> bool tie_breaker (T& A, T& B);
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
// Experimental population control mechanism
|
|
484
|
+
template<typename T, typename INDEX_TYPE = unsigned int, typename HASH_TYPE = unsigned int>
|
|
485
|
+
struct MCPCBuffer {
|
|
486
|
+
|
|
487
|
+
typedef INDEX_TYPE IndexType;
|
|
488
|
+
typedef HASH_TYPE HashType;
|
|
489
|
+
|
|
490
|
+
struct LinkType {
|
|
491
|
+
HashType hash;
|
|
492
|
+
IndexType next;
|
|
493
|
+
T data;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
struct LinkJump {
|
|
497
|
+
HashType hash;
|
|
498
|
+
IndexType index;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
IndexType capacity;
|
|
502
|
+
IndexType overflow;
|
|
503
|
+
|
|
504
|
+
|
|
505
|
+
IOBuffer<LinkType,IndexType> link_buffer;
|
|
506
|
+
|
|
507
|
+
IOBuffer<LinkJump,IndexType> jump_buffer;
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
__device__ bool pull(T& dest){
|
|
511
|
+
while ( ! jump_buffer.input_empty() ) {
|
|
512
|
+
IndexType idx;
|
|
513
|
+
if ( jump_buffer.pull_idx(idx) ){
|
|
514
|
+
LinkJump& jump = jump_buffer.input_ptr[idx];
|
|
515
|
+
if( jump.next == Adr<IndexType>::null ){
|
|
516
|
+
continue;
|
|
517
|
+
}
|
|
518
|
+
T best = link_buffer[];
|
|
519
|
+
while () {
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
jump.hash = 0;
|
|
523
|
+
jump.index = Adr<IndexType>::null;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return false;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
__device__ void push(T value, IndexType index, HashType hash){
|
|
530
|
+
HashType atom_max = atomicMax(&(LinkJump[index].hash),hash);
|
|
531
|
+
if ( atom_max <= hash ) {
|
|
532
|
+
|
|
533
|
+
} else if ( atom_max == hash ) {
|
|
534
|
+
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
__device__ void flip(){
|
|
541
|
+
link_buffer.flip();
|
|
542
|
+
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
__device__ bool input_empty() {
|
|
546
|
+
return link_buffer.input_empty();
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
__device__ bool output_full() {
|
|
550
|
+
return link_buffer.output_full();
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
};
|
|
554
|
+
#endif
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
|
|
563
|
+
#endif
|
|
564
|
+
|
|
565
|
+
|