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
harmonize/templates.py
ADDED
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
|
|
2
|
+
# String template for the program initialization wrapper
|
|
3
|
+
init_template = """
|
|
4
|
+
extern "C"
|
|
5
|
+
void init_program_{suffix}(
|
|
6
|
+
void *instance_ptr,
|
|
7
|
+
size_t grid_size
|
|
8
|
+
) {{
|
|
9
|
+
auto instance = (typename {short_name}::Instance*) instance_ptr;
|
|
10
|
+
//printf("\\n\\nINIT (instance: %p)\\n\\n",instance_ptr);
|
|
11
|
+
init<{short_name}>(*instance,grid_size);
|
|
12
|
+
util::host::auto_throw(adapt::GPUrtDeviceSynchronize());
|
|
13
|
+
}}
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# String template for the program execution wrapper
|
|
17
|
+
exec_template = """
|
|
18
|
+
#ifndef TIME
|
|
19
|
+
#define TIME
|
|
20
|
+
#include <chrono>
|
|
21
|
+
#endif
|
|
22
|
+
|
|
23
|
+
extern "C"
|
|
24
|
+
void exec_program_{suffix}(
|
|
25
|
+
void *instance_ptr,
|
|
26
|
+
size_t grid_size,
|
|
27
|
+
size_t cycle_count
|
|
28
|
+
) {{
|
|
29
|
+
static int total;
|
|
30
|
+
auto before = std::chrono::steady_clock::now();
|
|
31
|
+
auto instance = (typename {short_name}::Instance*) instance_ptr;
|
|
32
|
+
//printf("\\n\\nEXEC (instance: %p)\\n\\n",instance_ptr);
|
|
33
|
+
exec<{short_name}>(*instance,grid_size,cycle_count);
|
|
34
|
+
util::host::auto_throw(adapt::GPUrtDeviceSynchronize());
|
|
35
|
+
auto after = std::chrono::steady_clock::now();
|
|
36
|
+
int delta = std::chrono::duration_cast<std::chrono::milliseconds>(after-before).count();
|
|
37
|
+
total += delta;
|
|
38
|
+
//printf("Run was %d ms. Total time is %d ms",delta, total);
|
|
39
|
+
}}
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
alloc_event_prog_template = """
|
|
44
|
+
extern "C"
|
|
45
|
+
void *alloc_program_{suffix}(void* device_arg, size_t io_size) {{
|
|
46
|
+
//printf("allocating event program instance\\n");
|
|
47
|
+
auto state = (typename {short_name}::DeviceState) device_arg;
|
|
48
|
+
void *result = new {short_name}::Instance(io_size,state);
|
|
49
|
+
//printf("allocated event program instance:%p\\n",result);
|
|
50
|
+
return result;
|
|
51
|
+
}}
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
alloc_harm_prog_template = """
|
|
55
|
+
extern "C"
|
|
56
|
+
void *alloc_program_{suffix}(void* device_arg, size_t arena_size) {{
|
|
57
|
+
//printf("allocting async program instance\\n");
|
|
58
|
+
auto state = (typename {short_name}::DeviceState) device_arg;
|
|
59
|
+
void *result = new {short_name}::Instance(arena_size,state);
|
|
60
|
+
//printf("allocted async program instance:%p\\n",result);
|
|
61
|
+
return result;
|
|
62
|
+
}}
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
free_prog_template = """
|
|
66
|
+
extern "C"
|
|
67
|
+
void free_program_{suffix}(void* instance_ptr) {{
|
|
68
|
+
auto instance = (typename {short_name}::Instance*) instance_ptr;
|
|
69
|
+
delete instance;
|
|
70
|
+
}}
|
|
71
|
+
"""
|
|
72
|
+
|
|
73
|
+
alloc_state_template = """
|
|
74
|
+
extern "C"
|
|
75
|
+
void *alloc_state_{suffix}() {{
|
|
76
|
+
void *result = nullptr;
|
|
77
|
+
size_t size= sizeof({state_struct});
|
|
78
|
+
//printf("\\n\\n[[allocting async program instance with size:%ld]]\\n",size);
|
|
79
|
+
util::host::auto_throw(adapt::GPUrtMalloc(&result,size));
|
|
80
|
+
//printf("allocated gpu_state:%p\\n",result);
|
|
81
|
+
return result;
|
|
82
|
+
}}
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
load_state_template = """
|
|
86
|
+
extern "C"
|
|
87
|
+
void load_state_{label}_{suffix}(void *host_ptr, void *dev_ptr) {{
|
|
88
|
+
//printf("LOAD {label} {suffix}\\n");
|
|
89
|
+
//printf("cpu_state:%p\\n",host_ptr);
|
|
90
|
+
//printf("gpu_state:%p\\n", dev_ptr);
|
|
91
|
+
void *offset_dev_ptr = (void*)(((char*)dev_ptr)+{offset});
|
|
92
|
+
util::host::auto_throw(adapt::GPUrtMemcpy(
|
|
93
|
+
host_ptr,
|
|
94
|
+
offset_dev_ptr,
|
|
95
|
+
{size},
|
|
96
|
+
adapt::GPUrtMemcpyDeviceToHost
|
|
97
|
+
));
|
|
98
|
+
//size_t *data = (size_t*) host_ptr;
|
|
99
|
+
//for(int i=0; i<10; i++) {{
|
|
100
|
+
// //printf("%zu,",data[i]);
|
|
101
|
+
//}}
|
|
102
|
+
//printf("\\n");
|
|
103
|
+
}}
|
|
104
|
+
"""
|
|
105
|
+
|
|
106
|
+
store_state_template = """
|
|
107
|
+
extern "C"
|
|
108
|
+
void store_state_{label}_{suffix}(void *dev_ptr, void *host_ptr) {{
|
|
109
|
+
//printf("STORE {label} {suffix}\\n");
|
|
110
|
+
//printf("cpu_state:%p\\n",host_ptr);
|
|
111
|
+
//printf("gpu_state:%p\\n", dev_ptr);
|
|
112
|
+
void *offset_dev_ptr = (void*)(((char*)dev_ptr)+{offset});
|
|
113
|
+
//size_t *data = (size_t*) host_ptr;
|
|
114
|
+
//for(int i=0; i<10; i++) {{
|
|
115
|
+
// //printf("%zu,",data[i]);
|
|
116
|
+
//}}
|
|
117
|
+
//printf("\\n");
|
|
118
|
+
util::host::auto_throw(adapt::GPUrtMemcpy(
|
|
119
|
+
offset_dev_ptr,
|
|
120
|
+
host_ptr,
|
|
121
|
+
{size},
|
|
122
|
+
adapt::GPUrtMemcpyHostToDevice
|
|
123
|
+
));
|
|
124
|
+
}}
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
store_pointer_state_template = """
|
|
129
|
+
extern "C"
|
|
130
|
+
void store_pointer_state_{label}_{suffix}(void *dev_ptr, void *host_ptr) {{
|
|
131
|
+
//printf("STORE POINTER {label} {suffix}\\n");
|
|
132
|
+
//printf("cpu_state:%p\\n",host_ptr);
|
|
133
|
+
//printf("gpu_state:%p\\n", dev_ptr);
|
|
134
|
+
void *offset_dev_ptr = (void*)(((char*)dev_ptr)+{offset});
|
|
135
|
+
//size_t *data = (size_t*) host_ptr;
|
|
136
|
+
//for(int i=0; i<10; i++) {{
|
|
137
|
+
// //printf("%zu,",data[i]);
|
|
138
|
+
//}}
|
|
139
|
+
//printf("\\n");
|
|
140
|
+
if ({is_array}) {{
|
|
141
|
+
//printf("Would store %zu bytes (pointer %p) from %p to %p\\n",sizeof(host_ptr),host_ptr,&host_ptr,offset_dev_ptr);
|
|
142
|
+
util::host::auto_throw(adapt::GPUrtMemcpy(
|
|
143
|
+
offset_dev_ptr,
|
|
144
|
+
&host_ptr,
|
|
145
|
+
sizeof(host_ptr),
|
|
146
|
+
adapt::GPUrtMemcpyHostToDevice
|
|
147
|
+
));
|
|
148
|
+
}} else {{
|
|
149
|
+
throw std::runtime_error("Attempted to set indirection of non-array state field.");
|
|
150
|
+
}}
|
|
151
|
+
}}
|
|
152
|
+
"""
|
|
153
|
+
|
|
154
|
+
free_state_template = """
|
|
155
|
+
extern "C"
|
|
156
|
+
void free_state_{suffix}(void *state_ptr) {{
|
|
157
|
+
util::host::auto_throw(adapt::GPUrtFree(state_ptr));
|
|
158
|
+
}}
|
|
159
|
+
"""
|
|
160
|
+
|
|
161
|
+
complete_template = """
|
|
162
|
+
extern "C"
|
|
163
|
+
int complete_{suffix}(void *instance_ptr) {{
|
|
164
|
+
auto instance = (typename {short_name}::Instance*) instance_ptr;
|
|
165
|
+
bool result = instance->complete();
|
|
166
|
+
return result;
|
|
167
|
+
}}
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
clear_flags_template = """
|
|
171
|
+
extern "C"
|
|
172
|
+
void clear_flags_{suffix}(void *instance_ptr) {{
|
|
173
|
+
auto instance = (typename {short_name}::Instance*) instance_ptr;
|
|
174
|
+
//printf("instance is:%p\\n",instance_ptr);
|
|
175
|
+
instance->clear_flags();
|
|
176
|
+
}}
|
|
177
|
+
"""
|
|
178
|
+
|
|
179
|
+
set_device_template = """
|
|
180
|
+
extern "C"
|
|
181
|
+
void set_device_{suffix}(int device) {{
|
|
182
|
+
util::host::auto_throw(adapt::GPUrtSetDevice(device));
|
|
183
|
+
}}
|
|
184
|
+
"""
|
|
185
|
+
|
|
186
|
+
# String template for async function dispatches
|
|
187
|
+
dispatch_template = """
|
|
188
|
+
extern "C" __device__
|
|
189
|
+
int dispatch_{fn}_{kind}_{suffix}(void*fn_param_0{params}){{
|
|
190
|
+
(({short_name}*)fn_param_1)->template {kind}<{fn_type}>({args});
|
|
191
|
+
//printf("{{ {fn} wrapper }}");
|
|
192
|
+
return 0;
|
|
193
|
+
}}
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
# String template for the program execution wrapper
|
|
197
|
+
fn_query_template = """
|
|
198
|
+
extern "C" __device__
|
|
199
|
+
int query_{field}_{suffix}(void *result, void *prog){{
|
|
200
|
+
(*({kind}*)result) = {prefix}(({short_name}*)prog)->template {field}<{fn_type}>();
|
|
201
|
+
return 0;
|
|
202
|
+
}}
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
# String template for the program execution wrapper
|
|
206
|
+
query_template = """
|
|
207
|
+
extern "C" __device__
|
|
208
|
+
int query_{field}_{suffix}(void *result, void *prog){{
|
|
209
|
+
(*({kind}*)result) = {prefix}(({short_name}*)prog)->{field}();
|
|
210
|
+
return 0;
|
|
211
|
+
}}
|
|
212
|
+
"""
|
|
213
|
+
|
|
214
|
+
# String template for field accessors
|
|
215
|
+
accessor_template = """
|
|
216
|
+
extern "C" __device__
|
|
217
|
+
int access_{label}_{suffix}(void* result, void* prog){{
|
|
218
|
+
void*& adr = *(void**)result;
|
|
219
|
+
adr = {prefix}(({short_name}*)prog)->{field};
|
|
220
|
+
adr = {deref}(void*)(((char*)adr)+{offset});
|
|
221
|
+
if(threadIdx.x == 0) {{
|
|
222
|
+
//printf("{{ {label} accessor - offset %d - address %p - would be %p}}",{offset},adr,*(void**)adr);
|
|
223
|
+
//printf("{{prog %p}}",prog);
|
|
224
|
+
//printf("{{field%p}}",adr);
|
|
225
|
+
}}
|
|
226
|
+
return 0;
|
|
227
|
+
}}
|
|
228
|
+
"""
|
|
229
|
+
|
|
230
|
+
indirect_accessor_template = """
|
|
231
|
+
extern "C" __device__
|
|
232
|
+
int access_indirect_{label}_{suffix}(void* result, void* prog){{
|
|
233
|
+
void*& adr = *(void**)result;
|
|
234
|
+
adr = {prefix}(({short_name}*)prog)->{field};
|
|
235
|
+
adr = {deref}(void*)(((char*)adr)+{offset});
|
|
236
|
+
if(threadIdx.x == 0) {{
|
|
237
|
+
//printf("{{ {label} accessor - offset %d - address %p - would be %p}}",{offset},adr,*(void**)adr);
|
|
238
|
+
//printf("{{prog %p}}",prog);
|
|
239
|
+
//printf("{{field%p}}",adr);
|
|
240
|
+
}}
|
|
241
|
+
return 0;
|
|
242
|
+
}}
|
|
243
|
+
"""
|
|
244
|
+
|
|
245
|
+
atomic_template="""
|
|
246
|
+
extern "C" __device__
|
|
247
|
+
{face_type_cpp} array_atomic_{op_py}_{face_type_py}(void* ptr, size_t index, {face_type_cpp} value) {{
|
|
248
|
+
//printf("{{atomic add at %p}}",ptr);
|
|
249
|
+
volatile bool always_true = true;
|
|
250
|
+
if (always_true) {{
|
|
251
|
+
{real_type_cpp} *array = ({real_type_cpp} *) ptr;
|
|
252
|
+
return {op_cpp}(array+index,({real_type_cpp}) value);
|
|
253
|
+
}} else {{
|
|
254
|
+
return 0;
|
|
255
|
+
}}
|
|
256
|
+
}}
|
|
257
|
+
"""
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
clock_template="""
|
|
261
|
+
extern "C" __device__
|
|
262
|
+
long long int get_wall_clock() {{
|
|
263
|
+
#ifdef HARMONIZE_PLATFORM_CUDA
|
|
264
|
+
long long int result;
|
|
265
|
+
asm volatile("mov.u64 %0, %%globaltimer;" : "=l"(result));
|
|
266
|
+
return result;
|
|
267
|
+
#else
|
|
268
|
+
return wall_clock64();
|
|
269
|
+
#endif
|
|
270
|
+
}}
|
|
271
|
+
|
|
272
|
+
extern "C"
|
|
273
|
+
long long int wall_clock_rate() {{
|
|
274
|
+
#ifdef HARMONIZE_PLATFORM_CUDA
|
|
275
|
+
return 1000000000;
|
|
276
|
+
#else
|
|
277
|
+
int device_id;
|
|
278
|
+
util::host::auto_throw(hipGetDevice(&device_id));
|
|
279
|
+
int wall_clock_rate = 0; //in kilohertz
|
|
280
|
+
util::host::auto_throw(hipDeviceGetAttribute(
|
|
281
|
+
&wall_clock_rate,
|
|
282
|
+
hipDeviceAttributeWallClockRate,
|
|
283
|
+
device_id
|
|
284
|
+
));
|
|
285
|
+
return wall_clock_rate * 1000;
|
|
286
|
+
#endif
|
|
287
|
+
}}
|
|
288
|
+
"""
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
early_halt_template="""
|
|
292
|
+
extern "C" __device__
|
|
293
|
+
int halt_early_{suffix}(void* result, void *prog) {{
|
|
294
|
+
(({short_name}*)prog)->halt_early();
|
|
295
|
+
return 0;
|
|
296
|
+
}}
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
print_template="""
|
|
300
|
+
extern "C" __device__
|
|
301
|
+
int harmonize_print_{type_sig}(void* result, {args}) {{
|
|
302
|
+
printf("( {format_str} )\\n",{arg_vals});
|
|
303
|
+
return 0;
|
|
304
|
+
}}
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
alloc_device_bytes_template="""
|
|
308
|
+
extern "C"
|
|
309
|
+
void *harmonize_alloc_device_bytes(size_t size) {{
|
|
310
|
+
void *result_ptr = nullptr;
|
|
311
|
+
//printf("Allocating %zu device bytes\\n",size);
|
|
312
|
+
util::host::auto_throw(adapt::GPUrtMalloc(
|
|
313
|
+
&result_ptr,
|
|
314
|
+
size
|
|
315
|
+
));
|
|
316
|
+
//printf("Allocated %zu device bytes at %p\\n",size,result_ptr);
|
|
317
|
+
return result_ptr;
|
|
318
|
+
}}
|
|
319
|
+
"""
|
|
320
|
+
|
|
321
|
+
alloc_managed_bytes_template="""
|
|
322
|
+
extern "C"
|
|
323
|
+
void *harmonize_alloc_managed_bytes(size_t size) {{
|
|
324
|
+
void *result_ptr = nullptr;
|
|
325
|
+
//printf("Allocating %zu managed bytes\\n",size);
|
|
326
|
+
util::host::auto_throw(adapt::GPUrtMallocManaged(
|
|
327
|
+
&result_ptr,
|
|
328
|
+
size
|
|
329
|
+
));
|
|
330
|
+
//printf("Allocated %zu device bytes at %p\\n",size,result_ptr);
|
|
331
|
+
return result_ptr;
|
|
332
|
+
}}
|
|
333
|
+
"""
|
|
334
|
+
|
|
335
|
+
free_device_bytes_template="""
|
|
336
|
+
extern "C"
|
|
337
|
+
void harmonize_free_device_bytes(void* ptr) {{
|
|
338
|
+
//printf("Freeing bytes\\n");
|
|
339
|
+
util::host::auto_throw(adapt::GPUrtFree(ptr));
|
|
340
|
+
}}
|
|
341
|
+
"""
|
|
342
|
+
|
|
343
|
+
memcpy_host_to_device_template="""
|
|
344
|
+
extern "C"
|
|
345
|
+
void harmonize_memcpy_host_to_device(void *dev_ptr, void *host_ptr, size_t byte_count) {{
|
|
346
|
+
//printf("Copying %zu bytes from %p (host) to %p (device).\\n",byte_count,host_ptr,dev_ptr);
|
|
347
|
+
util::host::auto_throw(adapt::GPUrtMemcpy(
|
|
348
|
+
dev_ptr,
|
|
349
|
+
host_ptr,
|
|
350
|
+
byte_count,
|
|
351
|
+
adapt::GPUrtMemcpyHostToDevice
|
|
352
|
+
));
|
|
353
|
+
}}
|
|
354
|
+
"""
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
memcpy_device_to_host_template="""
|
|
358
|
+
extern "C"
|
|
359
|
+
void harmonize_memcpy_device_to_host(void *host_ptr, void *dev_ptr, size_t byte_count) {{
|
|
360
|
+
//printf("Copying %zu bytes from %p (device) to %p (host).\\n",byte_count,dev_ptr,host_ptr);
|
|
361
|
+
util::host::auto_throw(adapt::GPUrtMemcpy(
|
|
362
|
+
host_ptr,
|
|
363
|
+
dev_ptr,
|
|
364
|
+
byte_count,
|
|
365
|
+
adapt::GPUrtMemcpyDeviceToHost
|
|
366
|
+
));
|
|
367
|
+
}}
|
|
368
|
+
"""
|
|
369
|
+
|
harmonize/timing.py
ADDED
harmonize/types.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import numba
|
|
2
|
+
|
|
3
|
+
void = numba.types.void
|
|
4
|
+
vp = numba.types.voidptr
|
|
5
|
+
i8 = numba.types.int8
|
|
6
|
+
i16 = numba.types.int16
|
|
7
|
+
i32 = numba.types.int32
|
|
8
|
+
i64 = numba.types.int64
|
|
9
|
+
u8 = numba.types.uint8
|
|
10
|
+
u16 = numba.types.uint16
|
|
11
|
+
u32 = numba.types.uint32
|
|
12
|
+
u64 = numba.types.uint64
|
|
13
|
+
f32 = numba.types.float32
|
|
14
|
+
f64 = numba.types.float64
|
|
15
|
+
usize = numba.types.uintp
|
|
16
|
+
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: harmonize-python
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Harmonize, an async GPU scheduler
|
|
5
|
+
Project-URL: Documentation, https://harmonize-software.github.io/harmonize/
|
|
6
|
+
Project-URL: Repository, https://github.com/harmonize-software/harmonize
|
|
7
|
+
Project-URL: Issues, https://github.com/harmonize-software/harmonize/issues
|
|
8
|
+
Author-email: Braxton Cuneo <bcuneo@seattleu.edu>, Joanna Morgan <morgajoa@oregonstate.edu>
|
|
9
|
+
Maintainer-email: Braxton Cuneo <bcuneo@seattleu.edu>
|
|
10
|
+
License-Expression: BSD-3-Clause
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: GPU,HPC
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Operating System :: Unix
|
|
16
|
+
Classifier: Programming Language :: C++
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Typing :: Typed
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: cffi
|
|
21
|
+
Requires-Dist: colorama
|
|
22
|
+
Requires-Dist: numba>=0.58.0
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Provides-Extra: cuda12
|
|
25
|
+
Requires-Dist: numba-cuda[cu12]>=0.30; extra == 'cuda12'
|
|
26
|
+
Provides-Extra: cuda13
|
|
27
|
+
Requires-Dist: numba-cuda[cu13]>=0.30; extra == 'cuda13'
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: black; extra == 'dev'
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
|
|
32
|
+
# Harmonize
|
|
33
|
+
|
|
34
|
+
Harmonize is an execution framework for GPU with the aims of increasing performance and decreasing development burden for applications requiring complex processing patterns.
|
|
35
|
+
Harmonize is currently available both as a headers-only CUDA/HIP C++ library and as a Python package. In both forms, functionality is exposed as an asynchronous processing framework.
|
|
36
|
+
|
|
37
|
+
## Fundamentals
|
|
38
|
+
|
|
39
|
+
The system of asynchronous functions that are executed within a given runtime are defined in advance through a **program specification**.
|
|
40
|
+
A program specification only represents these systems abstractly, but they may be transformed into an implementation by declaring a **program** ***specialization***.
|
|
41
|
+
|
|
42
|
+
Program specifications are defined by application developers, and represent the business logic of what needs to be accomplished in the GPU, whereas the templates (**program types**) used to transform them into specializations are defined by framework developers.
|
|
43
|
+
This structure is used because it separates much of the underlying implementation details away from application developers, delegating those concerns to the framework developers.
|
|
44
|
+
Ideally, with the addition of a program type, transitioning a codebase to this other program could be as little as a one-line refactor:
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
< using MyProgram = EventProgram<MyProgramSpec>;
|
|
48
|
+
> using MyProgram = AsyncProgram<MyProgramSpec>;
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Likewise, as long as the interface between the specification and the program type does not change, program types may be updated without requiring refactors from the application developers.
|
|
52
|
+
|
|
53
|
+
## Why Async?
|
|
54
|
+
|
|
55
|
+
Asynchronous programming represents a looser contract between program and execution environment.
|
|
56
|
+
Once a function is called, there is no guarantee of where or when that call is actually evaluated.
|
|
57
|
+
If the call is lazy, then the evaluation may not happen at all.
|
|
58
|
+
|
|
59
|
+
This looser contract is useful, because it allows an interface to represent a wide variety of execution strategies without breaking any promises.
|
|
60
|
+
By representing all program types as different asynchronous runtimes, they can be used interchangeably as long as they fulfill the few promises made by the runtime's interface.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
## Dependencies
|
|
64
|
+
|
|
65
|
+
### CUDA C++ Dependencies
|
|
66
|
+
|
|
67
|
+
The C++ framework currently requires the following for CUDA:
|
|
68
|
+
|
|
69
|
+
- a CUDA compiler (e.g. `nvcc`)
|
|
70
|
+
- the CUDA runtime (host and device)
|
|
71
|
+
|
|
72
|
+
### HIP C++ Dependencies
|
|
73
|
+
|
|
74
|
+
The C++ framework currently requires the following for ROCM:
|
|
75
|
+
|
|
76
|
+
- a HIP compiler (e.g. `hipcc`)
|
|
77
|
+
- the ROCM runtime (host and device)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
### Python Dependencies
|
|
81
|
+
|
|
82
|
+
Python bindings require:
|
|
83
|
+
|
|
84
|
+
- Non-package Dependencies
|
|
85
|
+
- CUDA execution requires the CUDA toolkit, including:
|
|
86
|
+
- `nvcc`
|
|
87
|
+
- CUDA runtime (host and device)
|
|
88
|
+
- ROCM execution requires the ROCM 6.0.0 toolkit, including its version of:
|
|
89
|
+
- `hipcc`
|
|
90
|
+
- `clang-offload-bundler`
|
|
91
|
+
- `llvm-link`
|
|
92
|
+
- `llvm-as`
|
|
93
|
+
- HIP runtime (host and device)
|
|
94
|
+
|
|
95
|
+
- Python Package Dependencies
|
|
96
|
+
- [`numpy`](https://github.com/numpy/numpy)
|
|
97
|
+
- [`llvmlite`](https://github.com/numba/llvmlite)
|
|
98
|
+
- For CUDA:
|
|
99
|
+
- [`numba`](https://github.com/numba/numba)
|
|
100
|
+
- For ROCM:
|
|
101
|
+
- [the AMD fork of `numba`](https://github.com/ROCm/numba-hip)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## Installation
|
|
105
|
+
|
|
106
|
+
Harmonize is published on PyPI as `harmonize-python` and imported as
|
|
107
|
+
`harmonize`. (The PyPI project named `harmonize` is unrelated.)
|
|
108
|
+
|
|
109
|
+
For NVIDIA GPUs, install the extra matching your CUDA toolkit's major version:
|
|
110
|
+
|
|
111
|
+
```sh
|
|
112
|
+
pip install "harmonize-python[cuda13]" # or harmonize-python[cuda12]
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
That version's `nvcc` must also be available from the system, an environment
|
|
116
|
+
module (`module load cuda`), or conda (`conda install -c nvidia cuda-nvcc`).
|
|
117
|
+
|
|
118
|
+
For AMD GPUs, install ROCm and the corresponding version of `numba-hip` for
|
|
119
|
+
your ROCm release (here, ROCm 6.4.0):
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
pip install --extra-index-url https://test.pypi.org/simple \
|
|
123
|
+
"numba-hip[rocm-6-4-0] @ git+https://github.com/ROCm/numba-hip.git"
|
|
124
|
+
pip install harmonize-python
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To install from a clone of this repository instead, run
|
|
128
|
+
`pip install ".[cuda13]"` (or `pip install .` for AMD) in it; add `-e` to
|
|
129
|
+
work on Harmonize itself.
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
## Checking your setup
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
python -m harmonize info # detected platform, toolchain, and devices
|
|
136
|
+
python -m harmonize check # problems that would stop GPU builds; exits non-zero if any
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
`check` reports, for example, a missing `nvcc`, a CUDA toolkit newer than the
|
|
140
|
+
driver, a toolkit too old to target the installed GPU, or Numba's NVVM emitting
|
|
141
|
+
PTX newer than `nvcc` can assemble (pip's CUDA packages can be newer than the
|
|
142
|
+
`nvcc` on `PATH`; `check` compiles a small function and assembles it to test this).
|
|
143
|
+
Include the output of `info` when reporting problems.
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Selecting a platform
|
|
147
|
+
|
|
148
|
+
By default, Harmonize uses ROCm when `numba-hip` is installed and CUDA
|
|
149
|
+
otherwise. To explicitly require a platform, set `HARMONIZE_PLATFORM` to
|
|
150
|
+
`cuda` or `rocm`:
|
|
151
|
+
|
|
152
|
+
```sh
|
|
153
|
+
HARMONIZE_PLATFORM=cuda python my_program.py
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Toolkit locations can be set with `harmonize.config.set_cuda_path()` and
|
|
157
|
+
`harmonize.config.set_rocm_path()`, otherwise `nvcc` and `hipcc` are found
|
|
158
|
+
on `PATH`.
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
harmonize/__init__.py,sha256=QphQJ8ZcnIRfbpJAQ7BW5EIc1pNGVqCzi73wR1AeS9I,1516
|
|
2
|
+
harmonize/__main__.py,sha256=eRXG_wWNKzXXUTF4kjRxOlsSwIbrwuES1nhkIIv7AYA,1072
|
|
3
|
+
harmonize/adapt.py,sha256=MCCH06PXXi02mD3VmjquDyF8dLcAEJLt-6AWsR_J8Hw,3666
|
|
4
|
+
harmonize/array.py,sha256=m73eGT-s4hI4kOzfc-oGoEoyLP6IViuMeiH0yJbyIw0,20996
|
|
5
|
+
harmonize/atomics.py,sha256=qGwGxjN0TT5Ck3dSS3MpIWWN0XsjNqGejB4E22P0PE8,6223
|
|
6
|
+
harmonize/codegen.py,sha256=qwR9yNJcW2ktVKydjOj1-cwfOVk-ZtK55MEZbzw-9zs,14581
|
|
7
|
+
harmonize/config.py,sha256=OCuBuuDNXpQ-cRYxxi2MTLwx8-N5F3YpBWtfecNSxqc,5673
|
|
8
|
+
harmonize/diagnostics.py,sha256=N-aV8ppDJo0LXW4vhhiSXfVxz4dJBiYsWDuz_JqCYc0,16936
|
|
9
|
+
harmonize/errors.py,sha256=3jiuyNOKbNA5thJ4FA4k5W5hh42JzWfT2JZ6l1N5i_k,452
|
|
10
|
+
harmonize/logging.py,sha256=Fw5l2zWuBKK0HzEh4_1RbNRG9h17qSJVcvyvD1QHiC0,1299
|
|
11
|
+
harmonize/pointer.py,sha256=yQ3XGbbbmIfv67zyHsj7tgbFMH_zBaP2SjHBY53ro4A,3016
|
|
12
|
+
harmonize/prim.py,sha256=cKmE_kyWKXZoNcxT80O7IM2FMGzol0U4ljxlERIRU2Q,1319
|
|
13
|
+
harmonize/printing.py,sha256=fe8bqKb3J9le-FVEKXH8sBx0l9X7r8pMozdIBW-GjOM,2646
|
|
14
|
+
harmonize/runtime.py,sha256=v5tqb8-dQsa7H03L2ykflfRXFEmDF3JKGq0ikbOnWLo,57372
|
|
15
|
+
harmonize/templates.py,sha256=s24YHPvdQFGD6M-KrTTnr18dfN1hO7GK-DCRIeeVGtI,10180
|
|
16
|
+
harmonize/timing.py,sha256=46uLlgWaJY4MVTD1Q0D1-0Pahyels5qWofD2BBNsBzM,249
|
|
17
|
+
harmonize/types.py,sha256=lnRdwF0eAsn9aaS9LAJLY2D18Bmb6YeTPqmkQPDb1Hk,360
|
|
18
|
+
harmonize/cpp/harmonize.h,sha256=opIB8GjOx_hh1mp2PUpIHVDM5m4njNByHLf9BaAr0QI,49
|
|
19
|
+
harmonize/cpp/async/future.h,sha256=QVuGCRq50nPJ-SuHzKphZ5nzsiuJ47RDMlVAGXkhUgA,1323
|
|
20
|
+
harmonize/cpp/async/mod.h,sha256=ljlG-h9TLNiQu6S3JMzpbtCxmQnEKS2GZFEpSsj16hA,100
|
|
21
|
+
harmonize/cpp/async/promise.h,sha256=AGwJ-RxbRid36ZG53kXJAFa1TyU0w1rbmgSJnXcq2DQ,22626
|
|
22
|
+
harmonize/cpp/mem/mod.h,sha256=aT8i_fv6wuqKqobWIrGbMBNwemsBkgTZkA-AOejcdP0,79
|
|
23
|
+
harmonize/cpp/mem/work.h,sha256=Gcw0cqS1teftDdHAz7xzmfCrwyy-neBU9a8GbVPug4M,4340
|
|
24
|
+
harmonize/cpp/preamble/adapt.h,sha256=9tEqFVES6QhJvxrY01quZ07W-RZT4xHtiWVwb-Vs9fs,4588
|
|
25
|
+
harmonize/cpp/preamble/mod.h,sha256=RmIbcykMj-mbz-k-SM53Ib5yQ6M_-A7smPZ0c1UoeLk,2592
|
|
26
|
+
harmonize/cpp/program/async.h,sha256=2lGKV4grLMBahI9JcSV2X-aMOqn3SVhL7vtWkXzmYR4,85029
|
|
27
|
+
harmonize/cpp/program/event.h,sha256=DHR5GA8a_ZKwUQT7d4c7PsodbvSxmzb7cEe_pSuVNIs,14742
|
|
28
|
+
harmonize/cpp/program/mod.h,sha256=gJ5xst9hk7YXETXc1rDZ5PFMK_TVMwyIKHnwfG2KwEs,2623
|
|
29
|
+
harmonize/cpp/sync/barrier.h,sha256=oSPQZNMJEiK42Vhr92bwtMYq80Fp_9Lzz1AXVd_CFIw,26478
|
|
30
|
+
harmonize/cpp/sync/mod.h,sha256=HHz9wnCMcy_caJ2oaiJMwI_WwWaaepRyZUsychU7Few,79
|
|
31
|
+
harmonize/cpp/util/cli.h,sha256=agl1hS5pgevW9zG81nf26r7vZOHhjNMwExqKWagI2AM,10724
|
|
32
|
+
harmonize/cpp/util/host.h,sha256=0NxJL9fLaq8Bjy26E0rKfw5QbO9oQSE4lhH8hDHNiTM,4941
|
|
33
|
+
harmonize/cpp/util/iter.h,sha256=ybM5TZX5Xl7FDi_ksqJWvwGWfGV2qN53JnFBY7x5rdc,10817
|
|
34
|
+
harmonize/cpp/util/mem.h,sha256=GBXaWihuzHV9ikZtR_FEWYa9mpZGzIWSfJtQFD9dyx4,22011
|
|
35
|
+
harmonize/cpp/util/mod.h,sha256=cBFi0BqannlVE04z3AFt2Ams68eqHmgWC3Uwb1-B06A,3398
|
|
36
|
+
harmonize/python/__init__.py,sha256=czHBOJ3TTNKYqfB-t3CrI070ISBTckVwfNO78xrmXuw,1291
|
|
37
|
+
harmonize_python-0.1.0.dist-info/METADATA,sha256=s05j9aQzk4WgczJM0C_3hnjr718WvsKSgk9pvRXdG_A,6214
|
|
38
|
+
harmonize_python-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
39
|
+
harmonize_python-0.1.0.dist-info/licenses/LICENSE,sha256=cbW-xheOXy58GI5YuNx1Z1riPhNMbz1y-Kq8DiDsE6w,1514
|
|
40
|
+
harmonize_python-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, CEMeNT
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|