Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
soremi
oceanbase
提交
be0b714b
O
oceanbase
项目概览
soremi
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
be0b714b
编写于
11月 02, 2022
作者:
羽飞
提交者:
wangzelin.wzl
11月 02, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix isal crc64 bug
上级
0a044c27
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
49 addition
and
12 deletion
+49
-12
deps/oblib/src/lib/checksum/ob_crc64.cpp
deps/oblib/src/lib/checksum/ob_crc64.cpp
+32
-8
deps/oblib/src/lib/checksum/ob_crc64.h
deps/oblib/src/lib/checksum/ob_crc64.h
+2
-0
deps/oblib/unittest/lib/checksum/test_crc64.cpp
deps/oblib/unittest/lib/checksum/test_crc64.cpp
+15
-4
未找到文件。
deps/oblib/src/lib/checksum/ob_crc64.cpp
浏览文件 @
be0b714b
...
...
@@ -13,6 +13,8 @@
#include <stdlib.h>
#include "lib/checksum/ob_crc64.h"
#include "lib/ob_define.h"
#include "isa-l/crc64.h"
#include "isa-l/crc.h"
namespace
oceanbase
{
...
...
@@ -420,7 +422,7 @@ for RHEL4 support (GCC 3 doesn't support this instruction) */
#define crc32_sse42_byte crc = __crc32cb(crc, (uint8_t)*buf); len--, buf++
#endif
/* defined(__GNUC__) && defined(__x86_64__) */
inline
static
uint64_t
crc64_sse42
(
uint64_t
uCRC64
,
uint64_t
crc64_sse42
(
uint64_t
uCRC64
,
const
char
*
buf
,
int64_t
len
)
{
uint64_t
crc
=
uCRC64
;
...
...
@@ -1102,6 +1104,14 @@ uint64_t fast_crc64_sse42_manually(uint64_t crc, const char *buf, int64_t len)
return
crc
;
}
//If the CPU is intel, ISA-L library for CRC can be used
uint64_t
ob_crc64_isal
(
uint64_t
uCRC64
,
const
char
*
buf
,
int64_t
cb
)
{
if
(
buf
==
NULL
||
cb
<=
0
){
return
uCRC64
;
}
return
crc32_iscsi
((
unsigned
char
*
)(
buf
),
cb
,
uCRC64
);
}
uint64_t
crc64_sse42_dispatch
(
uint64_t
crc
,
const
char
*
buf
,
int64_t
len
)
{
...
...
@@ -1110,13 +1120,27 @@ uint64_t crc64_sse42_dispatch(uint64_t crc, const char *buf, int64_t len)
uint32_t
b
=
0
;
uint32_t
c
=
0
;
uint32_t
d
=
0
;
asm
(
"cpuid"
:
"=a"
(
a
),
"=b"
(
b
),
"=c"
(
c
),
"=d"
(
d
)
:
"0"
(
1
));
if
((
c
&
(
1
<<
20
))
!=
0
)
{
ob_crc64_sse42_func
=
&
crc64_sse42
;
_OB_LOG
(
INFO
,
"Use CPU crc32 instructs for crc64 calculate"
);
}
else
{
ob_crc64_sse42_func
=
&
fast_crc64_sse42_manually
;
_OB_LOG
(
INFO
,
"Use manual crc32 table lookup for crc64 calculate"
);
uint32_t
vendor_info
[
4
];
__asm__
(
"mov $0x0, %eax
\n\t
"
);
__asm__
(
"cpuid
\n\t
"
);
__asm__
(
"mov %%ebx, %0
\n\t
"
:
"=r"
(
vendor_info
[
0
]));
__asm__
(
"mov %%edx, %0
\n\t
"
:
"=r"
(
vendor_info
[
1
]));
__asm__
(
"mov %%ecx, %0
\n\t
"
:
"=r"
(
vendor_info
[
2
]));
vendor_info
[
3
]
=
'\0'
;
if
(
strcmp
((
char
*
)
vendor_info
,
"GenuineIntel"
)
==
0
)
{
ob_crc64_sse42_func
=
&
ob_crc64_isal
;
_OB_LOG
(
WARN
,
"Use ISAL for crc64 calculate"
);
}
else
{
asm
(
"cpuid"
:
"=a"
(
a
),
"=b"
(
b
),
"=c"
(
c
),
"=d"
(
d
)
:
"0"
(
1
));
if
((
c
&
(
1
<<
20
))
!=
0
)
{
ob_crc64_sse42_func
=
&
crc64_sse42
;
_OB_LOG
(
WARN
,
"Use CPU crc32 instructs for crc64 calculate"
);
}
else
{
ob_crc64_sse42_func
=
&
fast_crc64_sse42_manually
;
_OB_LOG
(
WARN
,
"Use manual crc32 table lookup for crc64 calculate"
);
}
}
#elif defined(__aarch64__)
#if 1
...
...
deps/oblib/src/lib/checksum/ob_crc64.h
浏览文件 @
be0b714b
...
...
@@ -68,6 +68,8 @@ inline uint64_t ob_crc64_sse42(const void *pv, int64_t cb)
return
(
*
ob_crc64_sse42_func
)(
0
,
static_cast
<
const
char
*>
(
pv
),
cb
);
}
uint64_t
ob_crc64_isal
(
uint64_t
uCRC64
,
const
char
*
buf
,
int64_t
cb
);
uint64_t
crc64_sse42
(
uint64_t
uCRC64
,
const
char
*
buf
,
int64_t
len
);
uint64_t
crc64_sse42_manually
(
uint64_t
crc
,
const
char
*
buf
,
int64_t
len
);
uint64_t
fast_crc64_sse42_manually
(
uint64_t
crc
,
const
char
*
buf
,
int64_t
len
);
...
...
deps/oblib/unittest/lib/checksum/test_crc64.cpp
浏览文件 @
be0b714b
...
...
@@ -41,13 +41,16 @@ TEST(TestCrc64, common)
const
int64_t
STR_LEN
=
10240
;
char
*
tmp_str
=
new
char
[
STR_LEN
];
char
*
str
=
NULL
;
uint64_t
intermediate_hash
=
0
;
for
(
int64_t
i
=
1
;
i
<
(
STR_LEN
-
1
);
++
i
)
{
str
=
rand_str
(
tmp_str
,
i
);
uint64_t
manually_hash
=
crc64_sse42_manually
(
0
,
str
,
i
);
uint64_t
fast_manually_hash
=
fast_crc64_sse42_manually
(
0
,
str
,
i
);
uint64_t
sse42_hash
=
ob_crc64
(
0
,
str
,
i
);
uint64_t
manually_hash
=
crc64_sse42_manually
(
intermediate_hash
,
str
,
i
);
uint64_t
fast_manually_hash
=
fast_crc64_sse42_manually
(
intermediate_hash
,
str
,
i
);
uint64_t
sse42_hash
=
crc64_sse42
(
intermediate_hash
,
str
,
i
);
uint64_t
isal_hash
=
ob_crc64_isal
(
intermediate_hash
,
str
,
i
);
ASSERT_EQ
(
manually_hash
,
fast_manually_hash
);
ASSERT_EQ
(
manually_hash
,
sse42_hash
);
ASSERT_EQ
(
manually_hash
,
isal_hash
);
//cout << "st = "<< tmp_str << endl;
//cout << "crc64c = "<< manually_hash << endl;
}
...
...
@@ -77,11 +80,19 @@ TEST(TestCrc64, test_speed)
start
=
get_current_time_us
();
for
(
int64_t
j
=
0
;
j
<
COUNT
;
++
j
)
{
ob_crc64
(
0
,
tmp_str
,
i
);
crc64_sse42
(
0
,
tmp_str
,
i
);
}
end
=
get_current_time_us
();
cout
<<
" ob_crc64(sse42), execut_count = "
<<
COUNT
<<
", cost_us = "
<<
end
-
start
<<
" len = "
<<
i
<<
endl
;
start
=
get_current_time_us
();
for
(
int64_t
j
=
0
;
j
<
COUNT
;
++
j
)
{
ob_crc64_isal
(
0
,
tmp_str
,
i
);
}
end
=
get_current_time_us
();
cout
<<
" ob_crc64(ob_crc64_isal), execut_count = "
<<
COUNT
<<
", cost_us = "
<<
end
-
start
<<
" len = "
<<
i
<<
endl
;
cout
<<
endl
;
cout
<<
endl
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录