Skip to content

Commit

Permalink
cleanup boundary crossing test
Browse files Browse the repository at this point in the history
  • Loading branch information
travisdowns committed Jan 22, 2018
1 parent dc4817a commit 373a782
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 34 deletions.
12 changes: 5 additions & 7 deletions misc-benches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ extern "C" {
bench2_f misc_add_loop32;
bench2_f misc_add_loop64;
bench2_f misc_port7;
bench2_f misc_dsb_align_16;
bench2_f misc_dsb_align_32;
bench2_f dsb_align_body_16;
bench2_f dsb_align_body_32;
bench2_f dsb_alignment_cross64;
bench2_f dsb_alignment_nocross64;
bench2_f bmi_tzcnt;
bench2_f bmi_lzcnt;
bench2_f bmi_popcnt;
Expand All @@ -36,7 +34,7 @@ void register_misc(GroupList& list) {

using default_maker = BenchmarkMaker<TIMER>;

const uint32_t iters = 10*1000*1000;
const uint32_t iters = 10*1000;
auto benches = std::vector<Benchmark> {
default_maker::template make_bench<misc_add_loop32>(misc_group.get(), "add-32", "32-bit add-loop", 1,
[]{ return nullptr; }, iters),
Expand All @@ -46,9 +44,9 @@ void register_misc(GroupList& list) {
[]{ return nullptr; }, iters),

// https://dendibakh.github.io/blog/2018/01/18/Code_alignment_issues
default_maker::template make_bench<dsb_align_body_16>(misc_group.get(), "dsb-align16", "Weird alignment effect 16", 1,
default_maker::template make_bench<dsb_alignment_cross64>(misc_group.get(), "dsb-align64-cross", "Crosses 64-byte i-boundary", 1,
[]{ return aligned_ptr(1024, 1024); }, 1024),
default_maker::template make_bench<dsb_align_body_32>(misc_group.get(), "dsb-align32", "Weird alignment effect 32", 1,
default_maker::template make_bench<dsb_alignment_nocross64>(misc_group.get(), "dsb-align64-nocross", "No cross 64-byte i-boundary", 1,
[]{ return aligned_ptr(1024, 1024); }, 1024),
};

Expand Down
38 changes: 11 additions & 27 deletions x86_methods.asm
Original file line number Diff line number Diff line change
Expand Up @@ -512,45 +512,29 @@ nop7
%assign i i+1
%endrep

%define ITERS 128

%macro dsb_body 0
times 2 nop8
.outer:
mov rax, -(ITERS * 32)
mov rdx, rax
nop
nop
nop
nop
nop
nop
nop
nop
nop6
mov rax, 128
.top:
nop9
add rdx, 32
jne .top
dec rax
jne .top
dec rdi
jnz .outer
ret
ud2
%endmacro

GLOBAL dsb_align_body_16,dsb_align_body_32
GLOBAL dsb_alignment_cross64,dsb_alignment_nocross64

ALIGN 32
nop8
nop8
nop8
nop8
; the loop ends up 16-byte aligned, not 32 because the code before the loop is 16 bytes
dsb_align_body_16:
ALIGN 64
times 4 nop8
; the loop ends up crossing a 64-byte boundary
dsb_alignment_cross64:
dsb_body

times 0 * 32 int3

ALIGN 32
dsb_align_body_32:
ALIGN 64
dsb_alignment_nocross64:
dsb_body

0 comments on commit 373a782

Please sign in to comment.