xobjects 0.5.13__tar.gz → 0.5.15__tar.gz
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.
- {xobjects-0.5.13/xobjects.egg-info → xobjects-0.5.15}/PKG-INFO +1 -1
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_capi.py +1 -3
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_common.py +2 -4
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_kernel.py +2 -4
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_ref.py +6 -12
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_shared_memory.py +3 -5
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_struct.py +4 -8
- xobjects-0.5.15/xobjects/_version.py +1 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/capi.py +2 -4
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/context_cupy.py +11 -6
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/context_pyopencl.py +2 -4
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/headers/atomicadd.h +11 -2
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/hybrid_class.py +2 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/scalar.py +0 -1
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/struct.py +1 -0
- {xobjects-0.5.13 → xobjects-0.5.15/xobjects.egg-info}/PKG-INFO +1 -1
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects.egg-info/SOURCES.txt +0 -1
- xobjects-0.5.13/xobjects/_version.py +0 -1
- {xobjects-0.5.13 → xobjects-0.5.15}/Architecture.md +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/LICENSE +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/MANIFEST.in +0 -0
- /xobjects-0.5.13/Readme.md → /xobjects-0.5.15/README.md +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/pyproject.toml +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/setup.cfg +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/setup.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_align.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_array.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_buffer.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_chunk.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_context_opencl.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_hybrid_class.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_linked_array.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_nplike_arrays.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_scalars.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_strides.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_string.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_to_dict.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_typeutils.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/tests/test_unionref.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/__init__.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/_patch_pyopencl_array.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/array.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/context.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/context_cpu.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/general.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/headers/common.h +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/linkedarray.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/ref.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/specialize_source.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/string.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/test_helpers.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/typeutils.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects/union.py +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects.egg-info/dependency_links.txt +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects.egg-info/entry_points.txt +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects.egg-info/requires.txt +0 -0
- {xobjects-0.5.13 → xobjects-0.5.15}/xobjects.egg-info/top_level.txt +0 -0
|
@@ -179,9 +179,7 @@ def test_array_get_shape(test_context, array_type):
|
|
|
179
179
|
*out_nd = ARRAY_TYPE_nd(arr);
|
|
180
180
|
ARRAY_TYPE_shape(arr, out_shape);
|
|
181
181
|
}
|
|
182
|
-
""".replace(
|
|
183
|
-
"ARRAY_TYPE", array_type.__name__
|
|
184
|
-
)
|
|
182
|
+
""".replace("ARRAY_TYPE", array_type.__name__)
|
|
185
183
|
|
|
186
184
|
kernels = {
|
|
187
185
|
"get_nd_and_shape": xo.Kernel(
|
|
@@ -87,8 +87,7 @@ def test_atomic(overload, ctype, test_context):
|
|
|
87
87
|
|
|
88
88
|
class TestAtomic(xo.Struct):
|
|
89
89
|
val = ctype
|
|
90
|
-
_extra_c_sources = [
|
|
91
|
-
f"""
|
|
90
|
+
_extra_c_sources = [f"""
|
|
92
91
|
#include "xobjects/headers/common.h"
|
|
93
92
|
#include "xobjects/headers/atomicadd.h"
|
|
94
93
|
|
|
@@ -101,8 +100,7 @@ def test_atomic(overload, ctype, test_context):
|
|
|
101
100
|
retvals[ii] = ret;
|
|
102
101
|
END_VECTORIZE;
|
|
103
102
|
}}
|
|
104
|
-
"""
|
|
105
|
-
]
|
|
103
|
+
"""]
|
|
106
104
|
|
|
107
105
|
kernels = {
|
|
108
106
|
"run_atomic_test": xo.Kernel(
|
|
@@ -216,15 +216,13 @@ def test_kernels_save_load_with_classes(tmp_path, mocker):
|
|
|
216
216
|
"x": xo.Float64,
|
|
217
217
|
"y": xo.Float64,
|
|
218
218
|
}
|
|
219
|
-
_extra_c_sources = [
|
|
220
|
-
"""
|
|
219
|
+
_extra_c_sources = ["""
|
|
221
220
|
/*gpufun*/ double myfun(TestClassData tc){
|
|
222
221
|
double x = TestClassData_get_x(tc);
|
|
223
222
|
double y = TestClassData_get_y(tc);
|
|
224
223
|
return x * y;
|
|
225
224
|
}
|
|
226
|
-
"""
|
|
227
|
-
]
|
|
225
|
+
"""]
|
|
228
226
|
_kernels = {
|
|
229
227
|
"myfun": xo.Kernel(
|
|
230
228
|
args=[
|
|
@@ -220,29 +220,25 @@ def test_unionref(test_context):
|
|
|
220
220
|
b = xo.Float64
|
|
221
221
|
h = xo.Float64
|
|
222
222
|
|
|
223
|
-
_extra_c_sources = [
|
|
224
|
-
"""
|
|
223
|
+
_extra_c_sources = ["""
|
|
225
224
|
/*gpufun*/
|
|
226
225
|
double Triangle_compute_area(Triangle tr, double scale){
|
|
227
226
|
double b = Triangle_get_b(tr);
|
|
228
227
|
double h = Triangle_get_h(tr);
|
|
229
228
|
return 0.5*b*h*scale;
|
|
230
229
|
}
|
|
231
|
-
"""
|
|
232
|
-
]
|
|
230
|
+
"""]
|
|
233
231
|
|
|
234
232
|
class Square(xo.Struct):
|
|
235
233
|
a = xo.Float64
|
|
236
234
|
|
|
237
|
-
_extra_c_sources = [
|
|
238
|
-
"""
|
|
235
|
+
_extra_c_sources = ["""
|
|
239
236
|
/*gpufun*/
|
|
240
237
|
double Square_compute_area(Square sq, double scale){
|
|
241
238
|
double a = Square_get_a(sq);
|
|
242
239
|
return a*a*scale;
|
|
243
240
|
}
|
|
244
|
-
"""
|
|
245
|
-
]
|
|
241
|
+
"""]
|
|
246
242
|
|
|
247
243
|
class Base(xo.UnionRef):
|
|
248
244
|
_reftypes = (Triangle, Square)
|
|
@@ -259,8 +255,7 @@ def test_unionref(test_context):
|
|
|
259
255
|
height = xo.Float64
|
|
260
256
|
volume = xo.Float64
|
|
261
257
|
|
|
262
|
-
_extra_c_sources = [
|
|
263
|
-
"""
|
|
258
|
+
_extra_c_sources = ["""
|
|
264
259
|
/*gpukern*/
|
|
265
260
|
void Prism_compute_volume(Prism pr){
|
|
266
261
|
Base base = Prism_getp_base(pr);
|
|
@@ -269,8 +264,7 @@ def test_unionref(test_context):
|
|
|
269
264
|
printf("base_area = %e", base_area);
|
|
270
265
|
Prism_set_volume(pr, base_area*height);
|
|
271
266
|
}
|
|
272
|
-
"""
|
|
273
|
-
]
|
|
267
|
+
"""]
|
|
274
268
|
|
|
275
269
|
test_context.add_kernels(
|
|
276
270
|
kernels={
|
|
@@ -35,8 +35,7 @@ def test_shared_memory():
|
|
|
35
35
|
|
|
36
36
|
class TestElement(xo.HybridClass):
|
|
37
37
|
_xofields = {}
|
|
38
|
-
_extra_c_sources = [
|
|
39
|
-
"""
|
|
38
|
+
_extra_c_sources = ["""
|
|
40
39
|
__global__ void test_shared_memory(const double* input_arr, double* result, const int n) {
|
|
41
40
|
// simple kernel to test shared memory
|
|
42
41
|
// reduction with an array of 4 doubles using 2 blocks each 2 threads
|
|
@@ -47,7 +46,7 @@ def test_shared_memory():
|
|
|
47
46
|
unsigned int gid = blockIdx.x*blockDim.x + threadIdx.x; // global thread ID: 0,1,2,3
|
|
48
47
|
|
|
49
48
|
// init shared memory with chunk of input array
|
|
50
|
-
extern __shared__ double sdata[
|
|
49
|
+
extern __shared__ double sdata[];
|
|
51
50
|
sdata[tid] = input_arr[gid];
|
|
52
51
|
__syncthreads();
|
|
53
52
|
|
|
@@ -59,8 +58,7 @@ def test_shared_memory():
|
|
|
59
58
|
atomicAdd(&result[tid], sdata[tid]);
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
|
-
"""
|
|
63
|
-
]
|
|
61
|
+
"""]
|
|
64
62
|
_kernels = _test_shared_memory_kernels
|
|
65
63
|
|
|
66
64
|
def __init__(
|
|
@@ -222,8 +222,7 @@ def test_kernel_namings():
|
|
|
222
222
|
var_mult_3 = xo.Float64[:]
|
|
223
223
|
var_mult_4 = xo.Float64[:]
|
|
224
224
|
|
|
225
|
-
_extra_c_sources = [
|
|
226
|
-
r"""
|
|
225
|
+
_extra_c_sources = [r"""
|
|
227
226
|
double mul(MyStruct stru) {
|
|
228
227
|
int32_t n = MyStruct_get_n(stru);
|
|
229
228
|
double* var_mult_1 = MyStruct_getp1_var_mult_1(stru, 0);
|
|
@@ -258,8 +257,7 @@ double mult_four(MyStruct stru) {
|
|
|
258
257
|
y+= var_mult_1[tid] * var_mult_2[tid] * var_mult_3[tid] * var_mult_4[tid];
|
|
259
258
|
}
|
|
260
259
|
return y;
|
|
261
|
-
}"""
|
|
262
|
-
]
|
|
260
|
+
}"""]
|
|
263
261
|
|
|
264
262
|
kernel_descriptions = {
|
|
265
263
|
"mul": xo.Kernel(
|
|
@@ -316,15 +314,13 @@ def test_compile_kernels_only_if_needed(tmp_path, mocker):
|
|
|
316
314
|
"x": xo.Float64,
|
|
317
315
|
"y": xo.Float64,
|
|
318
316
|
}
|
|
319
|
-
_extra_c_sources = [
|
|
320
|
-
"""
|
|
317
|
+
_extra_c_sources = ["""
|
|
321
318
|
/*gpufun*/ double myfun(TestClassData tc){
|
|
322
319
|
double x = TestClassData_get_x(tc);
|
|
323
320
|
double y = TestClassData_get_y(tc);
|
|
324
321
|
return x * y;
|
|
325
322
|
}
|
|
326
|
-
"""
|
|
327
|
-
]
|
|
323
|
+
"""]
|
|
328
324
|
_kernels = {
|
|
329
325
|
"myfun": xo.Kernel(
|
|
330
326
|
args=[
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.15"
|
|
@@ -525,14 +525,12 @@ def gen_method_switch(cls, path, conf, method):
|
|
|
525
525
|
for arg in kernel.args[1:]:
|
|
526
526
|
targs.append(f"{arg.name}")
|
|
527
527
|
targs = ",".join(targs)
|
|
528
|
-
lst.append(
|
|
529
|
-
f"""\
|
|
528
|
+
lst.append(f"""\
|
|
530
529
|
#ifndef {refname.upper()}_SKIP_{atname.upper()}
|
|
531
530
|
case {refname}_{atname}_t:
|
|
532
531
|
return {atname}_{method.c_name}({targs});
|
|
533
532
|
break;
|
|
534
|
-
#endif"""
|
|
535
|
-
)
|
|
533
|
+
#endif""")
|
|
536
534
|
lst.append(" }")
|
|
537
535
|
lst.append(f" return{'' if method.ret is None else ' 0'};")
|
|
538
536
|
lst.append("}")
|
|
@@ -350,19 +350,24 @@ if _enabled:
|
|
|
350
350
|
return cupy.ndarray.__invert__(self._as_cupy())
|
|
351
351
|
|
|
352
352
|
|
|
353
|
-
cudaheader: List[SourceType] = [
|
|
354
|
-
"""\
|
|
355
|
-
typedef signed long long int64_t; //only_for_context cuda
|
|
353
|
+
cudaheader: List[SourceType] = ["""\
|
|
356
354
|
typedef signed int int32_t; //only_for_context cuda
|
|
357
355
|
typedef signed short int16_t; //only_for_context cuda
|
|
358
356
|
typedef signed char int8_t; //only_for_context cuda
|
|
359
|
-
typedef unsigned long long uint64_t; //only_for_context cuda
|
|
360
357
|
typedef unsigned int uint32_t; //only_for_context cuda
|
|
361
358
|
typedef unsigned short uint16_t; //only_for_context cuda
|
|
362
359
|
typedef unsigned char uint8_t; //only_for_context cuda
|
|
363
360
|
|
|
364
|
-
|
|
365
|
-
|
|
361
|
+
#if defined(__CUDACC__) || defined(__HIPCC_RTC__)
|
|
362
|
+
typedef signed long long int64_t;
|
|
363
|
+
typedef unsigned long long uint64_t;
|
|
364
|
+
#endif
|
|
365
|
+
|
|
366
|
+
#ifndef NULL
|
|
367
|
+
#define NULL nullptr
|
|
368
|
+
#endif
|
|
369
|
+
|
|
370
|
+
"""]
|
|
366
371
|
|
|
367
372
|
|
|
368
373
|
def nplike_to_cupy(arr):
|
|
@@ -44,8 +44,7 @@ except ImportError:
|
|
|
44
44
|
|
|
45
45
|
from ._patch_pyopencl_array import _patch_pyopencl_array
|
|
46
46
|
|
|
47
|
-
openclheader: List[SourceType] = [
|
|
48
|
-
"""\
|
|
47
|
+
openclheader: List[SourceType] = ["""\
|
|
49
48
|
#ifndef XOBJ_STDINT
|
|
50
49
|
typedef long int64_t;
|
|
51
50
|
typedef int int32_t;
|
|
@@ -59,8 +58,7 @@ typedef unsigned char uint8_t;
|
|
|
59
58
|
#ifndef NULL
|
|
60
59
|
#define NULL 0L
|
|
61
60
|
#endif
|
|
62
|
-
"""
|
|
63
|
-
]
|
|
61
|
+
"""]
|
|
64
62
|
|
|
65
63
|
if _enabled:
|
|
66
64
|
# order of base classes matters as it defines which __setitem__ is used
|
|
@@ -101,8 +101,9 @@ DEF_ATOMIC_ADD(double , f64)
|
|
|
101
101
|
// -------------------------------------------
|
|
102
102
|
#if defined(XO_CONTEXT_CUDA)
|
|
103
103
|
// CUDA compiler may not have <stdint.h>, so define the types if needed.
|
|
104
|
-
#
|
|
105
|
-
// NVRTC (CuPy RawModule default) can’t see <stdint.h
|
|
104
|
+
#if defined(__CUDACC_RTC__) || defined(__HIPCC_RTC__)
|
|
105
|
+
// NVRTC and HIPRTC (CuPy RawModule default) can’t see <stdint.h>
|
|
106
|
+
// We detect via __CUDACC_RTC__ (Nvidia) or __HIPCC_RTC__ (ROCm)
|
|
106
107
|
typedef signed char int8_t;
|
|
107
108
|
typedef short int16_t;
|
|
108
109
|
typedef int int32_t;
|
|
@@ -111,6 +112,14 @@ DEF_ATOMIC_ADD(double , f64)
|
|
|
111
112
|
typedef unsigned short uint16_t;
|
|
112
113
|
typedef unsigned int uint32_t;
|
|
113
114
|
typedef unsigned long long uint64_t;
|
|
115
|
+
#elif defined(__HIPCC__) && !defined(__HIPCC_RTC__)
|
|
116
|
+
// ROCm-HIPCC compiler appears to have definitions for 64-bit int types
|
|
117
|
+
typedef signed char int8_t;
|
|
118
|
+
typedef short int16_t;
|
|
119
|
+
typedef int int32_t;
|
|
120
|
+
typedef unsigned char uint8_t;
|
|
121
|
+
typedef unsigned short uint16_t;
|
|
122
|
+
typedef unsigned int uint32_t;
|
|
114
123
|
#else
|
|
115
124
|
// Alternatively, NVCC path is fine with host headers
|
|
116
125
|
#include <stdint.h>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.5.13"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|