[app][tests][float] generally spiff up the test
Still doesn't seem to work right on some arches, will need to debug whats going on.
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#if ARM_WITH_VFP || ARCH_ARM64 || X86_WITH_FPU || (ARCH_RISCV && RISCV_FPU)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <rand.h>
|
||||
#include <lk/err.h>
|
||||
#include <lk/console_cmd.h>
|
||||
@@ -23,30 +24,29 @@ extern void float_vfp_thumb_instruction_test(void);
|
||||
extern void float_neon_arm_instruction_test(void);
|
||||
extern void float_neon_thumb_instruction_test(void);
|
||||
|
||||
#if !ARM_WITH_VFP_SP_ONLY
|
||||
#if ARM_WITH_VFP_SP_ONLY
|
||||
#define FLOAT float
|
||||
#else
|
||||
#define FLOAT float
|
||||
#define FLOAT double
|
||||
#endif
|
||||
|
||||
/* optimize this function to cause it to try to use a lot of registers */
|
||||
__OPTIMIZE("O3")
|
||||
static int float_thread(void *arg) {
|
||||
FLOAT *val = arg;
|
||||
uint i, j;
|
||||
|
||||
FLOAT a[16];
|
||||
|
||||
/* do a bunch of work with floating point to test context switching */
|
||||
a[0] = *val;
|
||||
for (i = 1; i < countof(a); i++) {
|
||||
a[i] = a[i-1] * 1.01f;
|
||||
for (size_t i = 1; i < countof(a); i++) {
|
||||
a[i] = a[i-1] * (FLOAT)1.01f;
|
||||
}
|
||||
|
||||
for (i = 0; i < 1000000; i++) {
|
||||
a[0] += 0.001f;
|
||||
for (j = 1; j < countof(a); j++) {
|
||||
a[j] += a[j-1] * 0.00001f;
|
||||
for (size_t i = 0; i < 1000000; i++) {
|
||||
a[0] += (FLOAT)0.001f;
|
||||
for (size_t j = 1; j < countof(a); j++) {
|
||||
a[j] += a[j-1] * (FLOAT)0.00001f;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,23 +75,25 @@ static int float_tests(int argc, const console_cmd_args *argv) {
|
||||
|
||||
/* test lazy fpu load on separate thread */
|
||||
thread_t *t[8];
|
||||
FLOAT val[countof(t)];
|
||||
volatile FLOAT val[countof(t)];
|
||||
|
||||
printf("creating %zu floating point threads\n", countof(t));
|
||||
for (uint i = 0; i < countof(t); i++) {
|
||||
val[i] = i;
|
||||
char name[32];
|
||||
snprintf(name, sizeof(name), "float %u", i);
|
||||
t[i] = thread_create(name, &float_thread, &val[i], LOW_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
t[i] = thread_create(name, &float_thread, (void *)&val[i], LOW_PRIORITY, DEFAULT_STACK_SIZE);
|
||||
thread_resume(t[i]);
|
||||
}
|
||||
|
||||
int res;
|
||||
for (uint i = 0; i < countof(t); i++) {
|
||||
thread_join(t[i], &res, INFINITE_TIME);
|
||||
printf("float thread %u returns %d, val %f\n", i, res, (double)val[i]);
|
||||
double result = (double)val[i];
|
||||
printf("float thread %u returns %d, hex val %a\n", i, res, result);
|
||||
//hexdump8(&result, 8);
|
||||
}
|
||||
printf("the above values should be close\n");
|
||||
printf("the above values should be valid and generally increasing, but close\n");
|
||||
|
||||
#if ARCH_ARM && !ARM_ISA_ARMV7M
|
||||
/* test all the instruction traps */
|
||||
|
||||
Reference in New Issue
Block a user