/src/c-blosc/blosc/shuffle-generic.h
Line | Count | Source (jump to first uncovered line) |
1 | | /********************************************************************* |
2 | | Blosc - Blocked Shuffling and Compression Library |
3 | | |
4 | | Author: Francesc Alted <francesc@blosc.org> |
5 | | |
6 | | See LICENSE.txt for details about copyright and rights to use. |
7 | | **********************************************************************/ |
8 | | |
9 | | /* Generic (non-hardware-accelerated) shuffle/unshuffle routines. |
10 | | These are used when hardware-accelerated functions aren't available |
11 | | for a particular platform; they are also used by the hardware- |
12 | | accelerated functions to handle any remaining elements in a block |
13 | | which isn't a multiple of the hardware's vector size. */ |
14 | | |
15 | | #ifndef SHUFFLE_GENERIC_H |
16 | | #define SHUFFLE_GENERIC_H |
17 | | |
18 | | #include "blosc-common.h" |
19 | | #include <stdlib.h> |
20 | | |
21 | | #ifdef __cplusplus |
22 | | extern "C" { |
23 | | #endif |
24 | | |
25 | | /** |
26 | | Generic (non-hardware-accelerated) shuffle routine. |
27 | | This is the pure element-copying nested loop. It is used by the |
28 | | generic shuffle implementation and also by the vectorized shuffle |
29 | | implementations to process any remaining elements in a block which |
30 | | is not a multiple of (type_size * vector_size). |
31 | | */ |
32 | | static void shuffle_generic_inline(const size_t type_size, |
33 | | const size_t vectorizable_blocksize, const size_t blocksize, |
34 | | const uint8_t* const _src, uint8_t* const _dest) |
35 | 0 | { |
36 | 0 | size_t i, j; |
37 | | /* Calculate the number of elements in the block. */ |
38 | 0 | const size_t neblock_quot = blocksize / type_size; |
39 | 0 | const size_t neblock_rem = blocksize % type_size; |
40 | 0 | const size_t vectorizable_elements = vectorizable_blocksize / type_size; |
41 | | |
42 | | |
43 | | /* Non-optimized shuffle */ |
44 | 0 | for (j = 0; j < type_size; j++) { |
45 | 0 | for (i = vectorizable_elements; i < (size_t)neblock_quot; i++) { |
46 | 0 | _dest[j*neblock_quot+i] = _src[i*type_size+j]; |
47 | 0 | } |
48 | 0 | } |
49 | | |
50 | | /* Copy any leftover bytes in the block without shuffling them. */ |
51 | 0 | memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem); |
52 | 0 | } Unexecuted instantiation: shuffle.c:shuffle_generic_inline Unexecuted instantiation: shuffle-generic.c:shuffle_generic_inline Unexecuted instantiation: shuffle-sse2.c:shuffle_generic_inline Unexecuted instantiation: shuffle-avx2.c:shuffle_generic_inline |
53 | | |
54 | | /** |
55 | | Generic (non-hardware-accelerated) unshuffle routine. |
56 | | This is the pure element-copying nested loop. It is used by the |
57 | | generic unshuffle implementation and also by the vectorized unshuffle |
58 | | implementations to process any remaining elements in a block which |
59 | | is not a multiple of (type_size * vector_size). |
60 | | */ |
61 | | static void unshuffle_generic_inline(const size_t type_size, |
62 | | const size_t vectorizable_blocksize, const size_t blocksize, |
63 | | const uint8_t* const _src, uint8_t* const _dest) |
64 | 0 | { |
65 | 0 | size_t i, j; |
66 | | |
67 | | /* Calculate the number of elements in the block. */ |
68 | 0 | const size_t neblock_quot = blocksize / type_size; |
69 | 0 | const size_t neblock_rem = blocksize % type_size; |
70 | 0 | const size_t vectorizable_elements = vectorizable_blocksize / type_size; |
71 | | |
72 | | /* Non-optimized unshuffle */ |
73 | 0 | for (i = vectorizable_elements; i < (size_t)neblock_quot; i++) { |
74 | 0 | for (j = 0; j < type_size; j++) { |
75 | 0 | _dest[i*type_size+j] = _src[j*neblock_quot+i]; |
76 | 0 | } |
77 | 0 | } |
78 | | |
79 | | /* Copy any leftover bytes in the block without unshuffling them. */ |
80 | 0 | memcpy(_dest + (blocksize - neblock_rem), _src + (blocksize - neblock_rem), neblock_rem); |
81 | 0 | } Unexecuted instantiation: shuffle.c:unshuffle_generic_inline Unexecuted instantiation: shuffle-generic.c:unshuffle_generic_inline Unexecuted instantiation: shuffle-sse2.c:unshuffle_generic_inline Unexecuted instantiation: shuffle-avx2.c:unshuffle_generic_inline |
82 | | |
83 | | /** |
84 | | Generic (non-hardware-accelerated) shuffle routine. |
85 | | */ |
86 | | BLOSC_NO_EXPORT void blosc_internal_shuffle_generic(const size_t bytesoftype, const size_t blocksize, |
87 | | const uint8_t* const _src, uint8_t* const _dest); |
88 | | |
89 | | /** |
90 | | Generic (non-hardware-accelerated) unshuffle routine. |
91 | | */ |
92 | | BLOSC_NO_EXPORT void blosc_internal_unshuffle_generic(const size_t bytesoftype, const size_t blocksize, |
93 | | const uint8_t* const _src, uint8_t* const _dest); |
94 | | |
95 | | #ifdef __cplusplus |
96 | | } |
97 | | #endif |
98 | | |
99 | | #endif /* SHUFFLE_GENERIC_H */ |