00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef H5Vprivate_H
00021 #define H5Vprivate_H
00022
00023
00024 #include "H5private.h"
00025 #include "H5Eprivate.h"
00026
00027
00028 #define H5V_vector_eq_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)==0)
00029 #define H5V_vector_lt_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)<0)
00030 #define H5V_vector_gt_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)>0)
00031 #define H5V_vector_le_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)<=0)
00032 #define H5V_vector_ge_s(N,V1,V2) (H5V_vector_cmp_s (N, V1, V2)>=0)
00033 #define H5V_vector_eq_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)==0)
00034 #define H5V_vector_lt_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)<0)
00035 #define H5V_vector_gt_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)>0)
00036 #define H5V_vector_le_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)<=0)
00037 #define H5V_vector_ge_u(N,V1,V2) (H5V_vector_cmp_u (N, V1, V2)>=0)
00038
00039
00040 #define H5V_vector_cpy(N,DST,SRC) { \
00041 assert (sizeof(*(DST))==sizeof(*(SRC))); \
00042 if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(*(DST))); \
00043 else HDmemset (DST, 0, (N)*sizeof(*(DST))); \
00044 }
00045
00046 #define H5V_vector_zero(N,DST) HDmemset(DST,0,(N)*sizeof(*(DST)))
00047
00048
00049 #define H5V_ZERO NULL
00050
00051 H5_DLL hsize_t H5V_hyper_stride(unsigned n, const hsize_t *size,
00052 const hsize_t *total_size,
00053 const hsize_t *offset,
00054 hsize_t *stride);
00055 H5_DLL htri_t H5V_hyper_disjointp(unsigned n, const hsize_t *offset1,
00056 const uint32_t *size1, const hsize_t *offset2, const uint32_t *size2);
00057 H5_DLL htri_t H5V_hyper_eq(unsigned n, const hsize_t *offset1,
00058 const hsize_t *size1, const hsize_t *offset2,
00059 const hsize_t *size2);
00060 H5_DLL herr_t H5V_hyper_fill(unsigned n, const hsize_t *_size,
00061 const hsize_t *total_size,
00062 const hsize_t *offset, void *_dst,
00063 unsigned fill_value);
00064 H5_DLL herr_t H5V_hyper_copy(unsigned n, const hsize_t *size,
00065 const hsize_t *dst_total_size,
00066 const hsize_t *dst_offset, void *_dst,
00067 const hsize_t *src_total_size,
00068 const hsize_t *src_offset, const void *_src);
00069 H5_DLL herr_t H5V_stride_fill(unsigned n, hsize_t elmt_size, const hsize_t *size,
00070 const hsize_t *stride, void *_dst,
00071 unsigned fill_value);
00072 H5_DLL herr_t H5V_stride_copy(unsigned n, hsize_t elmt_size, const hsize_t *_size,
00073 const hsize_t *dst_stride, void *_dst,
00074 const hsize_t *src_stride, const void *_src);
00075 H5_DLL herr_t H5V_stride_copy_s(unsigned n, hsize_t elmt_size, const hsize_t *_size,
00076 const hssize_t *dst_stride, void *_dst,
00077 const hssize_t *src_stride, const void *_src);
00078 H5_DLL herr_t H5V_array_fill(void *_dst, const void *src, size_t size,
00079 size_t count);
00080 H5_DLL herr_t H5V_array_down(unsigned n, const hsize_t *total_size,
00081 hsize_t *down);
00082 H5_DLL hsize_t H5V_array_offset_pre(unsigned n,
00083 const hsize_t *acc, const hsize_t *offset);
00084 H5_DLL hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size,
00085 const hsize_t *offset);
00086 H5_DLL herr_t H5V_array_calc(hsize_t offset, unsigned n,
00087 const hsize_t *total_size, hsize_t *coords);
00088 H5_DLL herr_t H5V_chunk_index(unsigned ndims, const hsize_t *coord,
00089 const uint32_t *chunk, const hsize_t *down_nchunks, hsize_t *chunk_idx);
00090 H5_DLL ssize_t H5V_memcpyvv(void *_dst,
00091 size_t dst_max_nseq, size_t *dst_curr_seq, size_t dst_len_arr[], hsize_t dst_off_arr[],
00092 const void *_src,
00093 size_t src_max_nseq, size_t *src_curr_seq, size_t src_len_arr[], hsize_t src_off_arr[]);
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 static H5_inline hsize_t UNUSED
00116 H5V_vector_reduce_product(unsigned n, const hsize_t *v)
00117 {
00118 hsize_t ret_value = 1;
00119
00120
00121 FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_reduce_product)
00122
00123 if (n && !v) HGOTO_DONE(0)
00124 while (n--) ret_value *= *v++;
00125
00126 done:
00127 FUNC_LEAVE_NOAPI(ret_value)
00128 }
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 static H5_inline htri_t UNUSED
00148 H5V_vector_zerop_u(int n, const hsize_t *v)
00149 {
00150 htri_t ret_value=TRUE;
00151
00152
00153 FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_zerop_u)
00154
00155 if (!v)
00156 HGOTO_DONE(TRUE)
00157 while (n--)
00158 if (*v++)
00159 HGOTO_DONE(FALSE)
00160
00161 done:
00162 FUNC_LEAVE_NOAPI(ret_value)
00163 }
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 static H5_inline htri_t UNUSED
00183 H5V_vector_zerop_s(int n, const hssize_t *v)
00184 {
00185 htri_t ret_value=TRUE;
00186
00187
00188 FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_zerop_s)
00189
00190 if (!v)
00191 HGOTO_DONE(TRUE)
00192 while (n--)
00193 if (*v++)
00194 HGOTO_DONE(FALSE)
00195
00196 done:
00197 FUNC_LEAVE_NOAPI(ret_value)
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 static H5_inline int UNUSED
00220 H5V_vector_cmp_u (unsigned n, const hsize_t *v1, const hsize_t *v2)
00221 {
00222 int ret_value=0;
00223
00224
00225 FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_u)
00226
00227 if (v1 == v2) HGOTO_DONE(0)
00228 if (v1 == NULL) HGOTO_DONE(-1)
00229 if (v2 == NULL) HGOTO_DONE(1)
00230 while (n--) {
00231 if (*v1 < *v2) HGOTO_DONE(-1)
00232 if (*v1 > *v2) HGOTO_DONE(1)
00233 v1++;
00234 v2++;
00235 }
00236
00237 done:
00238 FUNC_LEAVE_NOAPI(ret_value)
00239 }
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 static H5_inline int UNUSED
00262 H5V_vector_cmp_s (unsigned n, const hssize_t *v1, const hssize_t *v2)
00263 {
00264 int ret_value=0;
00265
00266
00267 FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5V_vector_cmp_s)
00268
00269 if (v1 == v2) HGOTO_DONE(0)
00270 if (v1 == NULL) HGOTO_DONE(-1)
00271 if (v2 == NULL) HGOTO_DONE(1)
00272 while (n--) {
00273 if (*v1 < *v2) HGOTO_DONE(-1)
00274 if (*v1 > *v2) HGOTO_DONE(1)
00275 v1++;
00276 v2++;
00277 }
00278
00279 done:
00280 FUNC_LEAVE_NOAPI(ret_value)
00281 }
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298 static H5_inline void UNUSED
00299 H5V_vector_inc(int n, hsize_t *v1, const hsize_t *v2)
00300 {
00301 while (n--) *v1++ += *v2++;
00302 }
00303
00304
00305 static const unsigned char LogTable256[] =
00306 {
00307 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
00308 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
00309 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
00310 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
00311 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
00312 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
00313 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
00314 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
00315 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00316 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00317 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00318 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00319 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00320 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00321 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
00322 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7
00323 };
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345 static H5_inline unsigned UNUSED
00346 H5V_log2_gen(uint64_t n)
00347 {
00348 unsigned r;
00349 register unsigned int t, tt, ttt;
00350
00351 #ifdef H5_BAD_LOG2_CODE_GENERATED
00352 if(n > (uint64_t)0x7fffffffffffffff)
00353 r = 63;
00354 else {
00355 n &= (uint64_t)0x7fffffffffffffff;
00356 #endif
00357 if((ttt = (unsigned)(n >> 32)))
00358 if((tt = (unsigned)(n >> 48)))
00359 r = (t = (unsigned)(n >> 56)) ? 56 + (unsigned)LogTable256[t] : 48 + (unsigned)LogTable256[tt & 0xFF];
00360 else
00361 r = (t = (unsigned)(n >> 40)) ? 40 + (unsigned)LogTable256[t] : 32 + (unsigned)LogTable256[ttt & 0xFF];
00362 else
00363 if((tt = (unsigned)(n >> 16)))
00364 r = (t = (unsigned)(n >> 24)) ? 24 + (unsigned)LogTable256[t] : 16 + (unsigned)LogTable256[tt & 0xFF];
00365 else
00366
00367 r = (t = (unsigned)(n >> 8)) ? 8 + (unsigned)LogTable256[t] : (unsigned)LogTable256[(uint8_t)n];
00368 #ifdef H5_BAD_LOG2_CODE_GENERATED
00369 }
00370 #endif
00371
00372 return(r);
00373 }
00374
00375
00376
00377 static const unsigned MultiplyDeBruijnBitPosition[32] =
00378 {
00379 0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8,
00380 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9
00381 };
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 static H5_inline unsigned UNUSED
00403 H5V_log2_of2(uint32_t n)
00404 {
00405 #ifndef NDEBUG
00406 HDassert(POWER_OF_TWO(n));
00407 #endif
00408 return(MultiplyDeBruijnBitPosition[(n * (uint32_t)0x077CB531UL) >> 27]);
00409 }
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425 static H5_inline unsigned UNUSED
00426 H5V_limit_enc_size(uint64_t limit)
00427 {
00428 return (H5V_log2_gen(limit) / 8) + 1;
00429 }
00430
00431 #endif
00432