carray 3.0.0 → 3.0.2
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.
- checksums.yaml +4 -4
- data/.yardopts +2 -1
- data/CHANGELOG.md +845 -3
- data/{NEWS.md → CHANGELOG.v1.md} +1 -1
- data/README.md +33 -33
- data/carray.gemspec +12 -8
- data/ext/ca_axis_dispatch.c +33 -4
- data/ext/ca_axis_group.c +256 -114
- data/ext/ca_binop_dispatch.c +5 -6
- data/ext/ca_binop_dispatch.h +0 -7
- data/ext/ca_categorical_iterator.c +121 -67
- data/ext/ca_for_each_element.h +6 -8
- data/ext/ca_group_iter.c +1 -1
- data/ext/ca_kernel_iterator.c +386 -74
- data/ext/ca_kernel_iterator.h +145 -45
- data/ext/ca_obj_array.c +62 -20
- data/ext/ca_obj_bincmp.c +57 -27
- data/ext/ca_obj_binop.c +86 -30
- data/ext/ca_obj_block.c +4 -4
- data/ext/ca_obj_const_string.c +88 -27
- data/ext/ca_obj_face.c +104 -0
- data/ext/ca_obj_face.h +48 -1
- data/ext/ca_obj_fake.c +11 -0
- data/ext/ca_obj_fixlen_string.c +21 -6
- data/ext/ca_obj_grid.c +11 -3
- data/ext/ca_obj_meld.c +125 -22
- data/ext/ca_obj_moncmp.c +33 -14
- data/ext/ca_obj_monop.c +19 -7
- data/ext/ca_obj_object.c +107 -4
- data/ext/ca_obj_record.c +3 -1
- data/ext/ca_obj_refer.c +30 -6
- data/ext/ca_obj_roll.c +13 -5
- data/ext/ca_obj_select.c +49 -34
- data/ext/ca_obj_select_axis.c +16 -6
- data/ext/ca_obj_shift.c +3 -3
- data/ext/ca_obj_stack.c +3 -8
- data/ext/ca_obj_stride.c +178 -24
- data/ext/ca_obj_string.c +11 -5
- data/ext/ca_obj_tile.c +13 -5
- data/ext/ca_obj_time.c +3 -1
- data/ext/ca_obj_timedelta.c +3 -1
- data/ext/ca_obj_transpose.c +1 -1
- data/ext/ca_obj_triop.c +62 -23
- data/ext/ca_obj_window.c +94 -19
- data/ext/ca_op_cmplx64.h +123 -0
- data/ext/ca_op_ipower.c +1 -5
- data/ext/ca_rng_normal.h +42 -0
- data/ext/ca_rng_xoshiro256pp.h +105 -0
- data/ext/ca_sort_kernels.h +5 -5
- data/ext/ca_sweep_engine.c +362 -155
- data/ext/ca_sweep_engine.h +39 -9
- data/ext/ca_transform_common.c +7 -0
- data/ext/carray.h +148 -132
- data/ext/carray_access.c +83 -49
- data/ext/carray_address_basis.c +590 -0
- data/ext/carray_bincount.c +8 -8
- data/ext/carray_broadcast.c +102 -9
- data/ext/carray_build_flags.h +3 -0
- data/ext/carray_call_cfunc.c +2010 -335
- data/ext/carray_call_cfunc.h +153 -0
- data/ext/carray_cast.c +184 -72
- data/ext/carray_conversion.c +22 -22
- data/ext/carray_copy.c +67 -32
- data/ext/carray_core.c +140 -13
- data/ext/carray_count.c +10 -11
- data/ext/carray_element.c +7 -7
- data/ext/carray_factorize.c +72 -51
- data/ext/carray_hold.c +1 -1
- data/ext/carray_index_classifier.c +7 -21
- data/ext/carray_internal.h +36 -3
- data/ext/carray_kernels_bincmp.c +1 -0
- data/ext/carray_kernels_binop.c +320 -298
- data/ext/carray_kernels_init.c +1095 -0
- data/ext/carray_kernels_map.c +1 -0
- data/ext/carray_kernels_moncmp.c +1 -0
- data/ext/carray_kernels_monop.c +412 -411
- data/ext/carray_kernels_reduce_aggregate.c +256 -87
- data/ext/carray_kernels_reduce_boolean.c +1 -0
- data/ext/carray_kernels_reduce_cumulative.c +324 -54
- data/ext/carray_kernels_reduce_extreme.c +605 -58
- data/ext/carray_kernels_reduce_variance.c +1 -0
- data/ext/carray_kernels_scan.c +5 -4
- data/ext/carray_kernels_search.c +187 -106
- data/ext/carray_kernels_sort.c +1 -0
- data/ext/carray_kernels_triop.c +1 -0
- data/ext/carray_lazy.c +175 -5
- data/ext/carray_loop.c +7 -1
- data/ext/carray_mask.c +29 -13
- data/ext/carray_median_percentile.c +56 -1
- data/ext/carray_memory_view.c +46 -21
- data/ext/carray_operator.c +50 -53
- data/ext/carray_order.c +1 -1
- data/ext/carray_partition.c +4 -4
- data/ext/carray_random.c +391 -47
- data/ext/carray_scatter.c +1 -1
- data/ext/carray_slab.c +13 -0
- data/ext/carray_sort.c +22 -24
- data/ext/carray_sort_kernel.c +10 -10
- data/ext/carray_test.c +1 -1
- data/ext/extconf.rb +18 -0
- data/ext/mk_call_cfunc.rb +323 -145
- data/ext/mkkernel.rb +651 -129
- data/ext/ruby_carray.c +28 -17
- data/ext/version.h +4 -4
- data/lib/carray/autoload_carray.rb +24 -3
- data/lib/carray/autoload_method_extension.rb +14 -1
- data/lib/carray/axis_group.rb +84 -7
- data/lib/carray/basics.rb +63 -59
- data/lib/carray/bincount_nd.rb +12 -12
- data/lib/carray/block_iterator.rb +111 -25
- data/lib/carray/categorical.rb +154 -37
- data/lib/carray/categorical_iterator.rb +300 -151
- data/lib/carray/conditional.rb +14 -14
- data/lib/carray/const_string.rb +131 -27
- data/lib/carray/construct.rb +61 -0
- data/lib/carray/core_extensions.rb +62 -5
- data/lib/carray/data_type_extension.rb +21 -1
- data/lib/carray/data_type_limits.rb +91 -0
- data/lib/carray/fixlen_string.rb +1 -1
- data/lib/carray/frame/concat.rb +3 -3
- data/lib/carray/frame/convert.rb +1 -1
- data/lib/carray/frame/csv_parser.rb +11 -4
- data/lib/carray/frame/frame.rb +85 -21
- data/lib/carray/frame/group.rb +36 -3
- data/lib/carray/frame/io.rb +224 -15
- data/lib/carray/frame/records.rb +18 -4
- data/lib/carray/frame/sort.rb +1 -1
- data/lib/carray/frame/verbs.rb +32 -12
- data/lib/carray/fuse_source.rb +123 -0
- data/lib/carray/fusion.rb +218 -0
- data/lib/carray/histogram.rb +16 -16
- data/lib/carray/inspect.rb +43 -16
- data/lib/carray/iterator.rb +147 -3
- data/lib/carray/lazy.rb +88 -73
- data/lib/carray/mask_gap_fill.rb +3 -1
- data/lib/carray/meld_reduce.rb +2 -2
- data/lib/carray/methods/align_addr.rb +1 -1
- data/lib/carray/methods/composition.rb +1 -1
- data/lib/carray/methods/discovery_along.rb +74 -0
- data/lib/carray/methods/factorize.rb +50 -0
- data/lib/carray/methods/is_in.rb +25 -14
- data/lib/carray/methods/locate_addr.rb +81 -3
- data/lib/carray/methods/mask_duplicates.rb +36 -2
- data/lib/carray/methods/meshgrid.rb +4 -5
- data/lib/carray/methods/mode.rb +2 -2
- data/lib/carray/methods/nunique.rb +23 -2
- data/lib/carray/methods/repeat.rb +110 -0
- data/lib/carray/methods/snap.rb +7 -2
- data/lib/carray/methods/unique.rb +44 -4
- data/lib/carray/methods/value_counts.rb +2 -2
- data/lib/carray/rng.rb +86 -0
- data/lib/carray/runtime.rb +0 -19
- data/lib/carray/slab_iterator.rb +77 -19
- data/lib/carray/string_operation_extension.rb +10 -6
- data/lib/carray/time.rb +906 -491
- data/lib/carray/window_iterator.rb +421 -27
- data/lib/carray.rb +7 -5
- data/yard-stubs/ca_obj_array.rb +385 -0
- data/yard-stubs/ca_obj_bitarray.rb +38 -0
- data/yard-stubs/ca_obj_bitfield.rb +43 -0
- data/yard-stubs/ca_obj_block.rb +68 -0
- data/yard-stubs/ca_obj_byte_swap.rb +56 -0
- data/yard-stubs/ca_obj_fake.rb +31 -0
- data/yard-stubs/ca_obj_farray.rb +32 -0
- data/yard-stubs/ca_obj_field.rb +45 -0
- data/yard-stubs/ca_obj_grid.rb +35 -0
- data/yard-stubs/ca_obj_refer.rb +72 -0
- data/yard-stubs/ca_obj_roll.rb +45 -0
- data/yard-stubs/ca_obj_shift.rb +43 -0
- data/yard-stubs/ca_obj_stride.rb +181 -0
- data/yard-stubs/ca_obj_tile.rb +29 -0
- data/yard-stubs/ca_obj_transpose.rb +40 -0
- data/yard-stubs/ca_obj_window.rb +57 -0
- data/yard-stubs/carray_access.rb +131 -0
- data/yard-stubs/carray_attribute.rb +246 -0
- data/yard-stubs/carray_broadcast.rb +37 -0
- data/yard-stubs/carray_cast.rb +489 -0
- data/yard-stubs/carray_class.rb +65 -0
- data/yard-stubs/carray_conversion.rb +76 -0
- data/yard-stubs/carray_copy.rb +79 -0
- data/yard-stubs/carray_core.rb +34 -0
- data/yard-stubs/carray_count.rb +84 -0
- data/yard-stubs/carray_element.rb +108 -0
- data/yard-stubs/carray_generate.rb +66 -0
- data/yard-stubs/carray_lazy.rb +228 -0
- data/yard-stubs/carray_loop.rb +140 -0
- data/yard-stubs/carray_mask.rb +259 -0
- data/yard-stubs/carray_math.rb +1615 -0
- data/yard-stubs/carray_mathfunc.rb +45 -0
- data/yard-stubs/carray_median_percentile.rb +103 -0
- data/yard-stubs/carray_memory_view.rb +163 -0
- data/yard-stubs/carray_order.rb +252 -0
- data/yard-stubs/carray_random.rb +89 -0
- data/yard-stubs/carray_scatter.rb +106 -0
- data/yard-stubs/carray_slab.rb +59 -0
- data/yard-stubs/carray_sort.rb +165 -0
- data/yard-stubs/carray_test.rb +85 -0
- data/yard-stubs/carray_undef.rb +64 -0
- data/yard-stubs/carray_utils.rb +97 -0
- data/yard-stubs/ruby_carray.rb +193 -0
- metadata +67 -10
- data/ext/ca_obj_unbound_repeat.c +0 -496
data/ext/carray.h
CHANGED
|
@@ -206,7 +206,7 @@ typedef int8_t boolean8_t;
|
|
|
206
206
|
#define CA_FLAG_MULTI_PARENTS 32
|
|
207
207
|
#define CA_FLAG_CYCLE_CHECK 64
|
|
208
208
|
#define CA_FLAG_IS_FACE 128
|
|
209
|
-
/* Face opt-in ordering/search flags
|
|
209
|
+
/* Face opt-in ordering/search flags.
|
|
210
210
|
A Face declares that its numeric storage may be descended to for kernel
|
|
211
211
|
dispatch. The two flags are on independent axes -- do not conflate:
|
|
212
212
|
ORDERABLE_STORAGE: storage native order == surface <=> order (self-scope).
|
|
@@ -224,6 +224,14 @@ typedef int8_t boolean8_t;
|
|
|
224
224
|
search / count / value-hash entries. Whether COMPARABLE holds is likewise
|
|
225
225
|
not a question of being numeric but of carrying a unit -- CATimedelta is
|
|
226
226
|
int64 on both sides and still sets ORDERABLE only. */
|
|
227
|
+
/* CALazyMarker. A marker layers "read this as the leaf of a lazy chain"
|
|
228
|
+
over storage that is identical to its parent's — the same premise as
|
|
229
|
+
CA_FLAG_IS_FACE — so the two are asked about together wherever a
|
|
230
|
+
storage-identical wrapper has to be seen through. Kept as its own bit
|
|
231
|
+
rather than folded into CA_FLAG_IS_FACE: ca_is_face is read in ~100
|
|
232
|
+
places that mean the Face mechanism specifically. */
|
|
233
|
+
#define CA_FLAG_IS_LAZY_MARKER 1024
|
|
234
|
+
|
|
227
235
|
#define CA_FLAG_FACE_ORDERABLE_STORAGE 256
|
|
228
236
|
#define CA_FLAG_FACE_COMPARABLE_STORAGE 512
|
|
229
237
|
/* NOTE: `flags` is int32_t, so there is plenty of bit space left. */
|
|
@@ -247,7 +255,6 @@ enum {
|
|
|
247
255
|
CA_OBJ_SELECT,
|
|
248
256
|
CA_OBJ_OBJECT,
|
|
249
257
|
CA_OBJ_REPEAT,
|
|
250
|
-
CA_OBJ_UNBOUND_REPEAT,
|
|
251
258
|
};
|
|
252
259
|
|
|
253
260
|
enum {
|
|
@@ -311,12 +318,13 @@ enum {
|
|
|
311
318
|
preamble stays focused on basic types + struct definitions. */
|
|
312
319
|
#include "ca_axis_descriptor.h"
|
|
313
320
|
|
|
314
|
-
/* xfer protocol direction flags
|
|
321
|
+
/* xfer protocol direction flags. The protocol is walked through in
|
|
322
|
+
guides/devel/04_attach_lifecycle.md. */
|
|
315
323
|
#define CA_XFER_GET 0 /* target -> data (gather) */
|
|
316
324
|
#define CA_XFER_PUT 1 /* data -> target (scatter) */
|
|
317
325
|
|
|
318
|
-
/* compose-fold state threaded through ca_stride_compose_to_root
|
|
319
|
-
|
|
326
|
+
/* compose-fold state threaded through ca_stride_compose_to_root.
|
|
327
|
+
strides / base / counts are expressed
|
|
320
328
|
in the *current parent*'s byte space; ndim is invariant through the walk.
|
|
321
329
|
counts[] is the leaf's per-dim extent (== leaf->dim), used by
|
|
322
330
|
ca_stride_compose_through's bounds check and by sometimes-fold
|
|
@@ -339,20 +347,20 @@ typedef struct {
|
|
|
339
347
|
void (*detach) (void *ap);
|
|
340
348
|
void (*fill_data) (void *ap, void *data);
|
|
341
349
|
void (*create_mask) (void *ap);
|
|
342
|
-
/* xfer protocol
|
|
350
|
+
/* xfer protocol. Added at struct end so existing
|
|
343
351
|
positional initializers leave it NULL automatically. dir = CA_XFER_GET /
|
|
344
352
|
CA_XFER_PUT. */
|
|
345
353
|
void (*xfer_index) (void *ap, ca_size_t *idx, void *data, int dir);
|
|
346
354
|
void (*xfer_addrs) (void *ap, ca_size_t n, ca_size_t *addrs,
|
|
347
355
|
void *data, int dir);
|
|
348
|
-
/* fold_stride
|
|
356
|
+
/* fold_stride: one compose-fold hop
|
|
349
357
|
for sometimes-fold participants (CAWindow now; CAGrid/CSA/CATile later).
|
|
350
358
|
Compose *f into next_parent's byte space and return 1, or decline
|
|
351
359
|
(leave *f / *next_parent untouched) and return 0 -> this view is the
|
|
352
360
|
fold boundary. CAStride family leaves this NULL (handled open-inline
|
|
353
361
|
by ca_stride_compose_to_root). */
|
|
354
362
|
int (*fold_stride) (void *ap, ca_fold_t *f, void **next_parent);
|
|
355
|
-
/* xfer_stride
|
|
363
|
+
/* xfer_stride: deliver a region of
|
|
356
364
|
counts[k] cells per axis to/from a caller buffer. Local materialise of
|
|
357
365
|
the requested region only (never the whole view).
|
|
358
366
|
|
|
@@ -365,21 +373,20 @@ typedef struct {
|
|
|
365
373
|
with strides[]. dir = CA_XFER_GET / CA_XFER_PUT. */
|
|
366
374
|
void (*xfer_stride) (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
367
375
|
ca_size_t *strides, void *data, int dir);
|
|
368
|
-
/* xfer_all
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
copy_data / sync_data become thin forwarders (removed in step 5).
|
|
376
|
+
/* xfer_all: whole-view transfer, the direction-unified replacement of
|
|
377
|
+
copy_data / sync_data. Holds the view's optimal whole-domain delivery
|
|
378
|
+
(compose-fold, partial materialise, etc.).
|
|
372
379
|
dir = CA_XFER_GET (gather: view -> data) / CA_XFER_PUT (scatter). */
|
|
373
380
|
void (*xfer_all) (void *ap, void *data, int dir);
|
|
374
|
-
/* Pool framework (
|
|
381
|
+
/* Pool framework (guides/devel/03_memory_management.md). Optional;
|
|
375
382
|
unfilled slots leave the obj_type on the legacy ALLOC_N path. When
|
|
376
383
|
populated, framework primitives in ca_array_pool.c manage a single
|
|
377
384
|
contiguous `_pool` buffer that holds dim/strides/<subclass tail>. */
|
|
378
385
|
size_t struct_size; /* sizeof(<concrete struct>) */
|
|
379
386
|
size_t (*pool_bytes) (int8_t ndim); /* required if struct_size != 0 */
|
|
380
387
|
void (*pool_init) (void *ap, int8_t ndim); /* required if struct_size != 0 */
|
|
381
|
-
/* fill_addrs / fill_stride
|
|
382
|
-
|
|
388
|
+
/* fill_addrs / fill_stride: write one value into part of the view.
|
|
389
|
+
fill_data carries no
|
|
383
390
|
region and so can only say "fill everything I cover"; without a region the
|
|
384
391
|
only way left to fill part of a view was to borrow a pointer, which
|
|
385
392
|
materialises a non-foldable root and writes it all back. `ptr` is a
|
|
@@ -413,7 +420,7 @@ void ca_array_func_xfer_all (void *ap, void *data, int dir);
|
|
|
413
420
|
void ca_array_func_fill_data (void *ap, void *val);
|
|
414
421
|
void ca_array_func_create_mask (void *ap);
|
|
415
422
|
|
|
416
|
-
/* Pool framework primitives (
|
|
423
|
+
/* Pool framework primitives (guides/devel/03_memory_management.md).
|
|
417
424
|
- ca_array_alloc: xmalloc(struct_size) + ca_array_pool_alloc().
|
|
418
425
|
For the C construction path (= replaces
|
|
419
426
|
TypedData_Make_Struct + per-field ALLOC_N).
|
|
@@ -449,8 +456,7 @@ struct _CArray {
|
|
|
449
456
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
450
457
|
Reserved for framework use; ext authors must not read,
|
|
451
458
|
write, or xfree this field directly. See
|
|
452
|
-
ext/ca_array_pool.c
|
|
453
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
459
|
+
ext/ca_array_pool.c. */
|
|
454
460
|
}; /* 28 + 4*ndim (bytes) */
|
|
455
461
|
|
|
456
462
|
typedef CArray CAWrap;
|
|
@@ -468,8 +474,7 @@ typedef struct {
|
|
|
468
474
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
469
475
|
Reserved for framework use; ext authors must not read,
|
|
470
476
|
write, or xfree this field directly. See
|
|
471
|
-
ext/ca_array_pool.c
|
|
472
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
477
|
+
ext/ca_array_pool.c. */
|
|
473
478
|
ca_size_t _dim;
|
|
474
479
|
} CScalar; /* 32 (bytes) */
|
|
475
480
|
|
|
@@ -486,8 +491,7 @@ typedef struct {
|
|
|
486
491
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
487
492
|
Reserved for framework use; ext authors must not read,
|
|
488
493
|
write, or xfree this field directly. See
|
|
489
|
-
ext/ca_array_pool.c
|
|
490
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
494
|
+
ext/ca_array_pool.c. */
|
|
491
495
|
CArray *parent;
|
|
492
496
|
uint32_t attach;
|
|
493
497
|
uint8_t nosync;
|
|
@@ -516,8 +520,7 @@ typedef struct {
|
|
|
516
520
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
517
521
|
Reserved for framework use; ext authors must not read,
|
|
518
522
|
write, or xfree this field directly. See
|
|
519
|
-
ext/ca_array_pool.c
|
|
520
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
523
|
+
ext/ca_array_pool.c. */
|
|
521
524
|
CArray *parent;
|
|
522
525
|
uint32_t attach;
|
|
523
526
|
uint8_t nosync;
|
|
@@ -551,8 +554,7 @@ typedef struct {
|
|
|
551
554
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
552
555
|
Reserved for framework use; ext authors must not read,
|
|
553
556
|
write, or xfree this field directly. See
|
|
554
|
-
ext/ca_array_pool.c
|
|
555
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
557
|
+
ext/ca_array_pool.c. */
|
|
556
558
|
CArray *parent;
|
|
557
559
|
uint32_t attach;
|
|
558
560
|
uint8_t nosync;
|
|
@@ -580,8 +582,7 @@ typedef struct {
|
|
|
580
582
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
581
583
|
Reserved for framework use; ext authors must not read,
|
|
582
584
|
write, or xfree this field directly. See
|
|
583
|
-
ext/ca_array_pool.c
|
|
584
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
585
|
+
ext/ca_array_pool.c. */
|
|
585
586
|
CArray *parent;
|
|
586
587
|
uint32_t attach;
|
|
587
588
|
uint8_t nosync;
|
|
@@ -603,14 +604,13 @@ typedef struct {
|
|
|
603
604
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
604
605
|
Reserved for framework use; ext authors must not read,
|
|
605
606
|
write, or xfree this field directly. See
|
|
606
|
-
ext/ca_array_pool.c
|
|
607
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
607
|
+
ext/ca_array_pool.c. */
|
|
608
608
|
CArray *parent;
|
|
609
609
|
uint32_t attach;
|
|
610
610
|
uint8_t nosync;
|
|
611
611
|
/* ---------- */
|
|
612
|
-
uint8_t *bounds; /* [ndim] per-axis policy (
|
|
613
|
-
|
|
612
|
+
uint8_t *bounds; /* [ndim] per-axis policy (a scalar uint8_t
|
|
613
|
+
before). Allows
|
|
614
614
|
CAShift (per-axis roll[]) to be expressed as
|
|
615
615
|
a CAWindow specialisation. */
|
|
616
616
|
ca_size_t *start;
|
|
@@ -620,8 +620,7 @@ typedef struct {
|
|
|
620
620
|
/* COMPOSITE_FAMILY Phase 1 (E.2): embed descriptor model. Computed by
|
|
621
621
|
ca_compute_embed_descriptor at setup time, immutable for view lifetime.
|
|
622
622
|
Used by attach/sync (E.3-E.4) to skip per-element bound checks via
|
|
623
|
-
"1 alias + 1 fill" decomposition.
|
|
624
|
-
See devel/PROPOSAL_COMPOSITE_FAMILY.md §4.1. */
|
|
623
|
+
"1 alias + 1 fill" decomposition. */
|
|
625
624
|
ca_size_t *embed_parent_start; /* [ndim] parent-side alias rectangle start */
|
|
626
625
|
ca_size_t *embed_count; /* [ndim] alias rectangle size per axis */
|
|
627
626
|
ca_size_t *embed_output_offset; /* [ndim] output-side alias rectangle start */
|
|
@@ -640,13 +639,12 @@ typedef struct {
|
|
|
640
639
|
must be contig in parent storage. */
|
|
641
640
|
} CAWindow; /* 56 + 16*(ndim) + 1*(bytes) + 1*ndim + 24*ndim (bytes) */
|
|
642
641
|
|
|
643
|
-
/*
|
|
644
|
-
of CAWindow. CAShift construction maps (shift[], roll[], fill,
|
|
642
|
+
/* CAShift is a pure typedef of CAWindow. CAShift construction maps (shift[], roll[], fill,
|
|
645
643
|
fill_mask) onto CAWindow's (start = -shift, count = parent->dim,
|
|
646
644
|
bounds = roll ? PERIODIC : (fill_mask ? MASK : FILL), fill). The
|
|
647
645
|
two views share the operation table (ca_window_func); only obj_type
|
|
648
646
|
differs (CA_OBJ_SHIFT vs CA_OBJ_WINDOW) to preserve user-facing class
|
|
649
|
-
distinction.
|
|
647
|
+
distinction. */
|
|
650
648
|
typedef CAWindow CAShift;
|
|
651
649
|
|
|
652
650
|
/* COMPOSITE_FAMILY Phase 2 (T.3, 2026-05-26): CATile = N-region
|
|
@@ -655,9 +653,8 @@ typedef CAWindow CAShift;
|
|
|
655
653
|
is a full-parent alias at output offset
|
|
656
654
|
(i_0 * parent.dim[0], i_1 * parent.dim[1], ...). Attach iterates
|
|
657
655
|
total_tiles regions, calling ca_composite_region_gather for each.
|
|
658
|
-
See devel/PROPOSAL_CATILE.md §1.2 / §1.3.
|
|
659
656
|
|
|
660
|
-
CARoll = typedef CATile (same pattern as the
|
|
657
|
+
CARoll = typedef CATile (same pattern as the
|
|
661
658
|
CAShift = CAWindow precedent); constructor parameters differ but the
|
|
662
659
|
C struct layout is shared, and the attach/sync routine is identical
|
|
663
660
|
(= dispatch the region list in order). */
|
|
@@ -674,8 +671,7 @@ typedef struct {
|
|
|
674
671
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
675
672
|
Reserved for framework use; ext authors must not read,
|
|
676
673
|
write, or xfree this field directly. See
|
|
677
|
-
ext/ca_array_pool.c
|
|
678
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
674
|
+
ext/ca_array_pool.c. */
|
|
679
675
|
CArray *parent;
|
|
680
676
|
uint32_t attach;
|
|
681
677
|
uint8_t nosync;
|
|
@@ -689,10 +685,8 @@ typedef CATile CARoll; /* T.4 will land CARoll-specific constructor +
|
|
|
689
685
|
obj_type CA_OBJ_ROLL. Until then CARoll path
|
|
690
686
|
is just CATile (= typedef body identical). */
|
|
691
687
|
|
|
692
|
-
/* CAStack
|
|
693
|
-
stack view of K uniform-shape parents. shape = (K, *parent_shape),
|
|
688
|
+
/* CAStack: outer-axis-only stack view of K uniform-shape parents. shape = (K, *parent_shape),
|
|
694
689
|
axis 0 maps to parent index, axes 1..ndim-1 are per-parent contig.
|
|
695
|
-
See devel/MEMO_CASTACK_DESIGN.md for design rationale.
|
|
696
690
|
- parents stored as Ruby Array @parents on the wrapper object (= GC
|
|
697
691
|
anchor); C-side tail `parents[]` is alias pointer array.
|
|
698
692
|
- CAView.parent points to parents[0] (= legacy compat for paths that
|
|
@@ -711,8 +705,7 @@ typedef struct {
|
|
|
711
705
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
712
706
|
Reserved for framework use; ext authors must not read,
|
|
713
707
|
write, or xfree this field directly. See
|
|
714
|
-
ext/ca_array_pool.c
|
|
715
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
708
|
+
ext/ca_array_pool.c. */
|
|
716
709
|
CArray *parent; /* = parents[0] (legacy CAView field) */
|
|
717
710
|
uint32_t attach;
|
|
718
711
|
uint8_t nosync;
|
|
@@ -733,8 +726,7 @@ typedef struct {
|
|
|
733
726
|
All other axes must match across parents (uniform check at constructor).
|
|
734
727
|
|
|
735
728
|
v0.1 stub: external-axis (meld_axis == 0) structural xfer_stride path only.
|
|
736
|
-
Other paths raise NotImplementedError
|
|
737
|
-
in devel/MEMO_CAMELD_SEGMENT_MAJOR_ENGINE.md §4. */
|
|
729
|
+
Other paths raise NotImplementedError. */
|
|
738
730
|
typedef struct {
|
|
739
731
|
int16_t obj_type;
|
|
740
732
|
int8_t data_type;
|
|
@@ -785,8 +777,7 @@ typedef struct {
|
|
|
785
777
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
786
778
|
Reserved for framework use; ext authors must not read,
|
|
787
779
|
write, or xfree this field directly. See
|
|
788
|
-
ext/ca_array_pool.c
|
|
789
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
780
|
+
ext/ca_array_pool.c. */
|
|
790
781
|
CArray *parent;
|
|
791
782
|
uint32_t attach;
|
|
792
783
|
uint8_t nosync;
|
|
@@ -813,8 +804,7 @@ typedef struct {
|
|
|
813
804
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
814
805
|
Reserved for framework use; ext authors must not read,
|
|
815
806
|
write, or xfree this field directly. See
|
|
816
|
-
ext/ca_array_pool.c
|
|
817
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
807
|
+
ext/ca_array_pool.c. */
|
|
818
808
|
/* -------------*/
|
|
819
809
|
VALUE array;
|
|
820
810
|
} CAObjectMask;
|
|
@@ -823,35 +813,6 @@ typedef struct {
|
|
|
823
813
|
The "repeat" axes are encoded as strides[k] == 0. */
|
|
824
814
|
typedef CAStride CARepeat;
|
|
825
815
|
|
|
826
|
-
/* CAUnboundRepeat (Phase U.1: CAStride prefix + rep_dim tail).
|
|
827
|
-
`rep_dim[i] == 0` marks an unbound (`*`) axis (size 1, stride 0);
|
|
828
|
-
`rep_dim[i] != 0` marks a sized axis inheriting parent's stride.
|
|
829
|
-
`ndim` replaces the former `rep_ndim` field (they are equal). */
|
|
830
|
-
typedef struct {
|
|
831
|
-
int16_t obj_type;
|
|
832
|
-
int8_t data_type;
|
|
833
|
-
int8_t ndim;
|
|
834
|
-
int32_t flags;
|
|
835
|
-
ca_size_t bytes;
|
|
836
|
-
ca_size_t elements;
|
|
837
|
-
ca_size_t *dim;
|
|
838
|
-
char *ptr;
|
|
839
|
-
CArray *mask;
|
|
840
|
-
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
841
|
-
Reserved for framework use; ext authors must not read,
|
|
842
|
-
write, or xfree this field directly. See
|
|
843
|
-
ext/ca_array_pool.c and
|
|
844
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
845
|
-
CArray *parent;
|
|
846
|
-
uint32_t attach;
|
|
847
|
-
uint8_t nosync;
|
|
848
|
-
/* --- CAStride prefix continues --- */
|
|
849
|
-
ca_size_t *strides;
|
|
850
|
-
ca_size_t base_offset;
|
|
851
|
-
/* --- CAUnboundRepeat tail --- */
|
|
852
|
-
ca_size_t *rep_dim;
|
|
853
|
-
} CAUnboundRepeat;
|
|
854
|
-
|
|
855
816
|
/*
|
|
856
817
|
CAReduce is an internal class
|
|
857
818
|
used only in ca_obj_refer.c.
|
|
@@ -870,8 +831,7 @@ typedef struct {
|
|
|
870
831
|
char *_pool; /* framework-managed pool buffer (NULL = legacy ALLOC_N path).
|
|
871
832
|
Reserved for framework use; ext authors must not read,
|
|
872
833
|
write, or xfree this field directly. See
|
|
873
|
-
ext/ca_array_pool.c
|
|
874
|
-
devel/PROPOSAL_CARRAY_POOL_STANDARDIZATION.md. */
|
|
834
|
+
ext/ca_array_pool.c. */
|
|
875
835
|
CArray *parent;
|
|
876
836
|
uint32_t attach;
|
|
877
837
|
uint8_t nosync;
|
|
@@ -882,9 +842,8 @@ typedef struct {
|
|
|
882
842
|
|
|
883
843
|
/* -------------------------------------------------------------------- */
|
|
884
844
|
|
|
885
|
-
/* CAIterator is a form-only Ruby base (see ext/carray_iterator.c); the
|
|
886
|
-
|
|
887
|
-
samples/caiterator/iterator.c. */
|
|
845
|
+
/* CAIterator is a form-only Ruby base (see ext/carray_iterator.c); the 2.0 C
|
|
846
|
+
struct (a kernel_at_addr dispatch slot) was retired in 3.0. */
|
|
888
847
|
|
|
889
848
|
/* -------------------------------------------------------------------- */
|
|
890
849
|
|
|
@@ -896,10 +855,8 @@ extern const int ca_cast_table[CA_NTYPE][CA_NTYPE];
|
|
|
896
855
|
extern const int ca_cast_table2[CA_NTYPE][CA_NTYPE];
|
|
897
856
|
|
|
898
857
|
/* data_type promotion reducer — pure function over ca_cast_table. Used by
|
|
899
|
-
CArray.result_type and
|
|
900
|
-
the
|
|
901
|
-
devel/AUDIT_DTYPE_PROMOTION.md for the audit that confirmed single
|
|
902
|
-
source. */
|
|
858
|
+
CArray.result_type and by the lazy view layer. See ext/carray_cast.c
|
|
859
|
+
for the definition; this is the single source of the promotion rule. */
|
|
903
860
|
int8_t ca_promote_type (int8_t a, int8_t b);
|
|
904
861
|
|
|
905
862
|
/* Infer a data_type code from a Ruby *value* (literal Numeric, true/false,
|
|
@@ -918,8 +875,7 @@ int8_t ca_mv_probe_data_type (VALUE obj);
|
|
|
918
875
|
/* Symbol cache for data_type code → Symbol lookup. Initialized in
|
|
919
876
|
Init_carray_class. Indexed by data_type code (0 = CA_FIXLEN ...
|
|
920
877
|
CA_NTYPE-1 = CA_OBJECT). Use rb_ca_data_type_to_sym for the public
|
|
921
|
-
conversion entry point (it validates the code first).
|
|
922
|
-
PROPOSAL_DTYPE_SYMBOL_FLIP rev3 Q5=(Y). */
|
|
878
|
+
conversion entry point (it validates the code first). */
|
|
923
879
|
extern ID ca_data_type_sym[CA_NTYPE];
|
|
924
880
|
VALUE rb_ca_data_type_to_sym (int8_t data_type);
|
|
925
881
|
|
|
@@ -932,9 +888,13 @@ extern int ca_obj_num;
|
|
|
932
888
|
|
|
933
889
|
#define CAVIEW(x) ((CAView *)(x))
|
|
934
890
|
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
891
|
+
/* CAREFUL: `flag` is parenthesised. Without it, ca_test_flag(ca, A | B)
|
|
892
|
+
expands to `ca->flags & A | B`, and since & binds tighter than | the
|
|
893
|
+
test is true for every array. ca_unset_flag had the mirror hazard
|
|
894
|
+
through ~. */
|
|
895
|
+
#define ca_set_flag(ca, flag) ( (ca)->flags |= (flag) )
|
|
896
|
+
#define ca_unset_flag(ca, flag) ( (ca)->flags &= ~(flag) )
|
|
897
|
+
#define ca_test_flag(ca, flag) (( (ca)->flags & (flag) ) ? 1 : 0)
|
|
938
898
|
|
|
939
899
|
/* -------------------------------------------------------------------- */
|
|
940
900
|
|
|
@@ -962,7 +922,6 @@ extern const rb_data_type_t careduce_data_type;
|
|
|
962
922
|
extern const rb_data_type_t carefer_data_type;
|
|
963
923
|
extern const rb_data_type_t caselect_data_type;
|
|
964
924
|
extern const rb_data_type_t cashift_data_type;
|
|
965
|
-
extern const rb_data_type_t caunboundrepeat_data_type;
|
|
966
925
|
extern const rb_data_type_t cawindow_data_type;
|
|
967
926
|
|
|
968
927
|
extern const rb_data_type_t carray_mask_data_type;
|
|
@@ -973,7 +932,6 @@ extern const rb_data_type_t careduce_mask_data_type;
|
|
|
973
932
|
extern const rb_data_type_t carefer_mask_data_type;
|
|
974
933
|
extern const rb_data_type_t caselect_mask_data_type;
|
|
975
934
|
extern const rb_data_type_t cashift_mask_data_type;
|
|
976
|
-
extern const rb_data_type_t caunboundrepeat_mask_data_type;
|
|
977
935
|
extern const rb_data_type_t cawindow_mask_data_type;
|
|
978
936
|
|
|
979
937
|
/* -------------------------------------------------------------------- */
|
|
@@ -993,7 +951,6 @@ extern VALUE rb_cCAStrideMask;
|
|
|
993
951
|
extern VALUE rb_cCASelect;
|
|
994
952
|
extern VALUE rb_cCAObject;
|
|
995
953
|
extern VALUE rb_cCARepeat;
|
|
996
|
-
extern VALUE rb_cCAUnboundRepeat;
|
|
997
954
|
extern VALUE rb_cCAIterator;
|
|
998
955
|
|
|
999
956
|
extern VALUE rb_cCArrayMask;
|
|
@@ -1003,7 +960,6 @@ extern VALUE rb_cCAFieldMask;
|
|
|
1003
960
|
extern VALUE rb_cCASelectMask;
|
|
1004
961
|
extern VALUE rb_cCAObjectMask;
|
|
1005
962
|
extern VALUE rb_cCARepeatMask;
|
|
1006
|
-
extern VALUE rb_cCAUnboundRepeatMask;
|
|
1007
963
|
|
|
1008
964
|
extern VALUE rb_mCA;
|
|
1009
965
|
extern VALUE rb_mCAMath;
|
|
@@ -1098,18 +1054,34 @@ extern VALUE rb_cCArrayObject;
|
|
|
1098
1054
|
|
|
1099
1055
|
#ifdef HAVE_COMPLEX_H
|
|
1100
1056
|
|
|
1057
|
+
/* CMPLX(re, im) builds a complex from its two parts without going through
|
|
1058
|
+
"re + I * im". That expression evaluates I * im first, so an im of +0.0
|
|
1059
|
+
yields (0.0 + 0.0i) and adding it to a re of -0.0 gives +0.0: the sign of
|
|
1060
|
+
a negative zero real part is lost. The sign matters -- branch cuts are
|
|
1061
|
+
selected by the sign of a zero (log(-1+0i) = +pi*i, log(-1-0i) = -pi*i).
|
|
1062
|
+
CMPLX is C11; provide it when the toolchain predates that. */
|
|
1063
|
+
#ifndef CMPLX
|
|
1064
|
+
# if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)))
|
|
1065
|
+
# define CMPLX(re, im) __builtin_complex((double)(re), (double)(im))
|
|
1066
|
+
# else
|
|
1067
|
+
# define CMPLX(re, im) \
|
|
1068
|
+
(((union { double _parts[2]; double complex _value; }) \
|
|
1069
|
+
{ { (double)(re), (double)(im) } })._value)
|
|
1070
|
+
# endif
|
|
1071
|
+
#endif
|
|
1072
|
+
|
|
1101
1073
|
static inline double complex
|
|
1102
1074
|
rb_carray_num2cmplx (VALUE num)
|
|
1103
1075
|
{
|
|
1104
1076
|
if ( RB_TYPE_P(num, T_COMPLEX) ) {
|
|
1105
|
-
return NUM2DBL(rb_complex_real(num))
|
|
1077
|
+
return CMPLX(NUM2DBL(rb_complex_real(num)), NUM2DBL(rb_complex_imag(num)));
|
|
1106
1078
|
}
|
|
1107
1079
|
if ( RB_FLOAT_TYPE_P(num) || RB_INTEGER_TYPE_P(num) ) {
|
|
1108
1080
|
return (double complex) NUM2DBL(num);
|
|
1109
1081
|
}
|
|
1110
1082
|
if ( rb_respond_to(num, rb_intern("to_c")) ) {
|
|
1111
1083
|
VALUE c = rb_funcall(num, rb_intern("to_c"), 0);
|
|
1112
|
-
return NUM2DBL(rb_complex_real(c))
|
|
1084
|
+
return CMPLX(NUM2DBL(rb_complex_real(c)), NUM2DBL(rb_complex_imag(c)));
|
|
1113
1085
|
}
|
|
1114
1086
|
if ( rb_respond_to(num, rb_intern("to_f")) ) {
|
|
1115
1087
|
return (double complex) NUM2DBL(rb_funcall(num, rb_intern("to_f"), 0));
|
|
@@ -1176,7 +1148,6 @@ enum {
|
|
|
1176
1148
|
CA_REG_GRID,
|
|
1177
1149
|
CA_REG_MAPPING,
|
|
1178
1150
|
CA_REG_METHOD_CALL,
|
|
1179
|
-
CA_REG_UNBOUND_REPEAT,
|
|
1180
1151
|
CA_REG_MEMBER,
|
|
1181
1152
|
CA_REG_ATTRIBUTE,
|
|
1182
1153
|
}; /* CA_REGION_TYPE */
|
|
@@ -1218,7 +1189,7 @@ typedef struct {
|
|
|
1218
1189
|
/* The element-wise kernel typedefs (ca_monop_func_t / ca_binop_func_t /
|
|
1219
1190
|
ca_triop_func_t / ca_moncmp_func_t / ca_bincmp_func_t), the rb_ca_call_*
|
|
1220
1191
|
drivers, ca_math_call, and the per-data_type dispatch tables now live in
|
|
1221
|
-
carray_math_kernel.h
|
|
1192
|
+
carray_math_kernel.h, which this header
|
|
1222
1193
|
includes at the bottom (umbrella). Declarations only moved — definitions
|
|
1223
1194
|
and ABI are unchanged. */
|
|
1224
1195
|
|
|
@@ -1261,7 +1232,7 @@ CArray *carray_new_adopt (int8_t data_type,
|
|
|
1261
1232
|
VALUE rb_carray_new_adopt (int8_t data_type,
|
|
1262
1233
|
int8_t ndim, ca_size_t *dim, ca_size_t bytes, char *ptr);
|
|
1263
1234
|
|
|
1264
|
-
/*
|
|
1235
|
+
/* Capstone helper: allocate
|
|
1265
1236
|
a reduction-output CArray for kernel_iterator authors. Computes
|
|
1266
1237
|
output shape = self.dim with slab axes removed (ascending order),
|
|
1267
1238
|
collapses to shape [1] when fully reduced. See
|
|
@@ -1273,7 +1244,7 @@ VALUE rb_ca_new_reduced (VALUE self, int8_t *slab_axes,
|
|
|
1273
1244
|
VALUE rb_ca_new_reduced_bytes (VALUE self, int8_t *slab_axes, int8_t naxes,
|
|
1274
1245
|
int32_t data_type, ca_size_t bytes, int keep_axis);
|
|
1275
1246
|
|
|
1276
|
-
/*
|
|
1247
|
+
/* Capstone helper: parse
|
|
1277
1248
|
variadic axis argv into validated int8_t array. Accepts Integer
|
|
1278
1249
|
args or a single Array arg, normalises negative axes (Python-style),
|
|
1279
1250
|
range / duplicate / overflow checks all raise ArgumentError.
|
|
@@ -1347,7 +1318,7 @@ int ca_stride_compose_through (CAStride *leaf, CAStride *parent,
|
|
|
1347
1318
|
|
|
1348
1319
|
/* --- ca_obj_grid.c --- */
|
|
1349
1320
|
|
|
1350
|
-
/*
|
|
1321
|
+
/* rb_ca_grid_new signature
|
|
1351
1322
|
changed to take a per-axis cag_axis_t proto array (private to
|
|
1352
1323
|
ca_obj_grid.c). No external callers exist so the declaration is
|
|
1353
1324
|
removed from the public header. */
|
|
@@ -1371,19 +1342,12 @@ VALUE rb_ca_fake_type (VALUE self, VALUE rtype, VALUE rbytes);
|
|
|
1371
1342
|
|
|
1372
1343
|
VALUE rb_ca_repeat (int argc, VALUE *argv, VALUE self);
|
|
1373
1344
|
|
|
1374
|
-
/* --- ca_obj_unbound_repeat.c --- */
|
|
1375
|
-
|
|
1376
|
-
VALUE rb_ca_ubrep_shave (VALUE self, VALUE other);
|
|
1377
|
-
VALUE rb_ca_rewrap_unbound_repeat (VALUE src, VALUE out);
|
|
1378
|
-
|
|
1379
1345
|
/* --- carray_broadcast.c --- */
|
|
1380
1346
|
|
|
1381
1347
|
VALUE ca_broadcast_view (VALUE src, int8_t ndim, ca_size_t *target_dim);
|
|
1382
1348
|
void ca_broadcast_pair (volatile VALUE *self, volatile VALUE *other);
|
|
1383
|
-
VALUE ca_ubrep_bind_with (VALUE self, VALUE other);
|
|
1384
1349
|
|
|
1385
|
-
/* --- ca_iter_dimension retired
|
|
1386
|
-
reference impl at samples/caiterator/dimension.c --- */
|
|
1350
|
+
/* --- ca_iter_dimension retired: CADimensionIterator -> CASlabIterator --- */
|
|
1387
1351
|
|
|
1388
1352
|
/* -------------------------------------------------------------------- */
|
|
1389
1353
|
|
|
@@ -1436,10 +1400,26 @@ int ca_is_entity (const void *ap);
|
|
|
1436
1400
|
#endif
|
|
1437
1401
|
|
|
1438
1402
|
int ca_is_view (void *ap);
|
|
1403
|
+
|
|
1404
|
+
/* True iff ca is a member of the CAStride family -- the views whose
|
|
1405
|
+
addressing is a linear stride expression over a single parent, and
|
|
1406
|
+
which ca_stride_compose_to_root therefore folds into
|
|
1407
|
+
root->ptr + base + sum(idx[k] * strides[k]). Currently CAStride,
|
|
1408
|
+
CARefer, CABlock, CARepeat, CATranspose, CAFarray and CAField, plus
|
|
1409
|
+
the mask array of each. Membership is decided by the operation table
|
|
1410
|
+
an obj_type was installed with, so an externally installed view that
|
|
1411
|
+
shares the table is recognised too. Passing a non-member to
|
|
1412
|
+
ca_stride_compose_to_root reads the struct past its end, so guard the
|
|
1413
|
+
call with this. (Defined in ca_obj_stride.c, out of line: it indexes
|
|
1414
|
+
ca_func[], and a function keeps that stride out of separately built
|
|
1415
|
+
callers.) */
|
|
1416
|
+
int ca_is_stride_family (const void *ap);
|
|
1417
|
+
|
|
1439
1418
|
int ca_is_readonly (void *ap);
|
|
1440
1419
|
int ca_is_value_array (void *ap);
|
|
1441
1420
|
int ca_is_mask_array (void *ap);
|
|
1442
1421
|
#define ca_is_face(ca) ( ca_test_flag((ca), CA_FLAG_IS_FACE) )
|
|
1422
|
+
#define ca_is_lazy_marker(ca) ( ca_test_flag((ca), CA_FLAG_IS_LAZY_MARKER) )
|
|
1443
1423
|
|
|
1444
1424
|
#define ca_is_attached(ca) ( (ca)->ptr != NULL )
|
|
1445
1425
|
#define ca_is_empty(ca) ( (ca)->elements == 0 )
|
|
@@ -1454,13 +1434,11 @@ int ca_is_mask_array (void *ap);
|
|
|
1454
1434
|
attached), CAWrap, CScalar, and CAStride-family views whose composed
|
|
1455
1435
|
strides are row-major contiguous (alias-attach path). Used by
|
|
1456
1436
|
kernel_iterator's L1 alias decision (ca_iter_can_alias level 1) and
|
|
1457
|
-
by
|
|
1458
|
-
|
|
1459
|
-
the structural property (= aliasable without materialise) rather
|
|
1460
|
-
than the perf characteristic. */
|
|
1437
|
+
by overlay-view dispatch. The name says the structural property
|
|
1438
|
+
(= aliasable without materialise), not the perf characteristic. */
|
|
1461
1439
|
int ca_attach_is_alias (void *ap);
|
|
1462
1440
|
|
|
1463
|
-
/*
|
|
1441
|
+
/* OR operand masks into
|
|
1464
1442
|
ca_out->mask without ca_attach on operand masks (= gathers via
|
|
1465
1443
|
ca_xfer_all into arena scratch then byte OR-folds). ca_out must be
|
|
1466
1444
|
a freshly templated entity. For bang variant where ca_out IS one of
|
|
@@ -1496,6 +1474,27 @@ int ca_is_valid_index (void *ap, ca_size_t *idx);
|
|
|
1496
1474
|
|
|
1497
1475
|
/* API : allocate, attach, update, sync, detach */
|
|
1498
1476
|
|
|
1477
|
+
/* Attach lifecycle contract (R1-R5). Ownership-based, and NOT transitive.
|
|
1478
|
+
This block is the canonical statement of the contract; the other documents
|
|
1479
|
+
copy it. guides/devel/04_attach_lifecycle.md discusses it at length.
|
|
1480
|
+
|
|
1481
|
+
R1 (validity) ca_attach(x) makes x->ptr only valid. It says nothing
|
|
1482
|
+
about any other array.
|
|
1483
|
+
R2 (no transit) Attaching a child does not attach its parent. An
|
|
1484
|
+
implementation may do so as an internal optimisation;
|
|
1485
|
+
never rely on it.
|
|
1486
|
+
R3 (necessity) To touch ca->parent->ptr, call ca_attach(ca->parent)
|
|
1487
|
+
yourself.
|
|
1488
|
+
R4 (ordering) Attaching both parent and child: open parent -> child,
|
|
1489
|
+
close child -> parent, sync in attach order. Symmetric
|
|
1490
|
+
nesting stays correct when a view double-attaches
|
|
1491
|
+
internally (views carry an attach refcount; entities do
|
|
1492
|
+
not).
|
|
1493
|
+
R5 (traffic) Attach hands you a buffer, not a live array. Use x->ptr;
|
|
1494
|
+
a view derived from x composes past the buffer to the
|
|
1495
|
+
root.
|
|
1496
|
+
*/
|
|
1497
|
+
|
|
1499
1498
|
void ca_allocate (void *ap);
|
|
1500
1499
|
void ca_attach (void *ca);
|
|
1501
1500
|
void ca_update (void *ca);
|
|
@@ -1533,10 +1532,10 @@ void ca_store_index (void *ap, ca_size_t *idx, void *ptr);
|
|
|
1533
1532
|
void ca_store_addr (void *ap, ca_size_t addr, void *ptr);
|
|
1534
1533
|
void ca_xfer_index (void *ap, ca_size_t *idx, void *data, int dir);
|
|
1535
1534
|
void ca_xfer_addrs (void *ap, ca_size_t n, ca_size_t *addrs, void *data, int dir);
|
|
1536
|
-
/*
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1535
|
+
/* Shared predicate: detect if addrs[] is a sequential run
|
|
1536
|
+
(addrs[i] == addrs[0]+i for all i). Used by ca_xfer_addrs_dispatch and
|
|
1537
|
+
by view xfer_addrs slots for whole-view / sub-region run detection ->
|
|
1538
|
+
opportunistic engine dispatch. */
|
|
1540
1539
|
int ca_xfer_addrs_is_sequential_run (ca_size_t n, ca_size_t *addrs,
|
|
1541
1540
|
ca_size_t *base_out);
|
|
1542
1541
|
/* Y.1.e: resolve cand through identity CAStride compose-fold to find an
|
|
@@ -1546,6 +1545,25 @@ int ca_xfer_addrs_is_sequential_run (ca_size_t n, ca_size_t *addrs,
|
|
|
1546
1545
|
parent->ptr gate through view CAStride layers (= chain pattern). */
|
|
1547
1546
|
CArray *ca_resolve_attached_root_via_identity (CArray *cand);
|
|
1548
1547
|
|
|
1548
|
+
/* Shared gate for the xfer_stride slots' structural fast paths.
|
|
1549
|
+
|
|
1550
|
+
An xfer_stride request is given over the view's linear ADDRESSES (see the
|
|
1551
|
+
slot comment above), so request axis k need not be view axis k: a caller
|
|
1552
|
+
is free to hand over a transposed region -- counts/strides in one order,
|
|
1553
|
+
the packed destination buffer in another -- and a degenerate axis makes
|
|
1554
|
+
that indistinguishable from an axis-aligned request by divisibility alone
|
|
1555
|
+
(an (n, 1) view has the same native step on both axes). A structural path
|
|
1556
|
+
that composes request axis k onto view axis k must therefore ask first:
|
|
1557
|
+
does request axis k advance view axis k, and stay inside it for the whole
|
|
1558
|
+
traversal? Returns 1 when that holds for every axis (count <= 1 axes move
|
|
1559
|
+
nothing and always pass), 0 when the request is not such a box -- the
|
|
1560
|
+
caller then takes its per-cell fallback, which is address-correct for any
|
|
1561
|
+
request. ndim is the request's rank, which the slots' wiring keeps equal
|
|
1562
|
+
to ca->ndim. */
|
|
1563
|
+
int ca_xfer_stride_request_is_axis_box (void *ap, ca_size_t *starts,
|
|
1564
|
+
ca_size_t *counts,
|
|
1565
|
+
ca_size_t *strides);
|
|
1566
|
+
|
|
1549
1567
|
void ca_xfer_stride (void *ap, ca_size_t *starts, ca_size_t *counts,
|
|
1550
1568
|
ca_size_t *strides, void *data, int dir);
|
|
1551
1569
|
void ca_xfer_all (void *ap, void *data, int dir);
|
|
@@ -1596,7 +1614,7 @@ void ca_fill_stride_whole (void *ap, void *ptr);
|
|
|
1596
1614
|
/* API : mask handling */
|
|
1597
1615
|
|
|
1598
1616
|
extern VALUE CA_UNDEF;
|
|
1599
|
-
extern VALUE
|
|
1617
|
+
extern VALUE CA_UNSPECIFIED;
|
|
1600
1618
|
|
|
1601
1619
|
boolean8_t *ca_mask_ptr (void *ap);
|
|
1602
1620
|
int ca_has_mask (void *ap);
|
|
@@ -1700,8 +1718,8 @@ VALUE rb_ca_wrap_writable (VALUE obj, VALUE vtype);
|
|
|
1700
1718
|
VALUE rb_ca_wrap_readonly (VALUE obj, VALUE vtype);
|
|
1701
1719
|
|
|
1702
1720
|
/* inheritance */
|
|
1703
|
-
/* rb_ca_data_type_inherit / rb_ca_data_type_import were removed in 3.0
|
|
1704
|
-
|
|
1721
|
+
/* rb_ca_data_type_inherit / rb_ca_data_type_import were removed in 3.0.
|
|
1722
|
+
data_class lives on
|
|
1705
1723
|
Face (CARecord) tail; view ctors no longer carry data_class via
|
|
1706
1724
|
@data_class ivar — Face dispatch (CA_FACE_LIFT_IF_FACE) handles it. */
|
|
1707
1725
|
VALUE rb_ca_set_parent (VALUE self, VALUE obj);
|
|
@@ -1748,8 +1766,7 @@ VALUE rb_ca_is_scalar (VALUE self);
|
|
|
1748
1766
|
VALUE rb_obj_is_data_class (VALUE rtype);
|
|
1749
1767
|
VALUE rb_ca_has_data_class (VALUE self);
|
|
1750
1768
|
VALUE rb_ca_data_class (VALUE self);
|
|
1751
|
-
/* rb_ca_set_data_class was removed in 3.0
|
|
1752
|
-
(PROPOSAL_DEPRECATE_LEGACY_DATA_CLASS P.5). The Ruby method
|
|
1769
|
+
/* rb_ca_set_data_class was removed in 3.0. The Ruby method
|
|
1753
1770
|
CArray#data_class= raises ArgumentError with migration message. */
|
|
1754
1771
|
VALUE rb_ca_data_class_decode (VALUE self, VALUE str);
|
|
1755
1772
|
VALUE rb_ca_data_class_encode (VALUE self, VALUE obj);
|
|
@@ -1878,16 +1895,15 @@ void ca_debug ();
|
|
|
1878
1895
|
|
|
1879
1896
|
/* -------------------------------------------------------------------- */
|
|
1880
1897
|
|
|
1881
|
-
/*
|
|
1898
|
+
/* Portable textbook sort kernels.
|
|
1882
1899
|
These are layer ③ true-internal (ca_sort_kernels.h self-describes as
|
|
1883
1900
|
"ext-internal, signatures may change across 3.x"). They are NOT pulled
|
|
1884
|
-
into the carray.h umbrella and NOT installed (
|
|
1885
|
-
H.4.1): the internal consumers (carray_sort_kernel.c / carray_sort.c /
|
|
1901
|
+
into the carray.h umbrella and NOT installed: the internal consumers (carray_sort_kernel.c / carray_sort.c /
|
|
1886
1902
|
carray_partition.c / carray_kernels.c) include ca_sort_kernels.h
|
|
1887
1903
|
directly. */
|
|
1888
1904
|
|
|
1889
1905
|
/* -------------------------------------------------------------------- */
|
|
1890
|
-
/* Public umbrella
|
|
1906
|
+
/* Public umbrella */
|
|
1891
1907
|
/* -------------------------------------------------------------------- */
|
|
1892
1908
|
|
|
1893
1909
|
/* Pull the ext-author / math-backend surface in under the carray.h
|