Skip to content

Commit

Permalink
* refactor timeval macos test for better precision; use the correct t…
Browse files Browse the repository at this point in the history
…imeval::tv_usec size

* allow de-nicing macos bounce tests and kitty term if present
* tweak sleep times in bounce macos tests
  • Loading branch information
blu committed Oct 23, 2021
1 parent c4db37b commit 5368641
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 56 deletions.
2 changes: 1 addition & 1 deletion test_macos/test_bounce.s
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ fb_cursor_len = . - fb_cursor_cmd

.align 3
timeval:
.dword 0, 13000
.dword 0, 12300

.section .bss
.align 6
Expand Down
33 changes: 32 additions & 1 deletion test_macos/test_bounce.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,40 @@ BUILD=..

make -C ${BUILD} all

# De-nice ourselves and our kitty term emu for smooth fps; some root required

DENICE=
PID_KITTY=

if [[ $# == 1 ]] && [[ $1 == "denice" ]] ; then

DENICE="sudo nice -n -20"

# Check if terminal is kitty -- normally our terminal should be our grandpatent

PID_KITTY=`ps -p $PPID -o ppid=''`
COMM_KITTY=`ps -p $PID_KITTY -o command='' -c`

if [[ ${COMM_KITTY} != "kitty" ]] ; then
PID_KITTY=
fi
fi

# Boost kitty to top warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n -20 -p ${PID_KITTY}
fi

# Hide term cursor before loading REL; restore term cursor
# upon termination

tput civis
${BUILD}/elvenrel test_bounce.o
${DENICE} ${BUILD}/elvenrel test_bounce.o
tput cnorm

# De-boost kitty to normal warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n 20 -p ${PID_KITTY}
fi
2 changes: 1 addition & 1 deletion test_macos/test_bounce_neon.s
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fb_cursor_len = . - fb_cursor_cmd

.align 3
timeval:
.dword 0, 13000
.dword 0, 12300

.section .bss
.align 6
Expand Down
42 changes: 42 additions & 0 deletions test_macos/test_bounce_neon.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/bin/bash
BUILD=..

make -C ${BUILD} all

# De-nice ourselves and our kitty term emu for smooth fps; some root required

DENICE=
PID_KITTY=

if [[ $# == 1 ]] && [[ $1 == "denice" ]] ; then

DENICE="sudo nice -n -20"

# Check if terminal is kitty -- normally our terminal should be our grandpatent

PID_KITTY=`ps -p $PPID -o ppid=''`
COMM_KITTY=`ps -p $PID_KITTY -o command='' -c`

if [[ ${COMM_KITTY} != "kitty" ]] ; then
PID_KITTY=
fi
fi

# Boost kitty to top warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n -20 -p ${PID_KITTY}
fi

# Hide term cursor before loading REL; restore term cursor
# upon termination

tput civis
${DENICE} ${BUILD}/elvenrel test_bounce_neon.o
tput cnorm

# De-boost kitty to normal warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n 20 -p ${PID_KITTY}
fi
2 changes: 1 addition & 1 deletion test_macos/test_bounce_neon_aosoa.s
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fb_cursor_len = . - fb_cursor_cmd

.align 3
timeval:
.dword 0, 13000
.dword 0, 12300

.section .bss
.align 6
Expand Down
41 changes: 36 additions & 5 deletions test_macos/test_bounce_neon_aosoa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,44 @@ COMMON=../test_common

make -C ${BUILD} all

# De-nice ourselves and our kitty term emu for smooth fps; some root required

DENICE=
PID_KITTY=

if [[ $# == 1 ]] && [[ $1 == "denice" ]] ; then

DENICE="sudo nice -n -20"

# Check if terminal is kitty -- normally our terminal should be our grandpatent

PID_KITTY=`ps -p $PPID -o ppid=''`
COMM_KITTY=`ps -p $PID_KITTY -o command='' -c`

if [[ ${COMM_KITTY} != "kitty" ]] ; then
PID_KITTY=
fi
fi

# Boost kitty to top warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n -20 -p ${PID_KITTY}
fi

# Hide term cursor before loading RELs; suppress reports to
# stdout; restore term cursor upon termination

tput civis
${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_0.o test_bounce_neon_aosoa.o --quiet
${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_1.o test_bounce_neon_aosoa.o --quiet
${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_2.o test_bounce_neon_aosoa.o --quiet
${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_3.o test_bounce_neon_aosoa.o --quiet
${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_2.o test_bounce_neon_aosoa_bg.o --quiet
${DENICE} ${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_0.o test_bounce_neon_aosoa.o --quiet
${DENICE} ${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_1.o test_bounce_neon_aosoa.o --quiet
${DENICE} ${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_2.o test_bounce_neon_aosoa.o --quiet
${DENICE} ${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_3.o test_bounce_neon_aosoa.o --quiet
${DENICE} ${BUILD}/elvenrel ${COMMON}/test_bounce_data_aosoa_alt_2.o test_bounce_neon_aosoa_bg.o --quiet
tput cnorm

# De-boost kitty to normal warp

if [[ ! -z ${PID_KITTY} ]] ; then
sudo renice -n 20 -p ${PID_KITTY}
fi
2 changes: 1 addition & 1 deletion test_macos/test_bounce_neon_aosoa_bg.s
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ fb_cursor_len = . - fb_cursor_cmd

.align 3
timeval:
.dword 0, 13000
.dword 0, 12300

.section .bss
.align 6
Expand Down
85 changes: 39 additions & 46 deletions test_macos/test_timeval.s
Original file line number Diff line number Diff line change
Expand Up @@ -35,61 +35,32 @@ advance_timeval_us:
subs w2, w4, w2
blo .Lupdate_only_us
add x3, x3, 1
stp x3, x2, [x0]
str x3, [x0]
str w2, [x0, 8]
ret
.Lupdate_only_us:
add w4, w4, w1
str x4, [x0, 8]
str w4, [x0, 8]
ret

_start:
adrf x17, timeval
adrf x18, msg

mov x16, SYS_gettimeofday
mov x2, xzr
mov x1, xzr
mov x0, x17
svc 0

// itoa timeval::tv_sec
ldr x1, [x17]
adrf x0, msg
bl string_x64

// itoa timeval::tv_usec
ldr x1, [x17, 8]
adrf x0, msg + 17
bl string_x64

// output current time
mov x16, SYS_write
mov x2, msg_len
adrf x1, msg
mov x0, STDOUT_FILENO
svc 0
ldr q0, [x17]
str q0, [x17, 16]

// advance time by DTIME us
mov w1, DTIME
mov x0, x17
add x0, x17, 16
bl advance_timeval_us

// itoa timeval::tv_sec
ldr x1, [x17]
adrf x0, msg
bl string_x64

// itoa timeval::tv_usec
ldr x1, [x17, 8]
adrf x0, msg + 17
bl string_x64

// output new time
mov x16, SYS_write
mov x2, msg_len
adrf x1, msg
mov x0, STDOUT_FILENO
svc 0

// xnu has no nano/usleep -- use select with empty fd sets
mov x16, SYS_select
adr x4, timeval_select
Expand All @@ -102,23 +73,40 @@ _start:
mov x16, SYS_gettimeofday
mov x2, xzr
mov x1, xzr
mov x0, x17
add x0, x17, 32
svc 0

// itoa timeval::tv_sec
ldr x1, [x17]
adrf x0, msg
// itoa start time (timeval::tv_sec and timeval::tv_usec)
ldr x1, [x17], 8
mov x0, x18
bl string_x64

// itoa timeval::tv_usec
ldr x1, [x17, 8]
adrf x0, msg + 17
ldr w1, [x17], 8
add x0, x18, 17
bl string_x32

// itoa target time
ldr x1, [x17], 8
add x0, x18, 26
bl string_x64

// output post-sleep time
ldr w1, [x17], 8
add x0, x18, 43
bl string_x32

// itoa post-sleep time
ldr x1, [x17], 8
add x0, x18, 52
bl string_x64

ldr w1, [x17], 8
add x0, x18, 69
bl string_x32

// output start, target and post-sleep times
mov x16, SYS_write
mov x2, msg_len
adrf x1, msg
mov x1, x18
mov x0, STDOUT_FILENO
svc 0

Expand All @@ -130,10 +118,15 @@ timeval_select:
.dword 0, DTIME

.section .bss
.align 4
timeval:
.dword 0, 0
.dword 0, 0
.dword 0, 0

.section .data
msg:
.ascii "################:################\n"
.ascii "################:########\n"
.ascii "################:########\n"
.ascii "################:########\n"
msg_len = . - msg

0 comments on commit 5368641

Please sign in to comment.