JASSv2
compress_integer_elias_gamma_simd_vb.h
Go to the documentation of this file.
1 /*
2  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB.H
3  --------------------------------------
4  Copyright (c) 2018 Andrew Trotman
5  Released under the 2-clause BSD license (See:https://en.wikipedia.org/wiki/BSD_licenses)
6 */
13 #pragma once
14 
15 #include <stdint.h>
16 #include <string.h>
17 #include <immintrin.h>
18 
20 
21  /*
22  CLASS COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB
23  ------------------------------------------
24  */
32  {
33  protected:
34  static const uint32_t mask_set[33][16];
35 
36  protected:
37  /*
38  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB::COMPUTE_SELECTOR()
39  --------------------------------------------------------
40  */
46  static uint32_t compute_selector(const uint8_t *encodings);
47 
48  /*
49  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB::FIND_FIRST_SET_BIT()
50  ----------------------------------------------------------
51  */
57  static forceinline uint64_t find_first_set_bit(uint64_t value)
58  {
59  return _tzcnt_u64(value) + 1;
60  }
61 
62  public:
63  /*
64  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB::ENCODE()
65  ----------------------------------------------
66  */
75  virtual size_t encode(void *encoded, size_t encoded_buffer_length, const integer *source, size_t source_integers);
76 
77  /*
78  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB::DECODE()
79  ----------------------------------------------
80  */
88  virtual void decode(integer *decoded, size_t integers_to_decode, const void *source, size_t source_length);
89 
90  /*
91  COMPRESS_INTEGER_ELIAS_GAMMA_SIMD_VB::DECODE_WITH_WRITER()
92  ----------------------------------------------------------
93  */
100 #ifdef SIMD_JASS
101  virtual void decode_with_writer(size_t integers_to_decode, const void *source_as_void, size_t source_length);
102 #endif
103 
104  /*
105  For JASS V1
106  */
107  virtual long long compress(unsigned char *destination, long long destination_length, uint32_t *source, long long source_integers)
108  {
109  return encode(destination, destination_length, source, source_integers);
110  }
111 
112  virtual void decompress(uint32_t *destination, unsigned char *source, long long destination_integers)
113  {
114  /* Nothing */
115  }
116 
117  };
118 
119 
static uint32_t compute_selector(const uint8_t *encodings)
Computer the selector to use for this encoding.
Definition: compress_integer_elias_gamma_simd_vb.cpp:24
Variable byte compression for integer sequences.
Definition: compress_integer_variable_byte.h:39
static forceinline uint64_t find_first_set_bit(uint64_t value)
return the position of the least significant set bit (using a single machine code instruction) ...
Definition: compress_integer_elias_gamma_simd_vb.h:57
virtual void decode(integer *decoded, size_t integers_to_decode, const void *source, size_t source_length)
Decode a sequence of integers encoded with this codex.
Definition: compress_integer_elias_gamma_simd_vb.cpp:319
virtual size_t encode(void *encoded, size_t encoded_buffer_length, const integer *source, size_t source_integers)
Encode a sequence of integers returning the number of bytes used for the encoding, or 0 if the encoded sequence doesn&#39;t fit in the buffer.
Definition: compress_integer_elias_gamma_simd_vb.cpp:50
Variable byte compression for integer sequences.
Pack 32-bit integers into 512-bit SIMD words using elias gamma with vbyte for short lists...
Definition: compress_integer_elias_gamma_simd_vb.h:31
virtual long long compress(unsigned char *destination, long long destination_length, uint32_t *source, long long source_integers)
Decode a sequence of integers encoded with this codex, calling add_rsv for each SIMD register...
Definition: compress_integer_elias_gamma_simd_vb.h:107