Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
642651c1
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
642651c1
编写于
1月 09, 2023
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
c7560202
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
81 addition
and
82 deletion
+81
-82
source/util/src/tcompression.c
source/util/src/tcompression.c
+81
-82
未找到文件。
source/util/src/tcompression.c
浏览文件 @
642651c1
...
...
@@ -283,96 +283,95 @@ int32_t tsDecompressINTImp(const char *const input, const int32_t nelements, cha
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
p
=
(
int64_t
*
)
output
;
int32_t
gRemainder
=
(
nelements
-
_pos
);
int32_t
num
=
(
gRemainder
>
elems
)
?
elems
:
gRemainder
;
int32_t
batch
=
num
>>
2
;
int32_t
remain
=
num
&
0x03
;
if
(
selector
==
0
||
selector
==
1
)
{
int32_t
gRemainder
=
nelements
-
_pos
;
int32_t
num
=
gRemainder
<
elems
?
gRemainder
:
elems
;
int32_t
batch
=
num
>>
2
;
int32_t
remainder
=
num
&
0x03
;
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
p
[
_pos
++
]
=
prev_value
;
p
[
_pos
++
]
=
prev_value
;
p
[
_pos
++
]
=
prev_value
;
p
[
_pos
++
]
=
prev_value
;
}
if
(
tsAVX2Enable
&&
tsSIMDBuiltins
)
{
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
__m256i
prev
=
_mm256_set1_epi64x
(
prev_value
);
_mm256_storeu_si256
((
__m256i
*
)
&
p
[
_pos
],
prev
);
_pos
+=
4
;
}
for
(
int32_t
i
=
0
;
i
<
remainder
;
++
i
)
{
p
[
_pos
++
]
=
prev_value
;
for
(
int32_t
i
=
0
;
i
<
remain
;
++
i
)
{
p
[
_pos
++
]
=
prev_value
;
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
elems
&&
count
<
nelements
;
i
++
,
count
++
)
{
p
[
_pos
++
]
=
prev_value
;
v
+=
bit
;
}
}
count
+=
num
;
}
else
{
int32_t
gRemainder
=
(
nelements
-
_pos
);
int32_t
num
=
(
gRemainder
>
elems
)
?
elems
:
gRemainder
;
int32_t
batch
=
num
>>
2
;
int32_t
remain
=
num
&
0x03
;
#if 1
__m256i
base
=
_mm256_set1_epi64x
(
w
);
__m256i
maskVal
=
_mm256_set1_epi64x
(
mask
);
__m256i
shiftBits
=
_mm256_set_epi64x
(
bit
*
3
+
4
,
bit
*
2
+
4
,
bit
+
4
,
4
);
__m256i
inc
=
_mm256_set1_epi64x
(
bit
<<
2
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
__m256i
after
=
_mm256_srlv_epi64
(
base
,
shiftBits
);
__m256i
zigzagVal
=
_mm256_and_si256
(
after
,
maskVal
);
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
__m256i
signmask
=
_mm256_and_si256
(
_mm256_set1_epi64x
(
1
),
zigzagVal
);
signmask
=
_mm256_sub_epi64
(
_mm256_setzero_si256
(),
signmask
);
// get the four zigzag values here
__m256i
delta
=
_mm256_xor_si256
(
_mm256_srli_epi64
(
zigzagVal
,
1
),
signmask
);
// calculate the cumulative sum (prefix sum) for each number
// decode[0] = prev_value + final[0]
// decode[1] = decode[0] + final[1] -----> prev_value + final[0] + final[1]
// decode[2] = decode[1] + final[1] -----> prev_value + final[0] + final[1] + final[2]
// decode[3] = decode[2] + final[1] -----> prev_value + final[0] + final[1] + final[2] + final[3]
// 1, 2, 3, 4
//+ 0, 1, 2, 3
// 1, 3, 5, 7
// shift and add for the first round
__m128i
prev
=
_mm_set1_epi64x
(
prev_value
);
delta
=
_mm256_add_epi64
(
delta
,
_mm256_slli_si256
(
delta
,
8
));
_mm256_storeu_si256
((
__m256i
*
)
&
p
[
_pos
],
delta
);
// 1, 3, 5, 7
//+ 0, 0, 1, 3
// 1, 3, 6, 10
// shift and add operation for the second round
__m128i
firstPart
=
_mm_loadu_si128
((
__m128i
*
)
&
p
[
_pos
]);
__m128i
secPart
=
_mm_add_epi64
(
_mm_loadu_si128
((
__m128i
*
)
&
p
[
_pos
+
2
]),
firstPart
);
firstPart
=
_mm_add_epi64
(
firstPart
,
prev
);
secPart
=
_mm_add_epi64
(
secPart
,
prev
);
// save it in the memory
_mm_storeu_si128
((
__m128i
*
)
&
p
[
_pos
],
firstPart
);
_mm_storeu_si128
((
__m128i
*
)
&
p
[
_pos
+
2
],
secPart
);
shiftBits
=
_mm256_add_epi64
(
shiftBits
,
inc
);
prev_value
=
p
[
_pos
+
3
];
_pos
+=
4
;
}
if
(
tsAVX2Enable
&&
tsSIMDBuiltins
)
{
__m256i
base
=
_mm256_set1_epi64x
(
w
);
__m256i
maskVal
=
_mm256_set1_epi64x
(
mask
);
__m256i
shiftBits
=
_mm256_set_epi64x
(
bit
*
3
+
4
,
bit
*
2
+
4
,
bit
+
4
,
4
);
__m256i
inc
=
_mm256_set1_epi64x
(
bit
<<
2
);
for
(
int32_t
i
=
0
;
i
<
batch
;
++
i
)
{
__m256i
after
=
_mm256_srlv_epi64
(
base
,
shiftBits
);
__m256i
zigzagVal
=
_mm256_and_si256
(
after
,
maskVal
);
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
__m256i
signmask
=
_mm256_and_si256
(
_mm256_set1_epi64x
(
1
),
zigzagVal
);
signmask
=
_mm256_sub_epi64
(
_mm256_setzero_si256
(),
signmask
);
// get the four zigzag values here
__m256i
delta
=
_mm256_xor_si256
(
_mm256_srli_epi64
(
zigzagVal
,
1
),
signmask
);
// calculate the cumulative sum (prefix sum) for each number
// decode[0] = prev_value + final[0]
// decode[1] = decode[0] + final[1] -----> prev_value + final[0] + final[1]
// decode[2] = decode[1] + final[1] -----> prev_value + final[0] + final[1] + final[2]
// decode[3] = decode[2] + final[1] -----> prev_value + final[0] + final[1] + final[2] + final[3]
// 1, 2, 3, 4
//+ 0, 1, 2, 3
// 1, 3, 5, 7
// shift and add for the first round
__m128i
prev
=
_mm_set1_epi64x
(
prev_value
);
delta
=
_mm256_add_epi64
(
delta
,
_mm256_slli_si256
(
delta
,
8
));
_mm256_storeu_si256
((
__m256i
*
)
&
p
[
_pos
],
delta
);
// 1, 3, 5, 7
//+ 0, 0, 1, 3
// 1, 3, 6, 10
// shift and add operation for the second round
__m128i
firstPart
=
_mm_loadu_si128
((
__m128i
*
)
&
p
[
_pos
]);
__m128i
secPart
=
_mm_add_epi64
(
_mm_loadu_si128
((
__m128i
*
)
&
p
[
_pos
+
2
]),
firstPart
);
firstPart
=
_mm_add_epi64
(
firstPart
,
prev
);
secPart
=
_mm_add_epi64
(
secPart
,
prev
);
// save it in the memory
_mm_storeu_si128
((
__m128i
*
)
&
p
[
_pos
],
firstPart
);
_mm_storeu_si128
((
__m128i
*
)
&
p
[
_pos
+
2
],
secPart
);
shiftBits
=
_mm256_add_epi64
(
shiftBits
,
inc
);
prev_value
=
p
[
_pos
+
3
];
_pos
+=
4
;
}
// handle the remain value
for
(
int32_t
i
=
0
;
i
<
remain
;
i
++
)
{
zigzag_value
=
((
w
>>
(
v
+
(
batch
*
bit
)))
&
mask
);
prev_value
+=
ZIGZAG_DECODE
(
int64_t
,
zigzag_value
);
// handle the remain value
for
(
int32_t
i
=
0
;
i
<
remain
;
i
++
)
{
zigzag_value
=
((
w
>>
(
v
+
(
batch
*
bit
)))
&
mask
);
prev_value
+=
ZIGZAG_DECODE
(
int64_t
,
zigzag_value
);
p
[
_pos
++
]
=
prev_value
;
v
+=
bit
;
}
#else
for
(
int32_t
i
=
0
;
i
<
elems
&&
count
<
nelements
;
i
++
,
count
++
)
{
zigzag_value
=
((
w
>>
v
)
&
mask
);
prev_value
+=
ZIGZAG_DECODE
(
int64_t
,
zigzag_value
);
p
[
_pos
++
]
=
prev_value
;
v
+=
bit
;
}
}
else
{
for
(
int32_t
i
=
0
;
i
<
elems
&&
count
<
nelements
;
i
++
,
count
++
)
{
zigzag_value
=
((
w
>>
v
)
&
mask
);
prev_value
+=
ZIGZAG_DECODE
(
int64_t
,
zigzag_value
);
p
[
_pos
++
]
=
prev_value
;
v
+=
bit
;
p
[
_pos
++
]
=
prev_value
;
v
+=
bit
;
}
}
#endif
}
}
break
;
case
TSDB_DATA_TYPE_INT
:
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录