-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiarray_views.c
More file actions
604 lines (549 loc) · 25.4 KB
/
Copy pathiarray_views.c
File metadata and controls
604 lines (549 loc) · 25.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
/*
* Copyright ironArray SL 2021.
*
* All rights reserved.
*
* This software is the confidential and proprietary information of ironArray SL
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license agreement.
*
*/
#include "iarray_private.h"
#include <libiarray/iarray.h>
#include "caterva_utils.h"
#include <stdio.h>
typedef struct {
void (*cast)(void *, void *, int32_t);
//!< Cast function.
blosc2_schunk *viewed_schunk;
//!< Predecessor's schunk
blosc2_schunk *first_schunk;
//!< View's schunk
} view_postparams_udata;
#define CAST (void (*)(void *, void *, int32_t))
#define D_I64_PARAMS const double *src, int64_t *dst, int32_t nelems
#define D_UI64_PARAMS const double *src, uint64_t *dst, int32_t nelems
#define F_D_PARAMS const float *src, double *dst, int32_t nelems
#define F_I64_PARAMS const float *src, int64_t *dst, int32_t nelems
#define F_I32_PARAMS const float *src, int32_t *dst, int32_t nelems
#define F_UI64_PARAMS const float *src, uint64_t *dst, int32_t nelems
#define F_UI32_PARAMS const float *src, uint32_t *dst, int32_t nelems
#define I64_D_PARAMS const int64_t *src, double *dst, int32_t nelems
#define I64_UI64_PARAMS const int64_t *src, uint64_t *dst, int32_t nelems
#define I32_D_PARAMS const int32_t *src, double *dst, int32_t nelems
#define I32_F_PARAMS const int32_t *src, float *dst, int32_t nelems
#define I32_I64_PARAMS const int32_t *src, int64_t *dst, int32_t nelems
#define I32_UI64_PARAMS const int32_t *src, uint64_t *dst, int32_t nelems
#define I32_UI32_PARAMS const int32_t *src, uint32_t *dst, int32_t nelems
#define I16_D_PARAMS const int16_t *src, double *dst, int32_t nelems
#define I16_F_PARAMS const int16_t *src, float *dst, int32_t nelems
#define I16_I64_PARAMS const int16_t *src, int64_t *dst, int32_t nelems
#define I16_I32_PARAMS const int16_t *src, int32_t *dst, int32_t nelems
#define I16_UI64_PARAMS const int16_t *src, uint64_t *dst, int32_t nelems
#define I16_UI32_PARAMS const int16_t *src, uint32_t *dst, int32_t nelems
#define I16_UI16_PARAMS const int16_t *src, uint16_t *dst, int32_t nelems
#define I8_D_PARAMS const int8_t *src, double *dst, int32_t nelems
#define I8_F_PARAMS const int8_t *src, float *dst, int32_t nelems
#define I8_I64_PARAMS const int8_t *src, int64_t *dst, int32_t nelems
#define I8_I32_PARAMS const int8_t *src, int32_t *dst, int32_t nelems
#define I8_I16_PARAMS const int8_t *src, int16_t *dst, int32_t nelems
#define I8_UI64_PARAMS const int8_t *src, uint64_t *dst, int32_t nelems
#define I8_UI32_PARAMS const int8_t *src, uint32_t *dst, int32_t nelems
#define I8_UI16_PARAMS const int8_t *src, uint16_t *dst, int32_t nelems
#define I8_UI8_PARAMS const int8_t *src, uint8_t *dst, int32_t nelems
#define I8_B_PARAMS const int8_t *src, bool *dst, int32_t nelems
#define UI64_D_PARAMS const uint64_t *src, double *dst, int32_t nelems
#define UI64_I64_PARAMS const uint64_t *src, int64_t *dst, int32_t nelems
#define UI32_D_PARAMS const uint32_t *src, double *dst, int32_t nelems
#define UI32_F_PARAMS const uint32_t *src, float *dst, int32_t nelems
#define UI32_I64_PARAMS const uint32_t *src, int64_t *dst, int32_t nelems
#define UI32_I32_PARAMS const uint32_t *src, int32_t *dst, int32_t nelems
#define UI32_UI64_PARAMS const uint32_t *src, uint64_t *dst, int32_t nelems
#define UI16_D_PARAMS const uint16_t *src, double *dst, int32_t nelems
#define UI16_F_PARAMS const uint16_t *src, float *dst, int32_t nelems
#define UI16_I64_PARAMS const uint16_t *src, int64_t *dst, int32_t nelems
#define UI16_I32_PARAMS const uint16_t *src, int32_t *dst, int32_t nelems
#define UI16_I16_PARAMS const uint16_t *src, int16_t *dst, int32_t nelems
#define UI16_UI64_PARAMS const uint16_t *src, uint64_t *dst, int32_t nelems
#define UI16_UI32_PARAMS const uint16_t *src, uint32_t *dst, int32_t nelems
#define UI8_D_PARAMS const uint8_t *src, double *dst, int32_t nelems
#define UI8_F_PARAMS const uint8_t *src, float *dst, int32_t nelems
#define UI8_I64_PARAMS const uint8_t *src, int64_t *dst, int32_t nelems
#define UI8_I32_PARAMS const uint8_t *src, int32_t *dst, int32_t nelems
#define UI8_I16_PARAMS const uint8_t *src, int16_t *dst, int32_t nelems
#define UI8_I8_PARAMS const uint8_t *src, int8_t *dst, int32_t nelems
#define UI8_UI64_PARAMS const uint8_t *src, uint64_t *dst, int32_t nelems
#define UI8_UI32_PARAMS const uint8_t *src, uint32_t *dst, int32_t nelems
#define UI8_UI16_PARAMS const uint8_t *src, uint16_t *dst, int32_t nelems
#define UI8_B_PARAMS const uint8_t *src, bool *dst, int32_t nelems
#define B_D_PARAMS const bool *src, double *dst, int32_t nelems
#define B_F_PARAMS const bool *src, float *dst, int32_t nelems
#define B_I64_PARAMS const bool *src, int64_t *dst, int32_t nelems
#define B_I32_PARAMS const bool *src, int32_t *dst, int32_t nelems
#define B_I16_PARAMS const bool *src, int16_t *dst, int32_t nelems
#define B_I8_PARAMS const bool *src, int8_t *dst, int32_t nelems
#define B_UI64_PARAMS const bool *src, uint64_t *dst, int32_t nelems
#define B_UI32_PARAMS const bool *src, uint32_t *dst, int32_t nelems
#define B_UI16_PARAMS const bool *src, uint16_t *dst, int32_t nelems
#define B_UI8_PARAMS const bool *src, uint8_t *dst, int32_t nelems
#define VIEW_CAST \
for (int i = 0; i < nelems; ++i) { \
*dst = *src; \
dst++; \
src++; \
}
static void d_i64_cast(D_I64_PARAMS) { VIEW_CAST }
static void d_ui64_cast(D_UI64_PARAMS) { VIEW_CAST }
static void f_d_cast(F_D_PARAMS) { VIEW_CAST }
static void f_i64_cast(F_I64_PARAMS) { VIEW_CAST }
static void f_i32_cast(F_I32_PARAMS) { VIEW_CAST }
static void f_ui64_cast(F_UI64_PARAMS) { VIEW_CAST }
static void f_ui32_cast(F_UI32_PARAMS) { VIEW_CAST }
static void i64_d_cast(I64_D_PARAMS) { VIEW_CAST }
static void i64_ui64_cast(I64_UI64_PARAMS) { VIEW_CAST }
static void i32_d_cast(I32_D_PARAMS) { VIEW_CAST }
static void i32_f_cast(I32_F_PARAMS) { VIEW_CAST }
static void i32_i64_cast(I32_I64_PARAMS) { VIEW_CAST }
static void i32_ui64_cast(I32_UI64_PARAMS) { VIEW_CAST }
static void i32_ui32_cast(I32_UI32_PARAMS) { VIEW_CAST }
static void i16_d_cast(I16_D_PARAMS) { VIEW_CAST }
static void i16_f_cast(I16_F_PARAMS) { VIEW_CAST }
static void i16_i64_cast(I16_I64_PARAMS) { VIEW_CAST }
static void i16_i32_cast(I16_I32_PARAMS) { VIEW_CAST }
static void i16_ui64_cast(I16_UI64_PARAMS) { VIEW_CAST }
static void i16_ui32_cast(I16_UI32_PARAMS) { VIEW_CAST }
static void i16_ui16_cast(I16_UI16_PARAMS) { VIEW_CAST }
static void i8_d_cast(I8_D_PARAMS) { VIEW_CAST }
static void i8_f_cast(I8_F_PARAMS) { VIEW_CAST }
static void i8_i64_cast(I8_I64_PARAMS) { VIEW_CAST }
static void i8_i32_cast(I8_I32_PARAMS) { VIEW_CAST }
static void i8_i16_cast(I8_I16_PARAMS) { VIEW_CAST }
static void i8_ui64_cast(I8_UI64_PARAMS) { VIEW_CAST }
static void i8_ui32_cast(I8_UI32_PARAMS) { VIEW_CAST }
static void i8_ui16_cast(I8_UI16_PARAMS) { VIEW_CAST }
static void i8_ui8_cast(I8_UI8_PARAMS) { VIEW_CAST }
static void i8_b_cast(I8_B_PARAMS) { VIEW_CAST }
static void ui64_d_cast(UI64_D_PARAMS) { VIEW_CAST }
static void ui64_i64_cast(UI64_I64_PARAMS) { VIEW_CAST }
static void ui32_d_cast(UI32_D_PARAMS) { VIEW_CAST }
static void ui32_f_cast(UI32_F_PARAMS) { VIEW_CAST }
static void ui32_i64_cast(UI32_I64_PARAMS) { VIEW_CAST }
static void ui32_i32_cast(UI32_I32_PARAMS) { VIEW_CAST }
static void ui32_ui64_cast(UI32_UI64_PARAMS) { VIEW_CAST }
static void ui16_d_cast(UI16_D_PARAMS) { VIEW_CAST }
static void ui16_f_cast(UI16_F_PARAMS) { VIEW_CAST }
static void ui16_i64_cast(UI16_I64_PARAMS) { VIEW_CAST }
static void ui16_i32_cast(UI16_I32_PARAMS) { VIEW_CAST }
static void ui16_i16_cast(UI16_I16_PARAMS) { VIEW_CAST }
static void ui16_ui64_cast(UI16_UI64_PARAMS) { VIEW_CAST }
static void ui16_ui32_cast(UI16_UI32_PARAMS) { VIEW_CAST }
static void ui8_d_cast(UI8_D_PARAMS) { VIEW_CAST }
static void ui8_f_cast(UI8_F_PARAMS) { VIEW_CAST }
static void ui8_i64_cast(UI8_I64_PARAMS) { VIEW_CAST }
static void ui8_i32_cast(UI8_I32_PARAMS) { VIEW_CAST }
static void ui8_i16_cast(UI8_I16_PARAMS) { VIEW_CAST }
static void ui8_i8_cast(UI8_I8_PARAMS) { VIEW_CAST }
static void ui8_ui64_cast(UI8_UI64_PARAMS) { VIEW_CAST }
static void ui8_ui32_cast(UI8_UI32_PARAMS) { VIEW_CAST }
static void ui8_ui16_cast(UI8_UI16_PARAMS) { VIEW_CAST }
static void ui8_b_cast(UI8_B_PARAMS) { VIEW_CAST }
static void b_d_cast(B_D_PARAMS) { VIEW_CAST }
static void b_f_cast(B_F_PARAMS) { VIEW_CAST }
static void b_i64_cast(B_I64_PARAMS) { VIEW_CAST }
static void b_i32_cast(B_I32_PARAMS) { VIEW_CAST }
static void b_i16_cast(B_I16_PARAMS) { VIEW_CAST }
static void b_i8_cast(B_I8_PARAMS) { VIEW_CAST }
static void b_ui64_cast(B_UI64_PARAMS) { VIEW_CAST }
static void b_ui32_cast(B_UI32_PARAMS) { VIEW_CAST }
static void b_ui16_cast(B_UI16_PARAMS) { VIEW_CAST }
static void b_ui8_cast(B_UI8_PARAMS) { VIEW_CAST }
ina_rc_t type_view_postfilter(blosc2_postfilter_params *postparams)
{
view_postparams_udata *udata = postparams->user_data;
uint8_t *chunk;
bool needs_free;
if (udata->first_schunk->dctx->threads_started > 1) {
pthread_mutex_lock(&udata->first_schunk->dctx->nchunk_mutex);
}
int csize = blosc2_schunk_get_lazychunk(udata->viewed_schunk, postparams->nchunk, &chunk,
&needs_free);
if (udata->first_schunk->dctx->threads_started > 1) {
pthread_mutex_unlock(&udata->first_schunk->dctx->nchunk_mutex);
}
if (csize < 0) {
IARRAY_TRACE1(iarray.tracing, "Error getting lazy chunk");
return IARRAY_ERR_BLOSC_FAILED;
}
blosc2_dparams dparams = {.schunk = udata->viewed_schunk,
.postfilter = udata->viewed_schunk->dctx->postfilter,
.postparams = udata->viewed_schunk->dctx->postparams,
.nthreads = 1};
blosc2_context *dctx = blosc2_create_dctx(dparams);
int block_nitems = postparams->size / postparams->typesize;
int32_t prop = postparams->typesize / udata->viewed_schunk->typesize;
uint8_t *aux = malloc(postparams->size / prop);
int bsize = blosc2_getitem_ctx(dctx, chunk, csize,
postparams->nblock * block_nitems,
block_nitems, aux, postparams->size / prop);
if (needs_free) {
free(chunk);
}
if (bsize < 0) {
blosc2_free_ctx(dctx);
IARRAY_TRACE1(iarray.tracing, "Error getting block");
return IARRAY_ERR_BLOSC_FAILED;
}
udata->cast(aux, postparams->out, block_nitems);
free(aux);
blosc2_free_ctx(dctx);
return INA_SUCCESS;
}
ina_rc_t slice_view_postfilter(blosc2_postfilter_params *postparams)
{
view_postparams_udata *udata = postparams->user_data;
uint8_t *chunk;
bool needs_free;
if (udata->first_schunk->dctx->threads_started > 1) {
pthread_mutex_lock(&udata->first_schunk->dctx->nchunk_mutex);
}
int csize = blosc2_schunk_get_lazychunk(udata->viewed_schunk, postparams->nchunk, &chunk,
&needs_free);
if (udata->first_schunk->dctx->threads_started > 1) {
pthread_mutex_unlock(&udata->first_schunk->dctx->nchunk_mutex);
}
if (csize < 0) {
IARRAY_TRACE1(iarray.tracing, "Error getting lazy chunk");
return IARRAY_ERR_BLOSC_FAILED;
}
blosc2_dparams dparams = {.schunk = udata->viewed_schunk,
.postfilter = udata->viewed_schunk->dctx->postfilter,
.postparams = udata->viewed_schunk->dctx->postparams,
.nthreads = 1};
blosc2_context *dctx = blosc2_create_dctx(dparams);
int block_nitems = udata->viewed_schunk->blocksize / postparams->typesize;
int bsize = blosc2_getitem_ctx(dctx, chunk, csize,
postparams->nblock * block_nitems,
block_nitems, postparams->out, postparams->size);
if (needs_free) {
free(chunk);
}
if (bsize < 0) {
blosc2_free_ctx(dctx);
IARRAY_TRACE1(iarray.tracing, "Error getting block");
return IARRAY_ERR_BLOSC_FAILED;
}
blosc2_free_ctx(dctx);
return INA_SUCCESS;
}
INA_API(ina_rc_t) iarray_add_view_postfilter(iarray_container_t *view, iarray_container_t *view_pred)
{
INA_VERIFY_NOT_NULL(view);
// Create params
blosc2_dparams *dparams;
blosc2_schunk_get_dparams(view->catarr->sc, &dparams);
blosc2_postfilter_params *postparams = malloc(sizeof(blosc2_postfilter_params));
view_postparams_udata *view_postparams = malloc(sizeof(view_postparams_udata));
view_postparams->viewed_schunk = view_pred->catarr->sc;
if (view->dtshape->dtype == view_pred->dtshape->dtype) {
dparams->postfilter = (blosc2_postfilter_fn) slice_view_postfilter;
view_postparams->cast = NULL;
}
else {
dparams->postfilter = (blosc2_postfilter_fn) type_view_postfilter;
switch (view->container_viewed->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST d_i64_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST d_ui64_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_FLOAT: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST f_d_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST f_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST f_i32_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST f_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST f_ui32_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_INT64: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE: {
view_postparams->cast = CAST i64_d_cast;
break;
}
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST i64_ui64_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_INT32: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST i32_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST i32_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST i32_i64_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST i32_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST i32_ui32_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_INT16: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST i16_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST i16_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST i16_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST i16_i32_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST i16_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST i16_ui32_cast;
break;
case IARRAY_DATA_TYPE_UINT16:
view_postparams->cast = CAST i16_ui16_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_INT8: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST i8_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST i8_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST i8_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST i8_i32_cast;
break;
case IARRAY_DATA_TYPE_INT16:
view_postparams->cast = CAST i8_i16_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST i8_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST i8_ui32_cast;
break;
case IARRAY_DATA_TYPE_UINT16:
view_postparams->cast = CAST i8_ui16_cast;
break;
case IARRAY_DATA_TYPE_UINT8:
view_postparams->cast = CAST i8_ui8_cast;
break;
case IARRAY_DATA_TYPE_BOOL:
view_postparams->cast = CAST i8_b_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_UINT64: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST ui64_d_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST ui64_i64_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_UINT32: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST ui32_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST ui32_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST ui32_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST ui32_i32_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST ui32_ui64_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_UINT16: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST ui16_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST ui16_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST ui16_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST ui16_i32_cast;
break;
case IARRAY_DATA_TYPE_INT16:
view_postparams->cast = CAST ui16_i16_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST ui16_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST ui16_ui32_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_UINT8: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST ui8_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST ui8_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST ui8_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST ui8_i32_cast;
break;
case IARRAY_DATA_TYPE_INT16:
view_postparams->cast = CAST ui8_i16_cast;
break;
case IARRAY_DATA_TYPE_INT8:
view_postparams->cast = CAST ui8_i8_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST ui8_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST ui8_ui32_cast;
break;
case IARRAY_DATA_TYPE_UINT16:
view_postparams->cast = CAST ui8_ui16_cast;
break;
case IARRAY_DATA_TYPE_BOOL:
view_postparams->cast = CAST ui8_b_cast;
break;
default:
goto fail;
}
break;
}
case IARRAY_DATA_TYPE_BOOL: {
switch (view->dtshape->dtype) {
case IARRAY_DATA_TYPE_DOUBLE:
view_postparams->cast = CAST b_d_cast;
break;
case IARRAY_DATA_TYPE_FLOAT:
view_postparams->cast = CAST b_f_cast;
break;
case IARRAY_DATA_TYPE_INT64:
view_postparams->cast = CAST b_i64_cast;
break;
case IARRAY_DATA_TYPE_INT32:
view_postparams->cast = CAST b_i32_cast;
break;
case IARRAY_DATA_TYPE_INT16:
view_postparams->cast = CAST b_i16_cast;
break;
case IARRAY_DATA_TYPE_INT8:
view_postparams->cast = CAST b_i8_cast;
break;
case IARRAY_DATA_TYPE_UINT64:
view_postparams->cast = CAST b_ui64_cast;
break;
case IARRAY_DATA_TYPE_UINT32:
view_postparams->cast = CAST b_ui32_cast;
break;
case IARRAY_DATA_TYPE_UINT16:
view_postparams->cast = CAST b_ui16_cast;
break;
case IARRAY_DATA_TYPE_UINT8:
view_postparams->cast = CAST b_ui8_cast;
break;
default:
goto fail;
}
break;
}
default:
goto fail;
}
}
view_postparams->first_schunk = view->catarr->sc;
postparams->user_data = (void*)view_postparams;
dparams->postparams = postparams;
// Disable multithreading on views from views. This is currently creating race conditions,
// probably accessing parts of the super-chunk (but could be totally unrelated).
// We still need to check how this might affect performance when views are used in
// expressions, but disabling multithreading is a safer option for the time being.
if (view_pred->container_viewed != NULL) {
dparams->nthreads = 1;
}
// Create new context since postparams is empty in the old one
blosc2_free_ctx(view->catarr->sc->dctx);
view->catarr->sc->dctx = blosc2_create_dctx(*dparams);
free(dparams);
return INA_SUCCESS;
fail:
IARRAY_TRACE1(iarray.error, "Only upcasting is supported");
return IARRAY_ERR_INVALID_DTYPE;
}