Skip to content

Commit 7577a0f

Browse files
committed
[codegen] Test and document codegen for SplitAt and Split
Makes progress towards #3079. gherrit-pr-id: G09ea59a47925616837b859b2c3cdf7f0f919232e
1 parent 559293f commit 7577a0f

35 files changed

Lines changed: 980 additions & 5 deletions

benches/formats/coco_dynamic_padding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub enum C0C0 {
77
_XC0C0 = 0xC0C0,
88
}
99

10-
#[derive(FromBytes, KnownLayout, Immutable)]
10+
#[derive(FromBytes, KnownLayout, Immutable, SplitAt)]
1111
#[repr(C, align(4))]
1212
pub struct Packet<Magic> {
1313
magic_number: Magic,

benches/formats/coco_dynamic_size.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub enum C0C0 {
99

1010
macro_rules! define_packet {
1111
($name: ident, $trait: ident, $leading_field: ty) => {
12-
#[derive($trait, KnownLayout, Immutable, IntoBytes)]
12+
#[derive($trait, KnownLayout, Immutable, IntoBytes, SplitAt)]
1313
#[repr(C, align(2))]
1414
pub struct $name {
1515
magic_number: $leading_field,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use zerocopy::*;
2+
3+
#[path = "formats/coco_dynamic_padding.rs"]
4+
mod format;
5+
6+
#[unsafe(no_mangle)]
7+
fn bench_split_at_dynamic_padding(
8+
source: &format::CocoPacket,
9+
len: usize,
10+
) -> Option<Split<&format::CocoPacket>> {
11+
source.split_at(len)
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bench_split_at_dynamic_padding:
2+
mov rax, rdi
3+
cmp rcx, rdx
4+
jbe .LBB5_2
5+
xor esi, esi
6+
mov qword ptr [rax], rsi
7+
ret
8+
.LBB5_2:
9+
mov qword ptr [rax + 8], rdx
10+
mov qword ptr [rax + 16], rcx
11+
mov qword ptr [rax], rsi
12+
ret
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Iterations: 100
2+
Instructions: 1000
3+
Total Cycles: 404
4+
Total uOps: 1000
5+
6+
Dispatch Width: 4
7+
uOps Per Cycle: 2.48
8+
IPC: 2.48
9+
Block RThroughput: 4.0
10+
11+
12+
Instruction Info:
13+
[1]: #uOps
14+
[2]: Latency
15+
[3]: RThroughput
16+
[4]: MayLoad
17+
[5]: MayStore
18+
[6]: HasSideEffects (U)
19+
20+
[1] [2] [3] [4] [5] [6] Instructions:
21+
1 1 0.33 mov rax, rdi
22+
1 1 0.33 cmp rcx, rdx
23+
1 1 1.00 jbe .LBB5_2
24+
1 0 0.25 xor esi, esi
25+
1 1 1.00 * mov qword ptr [rax], rsi
26+
1 1 1.00 U ret
27+
1 1 1.00 * mov qword ptr [rax + 8], rdx
28+
1 1 1.00 * mov qword ptr [rax + 16], rcx
29+
1 1 1.00 * mov qword ptr [rax], rsi
30+
1 1 1.00 U ret
31+
32+
33+
Resources:
34+
[0] - SBDivider
35+
[1] - SBFPDivider
36+
[2] - SBPort0
37+
[3] - SBPort1
38+
[4] - SBPort4
39+
[5] - SBPort5
40+
[6.0] - SBPort23
41+
[6.1] - SBPort23
42+
43+
44+
Resource pressure per iteration:
45+
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
46+
- - 0.99 1.00 4.00 3.01 2.00 2.00
47+
48+
Resource pressure by instruction:
49+
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
50+
- - 0.99 - - 0.01 - - mov rax, rdi
51+
- - - 1.00 - - - - cmp rcx, rdx
52+
- - - - - 1.00 - - jbe .LBB5_2
53+
- - - - - - - - xor esi, esi
54+
- - - - 1.00 - - 1.00 mov qword ptr [rax], rsi
55+
- - - - - 1.00 - - ret
56+
- - - - 1.00 - 1.00 - mov qword ptr [rax + 8], rdx
57+
- - - - 1.00 - - 1.00 mov qword ptr [rax + 16], rcx
58+
- - - - 1.00 - 1.00 - mov qword ptr [rax], rsi
59+
- - - - - 1.00 - - ret

benches/split_at_dynamic_size.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use zerocopy::*;
2+
3+
#[path = "formats/coco_dynamic_size.rs"]
4+
mod format;
5+
6+
#[unsafe(no_mangle)]
7+
fn bench_split_at_dynamic_size(
8+
source: &format::CocoPacket,
9+
len: usize,
10+
) -> Option<Split<&format::CocoPacket>> {
11+
source.split_at(len)
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bench_split_at_dynamic_size:
2+
mov rax, rdi
3+
cmp rcx, rdx
4+
jbe .LBB5_2
5+
xor esi, esi
6+
mov qword ptr [rax], rsi
7+
ret
8+
.LBB5_2:
9+
mov qword ptr [rax + 8], rdx
10+
mov qword ptr [rax + 16], rcx
11+
mov qword ptr [rax], rsi
12+
ret
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
Iterations: 100
2+
Instructions: 1000
3+
Total Cycles: 404
4+
Total uOps: 1000
5+
6+
Dispatch Width: 4
7+
uOps Per Cycle: 2.48
8+
IPC: 2.48
9+
Block RThroughput: 4.0
10+
11+
12+
Instruction Info:
13+
[1]: #uOps
14+
[2]: Latency
15+
[3]: RThroughput
16+
[4]: MayLoad
17+
[5]: MayStore
18+
[6]: HasSideEffects (U)
19+
20+
[1] [2] [3] [4] [5] [6] Instructions:
21+
1 1 0.33 mov rax, rdi
22+
1 1 0.33 cmp rcx, rdx
23+
1 1 1.00 jbe .LBB5_2
24+
1 0 0.25 xor esi, esi
25+
1 1 1.00 * mov qword ptr [rax], rsi
26+
1 1 1.00 U ret
27+
1 1 1.00 * mov qword ptr [rax + 8], rdx
28+
1 1 1.00 * mov qword ptr [rax + 16], rcx
29+
1 1 1.00 * mov qword ptr [rax], rsi
30+
1 1 1.00 U ret
31+
32+
33+
Resources:
34+
[0] - SBDivider
35+
[1] - SBFPDivider
36+
[2] - SBPort0
37+
[3] - SBPort1
38+
[4] - SBPort4
39+
[5] - SBPort5
40+
[6.0] - SBPort23
41+
[6.1] - SBPort23
42+
43+
44+
Resource pressure per iteration:
45+
[0] [1] [2] [3] [4] [5] [6.0] [6.1]
46+
- - 0.99 1.00 4.00 3.01 2.00 2.00
47+
48+
Resource pressure by instruction:
49+
[0] [1] [2] [3] [4] [5] [6.0] [6.1] Instructions:
50+
- - 0.99 - - 0.01 - - mov rax, rdi
51+
- - - 1.00 - - - - cmp rcx, rdx
52+
- - - - - 1.00 - - jbe .LBB5_2
53+
- - - - - - - - xor esi, esi
54+
- - - - 1.00 - - 1.00 mov qword ptr [rax], rsi
55+
- - - - - 1.00 - - ret
56+
- - - - 1.00 - 1.00 - mov qword ptr [rax + 8], rdx
57+
- - - - 1.00 - - 1.00 mov qword ptr [rax + 16], rcx
58+
- - - - 1.00 - 1.00 - mov qword ptr [rax], rsi
59+
- - - - - 1.00 - - ret
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
use zerocopy::*;
2+
3+
#[path = "formats/coco_dynamic_padding.rs"]
4+
mod format;
5+
6+
#[unsafe(no_mangle)]
7+
unsafe fn bench_split_at_unchecked_dynamic_padding(
8+
source: &format::CocoPacket,
9+
len: usize,
10+
) -> Split<&format::CocoPacket> {
11+
unsafe { source.split_at_unchecked(len) }
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bench_split_at_unchecked_dynamic_padding:
2+
mov rax, rdi
3+
mov qword ptr [rdi], rsi
4+
mov qword ptr [rdi + 8], rdx
5+
mov qword ptr [rdi + 16], rcx
6+
ret

0 commit comments

Comments
 (0)