Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

lp_test.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /**************************************************************************
  2. *
  3. * Copyright 2009 VMware, Inc.
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  19. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  21. * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  22. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  23. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  24. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. /**
  28. * @file
  29. * Shared testing code.
  30. *
  31. * @author Jose Fonseca <jfonseca@vmware.com>
  32. */
  33. #ifndef LP_TEST_H
  34. #define LP_TEST_H
  35. #include <stdlib.h>
  36. #include <stdio.h>
  37. #include <float.h>
  38. #include "gallivm/lp_bld.h"
  39. #include "pipe/p_state.h"
  40. #include "util/u_format.h"
  41. #include "util/u_math.h"
  42. #include "util/u_dump.h"
  43. #include "gallivm/lp_bld_type.h"
  44. #define LP_TEST_NUM_SAMPLES 32
  45. void
  46. write_tsv_header(FILE *fp);
  47. boolean
  48. test_some(unsigned verbose, FILE *fp,
  49. unsigned long n);
  50. boolean
  51. test_single(unsigned verbose, FILE *fp);
  52. boolean
  53. test_all(unsigned verbose, FILE *fp);
  54. #if defined(PIPE_CC_MSVC)
  55. unsigned __int64 __rdtsc();
  56. #pragma intrinsic(__rdtsc)
  57. #define rdtsc() __rdtsc()
  58. #elif defined(PIPE_CC_GCC) && (defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64))
  59. static INLINE uint64_t
  60. rdtsc(void)
  61. {
  62. uint32_t hi, lo;
  63. __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
  64. return ((uint64_t)lo) | (((uint64_t)hi) << 32);
  65. }
  66. #else
  67. #define rdtsc() 0
  68. #endif
  69. float
  70. random_float(void);
  71. void
  72. dump_type(FILE *fp, struct lp_type type);
  73. double
  74. read_elem(struct lp_type type, const void *src, unsigned index);
  75. void
  76. write_elem(struct lp_type type, void *dst, unsigned index, double src);
  77. void
  78. random_elem(struct lp_type type, void *dst, unsigned index);
  79. void
  80. read_vec(struct lp_type type, const void *src, double *dst);
  81. void
  82. write_vec(struct lp_type type, void *dst, const double *src);
  83. void
  84. random_vec(struct lp_type type, void *dst);
  85. boolean
  86. compare_vec_with_eps(struct lp_type type, const void *res, const void *ref, double eps);
  87. boolean
  88. compare_vec(struct lp_type type, const void *res, const void *ref);
  89. void
  90. dump_vec(FILE *fp, struct lp_type type, const void *src);
  91. #endif /* !LP_TEST_H */