Skip to content

Commit

Permalink
test loads
Browse files Browse the repository at this point in the history
  • Loading branch information
clamchowder committed Oct 8, 2023
1 parent 3c53bd6 commit 0f93a07
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
8 changes: 8 additions & 0 deletions InstructionRate/x86_instructionrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extern uint64_t mul16(uint64_t iterations) __attribute((sysv_abi));
extern uint64_t mul64(uint64_t iterations) __attribute((sysv_abi));
extern uint64_t load128(uint64_t iterations, int *arr) __attribute((sysv_abi));
extern uint64_t spacedload128(uint64_t iterations, int *arr) __attribute((sysv_abi));
extern uint64_t loadscalar(uint64_t iterations, int *arr) __attribute((sysv_abi));
extern uint64_t load256(uint64_t iterations, float *arr) __attribute((sysv_abi));
extern uint64_t load512(uint64_t iterations, float *arr) __attribute((sysv_abi));
extern uint64_t store128(uint64_t iterations, int *arr, int *sink) __attribute((sysv_abi));
Expand Down Expand Up @@ -125,6 +126,7 @@ int *intTestArr;
int intSinkArr[8] __attribute__ ((aligned (64))) = { 2, 3, 4, 5, 6, 7, 8, 9 };

uint64_t load128wrapper(uint64_t iterations) __attribute((sysv_abi));
uint64_t loadscalarwrapper(uint64_t iterations) __attribute((sysv_abi));
uint64_t spacedload128wrapper(uint64_t iterations) __attribute((sysv_abi));
uint64_t spacedstorescalarwrapper(uint64_t iterations) __attribute((sysv_abi));
uint64_t load256wrapper(uint64_t iterations) __attribute((sysv_abi));
Expand Down Expand Up @@ -420,6 +422,8 @@ int main(int argc, char *argv[]) {
printf("2:1 mixed 16-bit/64-bit imul per clk: %.2f\n", measureFunction(iterations, clockSpeedGhz, mixmul16mul64_21));

// load/store
if (argc == 1 || argc > 1 && strncmp(argv[1], "loadscalar", 10) == 0)
printf("64-bit scalar loads per clk: %.2f\n", measureFunction(iterations, clockSpeedGhz, loadscalarwrapper));
if (argc == 1 || argc > 1 && strncmp(argv[1], "load128", 7) == 0)
printf("128-bit loads per clk: %.2f\n", measureFunction(iterations, clockSpeedGhz, load128wrapper));
if (argc == 1 || argc > 1 && strncmp(argv[1], "spacedload128", 13) == 0)
Expand Down Expand Up @@ -471,6 +475,10 @@ __attribute((sysv_abi)) uint64_t load256wrapper(uint64_t iterations) {
return load256(iterations, fpTestArr);
}

__attribute((sysv_abi)) uint64_t loadscalarwrapper(uint64_t iterations) {
return loadscalar(iterations, intTestArr);
}

__attribute((sysv_abi)) uint64_t load512wrapper(uint64_t iterations) {
return load512(iterations, fpTestArr);
}
Expand Down
48 changes: 48 additions & 0 deletions InstructionRate/x86_instructionrate.s
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
.global store128
.global store256
.global store512
.global loadscalar
.global spacedstorescalar
.global mixaddmul128int
.global mixmul16mul64
Expand Down Expand Up @@ -3984,6 +3985,53 @@ mixmul16mul64_21_loop:
pop %rbx
ret

loadscalar:
push %rbx
push %rcx
push %r8
push %r9
push %r10
push %r11
push %r12
push %r13
push %r14
push %r15
mov $20, %r9
loadscalar_loop:
mov (%rsi), %r15
mov 8(%rsi), %r14
mov 16(%rsi), %r13
mov 24(%rsi), %r12
mov 32(%rsi), %r11
mov 40(%rsi), %r10
mov 48(%rsi), %r15
mov 56(%rsi), %r14
mov 64(%rsi), %r13
mov 72(%rsi), %r12
mov 80(%rsi), %r11
mov 88(%rsi), %r10
mov 96(%rsi), %r15
mov 104(%rsi), %r14
mov 112(%rsi), %r13
mov 120(%rsi), %r12
mov 128(%rsi), %r11
mov 136(%rsi), %r10
mov 144(%rsi), %r15
mov 152(%rsi), %r14
sub %r9, %rdi
jnz loadscalar_loop
pop %r15
pop %r14
pop %r13
pop %r12
pop %r11
pop %r10
pop %r9
pop %r8
pop %rcx
pop %rbx
ret

spacedstorescalar:
push %rbx
push %rcx
Expand Down

0 comments on commit 0f93a07

Please sign in to comment.