Skip to content

Commit 3803b9f

Browse files
committed
split implementation to please MSVC
1 parent 3aa342b commit 3803b9f

18 files changed

Lines changed: 434 additions & 86 deletions
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
set(SOURCES
22
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor.c
3+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_8.c
4+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_16.c
5+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_32.c
6+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_64.c
7+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_128.c
8+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_ffor_256.c
39
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack.c
10+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_8.c
11+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_16.c
12+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_32.c
13+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_64.c
14+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_128.c
15+
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_pack_256.c
416
${CMAKE_CURRENT_SOURCE_DIR}/fastlanes_sizing.c)
517
target_sources(${TSL_LIBRARY_NAME} PRIVATE ${SOURCES})

tsl/src/compression/algorithms/fastlanes/fastlanes.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,30 @@
4040
* | 65..128 | FL128 | FL128 | FL128 | FL128 |
4141
* | 129..256 | FL256 | FL256 | FL256 | FL256 |
4242
*/
43-
fl_tier_width_t fl_tier_select(uint32 n, fl_elem_width_t t);
43+
extern fl_tier_width_t fl_tier_select(uint32 n, fl_elem_width_t t);
4444

4545
/* Required size for the tier (selected by fl_tier_select(N, T)).
4646
* Determines the sizes of pack output and unpack input buffers exactly.
4747
*/
48-
size_t fl_required_bytes(uint32 n, uint8 w, fl_elem_width_t t);
48+
extern size_t fl_required_bytes(uint32 n, uint8 w, fl_elem_width_t t);
4949

5050
/* Bytes the encoded output carries for N elements (<= fl_required_bytes).
5151
* Matches the return of fl_pack / fl_pack_ffor; useful for sizing the
5252
* truncated prefix without running the encoder. */
53-
size_t fl_result_bytes(uint32 n, uint8 w, fl_elem_width_t t);
53+
extern size_t fl_result_bytes(uint32 n, uint8 w, fl_elem_width_t t);
5454

5555
/* Required alignment for the _packed_ input and output buffers.
5656
* Recommended alignment for the input and output _values_.
5757
*/
58-
size_t fl_alignment(uint32 n, fl_elem_width_t t);
58+
extern size_t fl_alignment(uint32 n, fl_elem_width_t t);
5959

6060
/* Number of input ELEMENTS the kernel reads -- callers must provide
6161
* at least this many readable elements at `values` (positions past N
6262
* are read but only the [0..N) outputs are meaningful). */
63-
uint32 fl_input_count(uint32 n, fl_elem_width_t t);
63+
extern uint32 fl_input_count(uint32 n, fl_elem_width_t t);
6464

6565
/* Byte size of the input buffer (= fl_input_count() * t / 8). */
66-
size_t fl_input_bytes(uint32 n, fl_elem_width_t t);
66+
extern size_t fl_input_bytes(uint32 n, fl_elem_width_t t);
6767

6868
/*
6969
* Plain pack / unpack.
@@ -79,8 +79,8 @@ size_t fl_input_bytes(uint32 n, fl_elem_width_t t);
7979
* W = 0 (constant block) is a special case: fl_pack returns 0 and
8080
* writes nothing; fl_unpack fills outputs [0..N) with 0.
8181
*/
82-
size_t fl_pack(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t);
83-
void fl_unpack(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t);
82+
extern size_t fl_pack(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t);
83+
extern void fl_unpack(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t);
8484

8585
/*
8686
* FFOR (Frame Of Reference) variants.
@@ -92,7 +92,7 @@ void fl_unpack(const void *packed, void *values, uint32 n, uint8 w, fl_elem_widt
9292
* W = 0: fl_pack_ffor returns 0 and writes nothing; fl_unpack_ffor
9393
* fills outputs [0..N) with `base`.
9494
*/
95-
size_t fl_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
96-
uint64 base);
97-
void fl_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
98-
uint64 base);
95+
extern size_t fl_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
96+
uint64 base);
97+
extern void fl_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
98+
uint64 base);

tsl/src/compression/algorithms/fastlanes/fastlanes_ffor.c

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
* fastlanes/fastlanes_ffor.c -- public FFOR (Frame Of Reference)
99
* pack/unpack entry points.
1010
*
11-
* Uses fastlanes_tier_sizing.h + fastlanes_tier_ffor_impl.h as
12-
* templates driven by the FL_TIER.
13-
*
1411
* Defines fl_pack_ffor and fl_unpack_ffor as switches
1512
* on fl_tier_select that forward to the matching per-tier static.
1613
*/
@@ -20,40 +17,35 @@
2017
#include "fastlanes.h"
2118
#include "fastlanes_common.h"
2219

23-
/* clang format would reorder the headers which is not desired here */
24-
/* clang-format off */
25-
26-
#define FL_TIER 8
27-
#include "fastlanes_tier_sizing.h"
28-
#include "fastlanes_tier_ffor_impl.h"
29-
#undef FL_TIER
30-
31-
#define FL_TIER 16
32-
#include "fastlanes_tier_sizing.h"
33-
#include "fastlanes_tier_ffor_impl.h"
34-
#undef FL_TIER
35-
36-
#define FL_TIER 32
37-
#include "fastlanes_tier_sizing.h"
38-
#include "fastlanes_tier_ffor_impl.h"
39-
#undef FL_TIER
40-
41-
#define FL_TIER 64
42-
#include "fastlanes_tier_sizing.h"
43-
#include "fastlanes_tier_ffor_impl.h"
44-
#undef FL_TIER
45-
46-
#define FL_TIER 128
47-
#include "fastlanes_tier_sizing.h"
48-
#include "fastlanes_tier_ffor_impl.h"
49-
#undef FL_TIER
50-
51-
#define FL_TIER 256
52-
#include "fastlanes_tier_sizing.h"
53-
#include "fastlanes_tier_ffor_impl.h"
54-
#undef FL_TIER
55-
56-
/* clang-format on */
20+
/*
21+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
22+
* macro expansion happens in the same C file. These functions are intentionally
23+
* not placed in a header file, to discourage direct use.
24+
*/
25+
extern size_t fl8_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
26+
uint64 base);
27+
extern size_t fl16_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
28+
uint64 base);
29+
extern size_t fl32_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
30+
uint64 base);
31+
extern size_t fl64_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
32+
uint64 base);
33+
extern size_t fl128_pack_ffor(const void *values, void *packed, uint32 n, uint8 w,
34+
fl_elem_width_t t, uint64 base);
35+
extern size_t fl256_pack_ffor(const void *values, void *packed, uint32 n, uint8 w,
36+
fl_elem_width_t t, uint64 base);
37+
extern void fl8_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
38+
uint64 base);
39+
extern void fl16_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
40+
uint64 base);
41+
extern void fl32_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
42+
uint64 base);
43+
extern void fl64_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
44+
uint64 base);
45+
extern void fl128_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w,
46+
fl_elem_width_t t, uint64 base);
47+
extern void fl256_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w,
48+
fl_elem_width_t t, uint64 base);
5749

5850
/* Public FFOR pack/unpack
5951
*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl128_pack_ffor(const void *values, void *packed, uint32 n, uint8 w,
19+
fl_elem_width_t t, uint64 base);
20+
extern void fl128_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w,
21+
fl_elem_width_t t, uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 128
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl16_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
19+
uint64 base);
20+
extern void fl16_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
21+
uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 16
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl256_pack_ffor(const void *values, void *packed, uint32 n, uint8 w,
19+
fl_elem_width_t t, uint64 base);
20+
extern void fl256_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w,
21+
fl_elem_width_t t, uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 256
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl32_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
19+
uint64 base);
20+
extern void fl32_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
21+
uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 32
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl64_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
19+
uint64 base);
20+
extern void fl64_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
21+
uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 64
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file and its contents are licensed under the Timescale License.
3+
* Please see the included NOTICE for copyright information and
4+
* LICENSE-TIMESCALE for a copy of the license.
5+
*/
6+
7+
#include <postgres.h>
8+
9+
#include "fastlanes.h"
10+
#include "fastlanes_common.h"
11+
12+
/*
13+
* These extern declarations are needed because MSVC runs out of the heap space if all FFOR
14+
* macro expansion happens in the same C file. The functions are being called from
15+
* `fastlanes_ffor.c`, which dispatches between the tiers. These functions are intentionally
16+
* not placed in a header file, to discourage direct use.
17+
*/
18+
extern size_t fl8_pack_ffor(const void *values, void *packed, uint32 n, uint8 w, fl_elem_width_t t,
19+
uint64 base);
20+
extern void fl8_unpack_ffor(const void *packed, void *values, uint32 n, uint8 w, fl_elem_width_t t,
21+
uint64 base);
22+
23+
/* clang format would reorder the headers which is not desired here */
24+
/* clang-format off */
25+
26+
#define FL_TIER 8
27+
#include "fastlanes_tier_sizing.h"
28+
#include "fastlanes_tier_ffor_impl.h"
29+
#undef FL_TIER
30+
31+
/* clang-format on */

0 commit comments

Comments
 (0)