Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
36e198b9
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36e198b9
编写于
9月 13, 2021
作者:
C
Caleb Zulawski
提交者:
Jubilee Young
11月 13, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use new bitmask intrinsics with byte arrays
上级
1ce1c645
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
39 deletion
+9
-39
crates/core_simd/src/lane_count.rs
crates/core_simd/src/lane_count.rs
+0
-9
crates/core_simd/src/masks/bitmask.rs
crates/core_simd/src/masks/bitmask.rs
+7
-13
crates/core_simd/src/masks/full_masks.rs
crates/core_simd/src/masks/full_masks.rs
+2
-17
未找到文件。
crates/core_simd/src/lane_count.rs
浏览文件 @
36e198b9
...
@@ -15,34 +15,25 @@ impl<const LANES: usize> LaneCount<LANES> {
...
@@ -15,34 +15,25 @@ impl<const LANES: usize> LaneCount<LANES> {
pub
trait
SupportedLaneCount
:
Sealed
{
pub
trait
SupportedLaneCount
:
Sealed
{
#[doc(hidden)]
#[doc(hidden)]
type
BitMask
:
Copy
+
Default
+
AsRef
<
[
u8
]
>
+
AsMut
<
[
u8
]
>
;
type
BitMask
:
Copy
+
Default
+
AsRef
<
[
u8
]
>
+
AsMut
<
[
u8
]
>
;
#[doc(hidden)]
type
IntBitMask
;
}
}
impl
<
const
LANES
:
usize
>
Sealed
for
LaneCount
<
LANES
>
{}
impl
<
const
LANES
:
usize
>
Sealed
for
LaneCount
<
LANES
>
{}
impl
SupportedLaneCount
for
LaneCount
<
1
>
{
impl
SupportedLaneCount
for
LaneCount
<
1
>
{
type
BitMask
=
[
u8
;
1
];
type
BitMask
=
[
u8
;
1
];
type
IntBitMask
=
u8
;
}
}
impl
SupportedLaneCount
for
LaneCount
<
2
>
{
impl
SupportedLaneCount
for
LaneCount
<
2
>
{
type
BitMask
=
[
u8
;
1
];
type
BitMask
=
[
u8
;
1
];
type
IntBitMask
=
u8
;
}
}
impl
SupportedLaneCount
for
LaneCount
<
4
>
{
impl
SupportedLaneCount
for
LaneCount
<
4
>
{
type
BitMask
=
[
u8
;
1
];
type
BitMask
=
[
u8
;
1
];
type
IntBitMask
=
u8
;
}
}
impl
SupportedLaneCount
for
LaneCount
<
8
>
{
impl
SupportedLaneCount
for
LaneCount
<
8
>
{
type
BitMask
=
[
u8
;
1
];
type
BitMask
=
[
u8
;
1
];
type
IntBitMask
=
u8
;
}
}
impl
SupportedLaneCount
for
LaneCount
<
16
>
{
impl
SupportedLaneCount
for
LaneCount
<
16
>
{
type
BitMask
=
[
u8
;
2
];
type
BitMask
=
[
u8
;
2
];
type
IntBitMask
=
u16
;
}
}
impl
SupportedLaneCount
for
LaneCount
<
32
>
{
impl
SupportedLaneCount
for
LaneCount
<
32
>
{
type
BitMask
=
[
u8
;
4
];
type
BitMask
=
[
u8
;
4
];
type
IntBitMask
=
u32
;
}
}
crates/core_simd/src/masks/bitmask.rs
浏览文件 @
36e198b9
#![allow(unused_imports)]
use
super
::
MaskElement
;
use
super
::
MaskElement
;
use
crate
::
simd
::
intrinsics
;
use
crate
::
simd
::
intrinsics
;
use
crate
::
simd
::{
LaneCount
,
Simd
,
SupportedLaneCount
};
use
crate
::
simd
::{
LaneCount
,
Simd
,
SupportedLaneCount
};
...
@@ -101,24 +102,17 @@ pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) {
...
@@ -101,24 +102,17 @@ pub unsafe fn set_unchecked(&mut self, lane: usize, value: bool) {
#[inline]
#[inline]
pub
fn
to_int
(
self
)
->
Simd
<
T
,
LANES
>
{
pub
fn
to_int
(
self
)
->
Simd
<
T
,
LANES
>
{
unsafe
{
unsafe
{
let
mask
:
<
LaneCount
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
=
crate
::
intrinsics
::
simd_select_bitmask
(
core
::
mem
::
transmute_copy
(
&
self
);
self
.0
,
intrinsics
::
simd_select_bitmask
(
mask
,
Simd
::
splat
(
T
::
TRUE
),
Simd
::
splat
(
T
::
FALSE
))
Simd
::
splat
(
T
::
TRUE
),
Simd
::
splat
(
T
::
FALSE
),
)
}
}
}
}
#[inline]
#[inline]
pub
unsafe
fn
from_int_unchecked
(
value
:
Simd
<
T
,
LANES
>
)
->
Self
{
pub
unsafe
fn
from_int_unchecked
(
value
:
Simd
<
T
,
LANES
>
)
->
Self
{
// TODO remove the transmute when rustc is more flexible
unsafe
{
Self
(
crate
::
intrinsics
::
simd_bitmask
(
value
),
PhantomData
)
}
assert_eq!
(
core
::
mem
::
size_of
::
<<
LaneCount
::
<
LANES
>
as
SupportedLaneCount
>
::
BitMask
>
(),
core
::
mem
::
size_of
::
<<
LaneCount
::
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
>
(),
);
unsafe
{
let
mask
:
<
LaneCount
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
=
intrinsics
::
simd_bitmask
(
value
);
Self
(
core
::
mem
::
transmute_copy
(
&
mask
),
PhantomData
)
}
}
}
#[cfg(feature
=
"generic_const_exprs"
)]
#[cfg(feature
=
"generic_const_exprs"
)]
...
...
crates/core_simd/src/masks/full_masks.rs
浏览文件 @
36e198b9
...
@@ -106,15 +106,8 @@ pub fn convert<U>(self) -> Mask<U, LANES>
...
@@ -106,15 +106,8 @@ pub fn convert<U>(self) -> Mask<U, LANES>
#[inline]
#[inline]
pub
fn
to_bitmask
(
self
)
->
[
u8
;
LaneCount
::
<
LANES
>
::
BITMASK_LEN
]
{
pub
fn
to_bitmask
(
self
)
->
[
u8
;
LaneCount
::
<
LANES
>
::
BITMASK_LEN
]
{
unsafe
{
unsafe
{
// TODO remove the transmute when rustc can use arrays of u8 as bitmasks
assert_eq!
(
core
::
mem
::
size_of
::
<<
LaneCount
::
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
>
(),
LaneCount
::
<
LANES
>
::
BITMASK_LEN
,
);
let
bitmask
:
<
LaneCount
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
=
intrinsics
::
simd_bitmask
(
self
.0
);
let
mut
bitmask
:
[
u8
;
LaneCount
::
<
LANES
>
::
BITMASK_LEN
]
=
let
mut
bitmask
:
[
u8
;
LaneCount
::
<
LANES
>
::
BITMASK_LEN
]
=
c
ore
::
mem
::
transmute_copy
(
&
bitmask
);
c
rate
::
intrinsics
::
simd_bitmask
(
self
.0
);
// There is a bug where LLVM appears to implement this operation with the wrong
// There is a bug where LLVM appears to implement this operation with the wrong
// bit order.
// bit order.
...
@@ -142,15 +135,7 @@ pub fn convert<U>(self) -> Mask<U, LANES>
...
@@ -142,15 +135,7 @@ pub fn convert<U>(self) -> Mask<U, LANES>
}
}
}
}
// TODO remove the transmute when rustc can use arrays of u8 as bitmasks
Self
::
from_int_unchecked
(
crate
::
intrinsics
::
simd_select_bitmask
(
assert_eq!
(
core
::
mem
::
size_of
::
<<
LaneCount
::
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
>
(),
LaneCount
::
<
LANES
>
::
BITMASK_LEN
,
);
let
bitmask
:
<
LaneCount
<
LANES
>
as
SupportedLaneCount
>
::
IntBitMask
=
core
::
mem
::
transmute_copy
(
&
bitmask
);
Self
::
from_int_unchecked
(
intrinsics
::
simd_select_bitmask
(
bitmask
,
bitmask
,
Self
::
splat
(
true
)
.to_int
(),
Self
::
splat
(
true
)
.to_int
(),
Self
::
splat
(
false
)
.to_int
(),
Self
::
splat
(
false
)
.to_int
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录