X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fllvmpipe%2Flp_test_main.c;h=c7b6d65fa303009abd7f0678363d6604d5215503;hb=6f7371619c5edcde647ae8f4822d1b5bae050ef6;hp=4592dc0b2d070dc27d0774c0eac70d4af1f2da00;hpb=890679d4322e7ba4f12f32532a3fdd277edff886;p=mesa.git diff --git a/src/gallium/drivers/llvmpipe/lp_test_main.c b/src/gallium/drivers/llvmpipe/lp_test_main.c index 4592dc0b2d0..c7b6d65fa30 100644 --- a/src/gallium/drivers/llvmpipe/lp_test_main.c +++ b/src/gallium/drivers/llvmpipe/lp_test_main.c @@ -34,7 +34,12 @@ */ -#include "lp_bld_const.h" +#include "util/u_cpu_detect.h" +#include "util/u_math.h" + +#include "gallivm/lp_bld_const.h" +#include "gallivm/lp_bld_init.h" +#include "gallivm/lp_bld_debug.h" #include "lp_test.h" @@ -190,16 +195,19 @@ random_elem(struct lp_type type, void *dst, unsigned index) assert(index < type.length); value = (double)rand()/(double)RAND_MAX; if(!type.norm) { - unsigned long long mask; - if (type.floating) - mask = ~(unsigned long long)0; - else if (type.fixed) - mask = ((unsigned long long)1 << (type.width / 2)) - 1; - else if (type.sign) - mask = ((unsigned long long)1 << (type.width - 1)) - 1; - else - mask = ((unsigned long long)1 << type.width) - 1; - value += (double)(mask & rand()); + if (type.floating) { + value *= 2.0; + } + else { + unsigned long long mask; + if (type.fixed) + mask = ((unsigned long long)1 << (type.width / 2)) - 1; + else if (type.sign) + mask = ((unsigned long long)1 << (type.width - 1)) - 1; + else + mask = ((unsigned long long)1 << type.width) - 1; + value += (double)(mask & rand()); + } } if(!type.sign) if(rand() & 1) @@ -246,12 +254,18 @@ boolean compare_vec_with_eps(struct lp_type type, const void *res, const void *ref, double eps) { unsigned i; + eps *= type.floating ? 8.0 : 2.0; for (i = 0; i < type.length; ++i) { double res_elem = read_elem(type, res, i); double ref_elem = read_elem(type, ref, i); - double delta = fabs(res_elem - ref_elem); - if(delta >= 2.0*eps) + double delta = res_elem - ref_elem; + if (ref_elem < -1.0 || ref_elem > 1.0) { + delta /= ref_elem; + } + delta = fabs(delta); + if (delta >= eps) { return FALSE; + } } return TRUE; @@ -355,16 +369,36 @@ int main(int argc, char **argv) unsigned long n = 1000; unsigned i; boolean success; + boolean single = FALSE; + unsigned fpstate; + + util_cpu_detect(); + fpstate = util_fpstate_get(); + util_fpstate_set_denorms_to_zero(fpstate); + + if (!lp_build_init()) + return 1; for(i = 1; i < argc; ++i) { if(strcmp(argv[i], "-v") == 0) ++verbose; + else if(strcmp(argv[i], "-s") == 0) + single = TRUE; else if(strcmp(argv[i], "-o") == 0) fp = fopen(argv[++i], "wt"); else n = atoi(argv[i]); } +#ifdef DEBUG + if (verbose >= 2) { + gallivm_debug |= GALLIVM_DEBUG_IR; + gallivm_debug |= GALLIVM_DEBUG_ASM; + } +#endif + + util_cpu_detect(); + if(fp) { /* Warm up the caches */ test_some(0, NULL, 100); @@ -372,7 +406,9 @@ int main(int argc, char **argv) write_tsv_header(fp); } - if(n) + if (single) + success = test_single(verbose, fp); + else if (n) success = test_some(verbose, fp, n); else success = test_all(verbose, fp);