Advertisement
Guest User

Untitled

a guest
Aug 7th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. #define testnd(idx, from, to) \
  2. for (n[idx - 1] = ((argc > optind + idx * 2 - 1) ? \
  3. atoi(argv[optind + idx * 2 - 1]) : from); \
  4. n[idx - 1] <= ((argc > optind + idx * 2) ? \
  5. atoi(argv[optind + idx * 2]) : \
  6. ((argc == optind + idx * 2) ? \
  7. atoi(argv[optind + idx * 2 - 1]) : to - 1)); \
  8. n[idx - 1]++)
  9.  
  10. #define test1d(name, from, to) \
  11. if (argc == optind || !strcmp(argv[optind], name)) \
  12. testnd(1, from, to)
  13.  
  14. static unsigned num_tests;
  15.  
  16. static void test_mc(const mc_fn c_fn, const mc_fn simd_fn,
  17. const enum FilterMode filter, const int log2idx,
  18. const int opidx, const int have_mx, const int have_my)
  19. {
  20. ALIGN_STK_32(uint8_t, src, 96 * 96,);
  21. ALIGN_STK_32(uint8_t, c_dst, 64 * 64,);
  22. ALIGN_STK_32(uint8_t, simd_dst, 64 * 64,);
  23. unsigned n;
  24.  
  25. for (n = 0; n < num_tests; n++) {
  26. const int mx = have_mx ? 1 + (random() % 6) : 0;
  27. const int my = have_my ? 1 + (random() % 6) : 0;
  28. uint8_t *src_ptr = src + 3 + (random() % 25) + (3 + (random() % 25)) * 96;
  29.  
  30. fill_plane(src, 96 * 96);
  31. if (opidx) {
  32. fill_plane(c_dst, 64 * 64);
  33. memcpy(simd_dst, c_dst, 64 * 64);
  34. }
  35.  
  36. start_timer(c, n);
  37. c_fn(c_dst, 4 << log2idx, src_ptr, 96, 4 << log2idx, mx, my);
  38. stop_timer(c);
  39. start_timer(simd, n);
  40. simd_fn(simd_dst, 4 << log2idx, src_ptr, 96, 4 << log2idx, mx, my);
  41. stop_timer(simd);
  42. assert(!memcmp(c_dst, simd_dst, 4 << (log2idx * 2)));
  43. }
  44. }
  45.  
  46. #define test_dsp_fn(DSPCtxType, fn_type, dsp_init_fn, member, idx, test, fmt, args...) do { \
  47. DSPCtxType dsp; \
  48. fn_type c, last; \
  49. int shift; \
  50. \
  51. set_cpu_flags_mask_x86(0); \
  52. dsp_init_fn(&dsp); \
  53. c = last = dsp.member idx; \
  54. for (shift = 31; shift >= 0; shift--) { \
  55. fn_type simd; \
  56. \
  57. set_cpu_flags_mask_x86(X86_ALL_CPU_FLAGS >> shift); \
  58. dsp_init_fn(&dsp); \
  59. simd = dsp.member idx; \
  60. if (simd != last) { \
  61. printf("Running %s on %s.%s" fmt " %p (C) versus %p (SIMD; 0x%x=", \
  62. #test, #DSPCtxType, #member, args, c, simd, \
  63. X86_ALL_CPU_FLAGS >> shift); \
  64. print_cpu_flags_x86(X86_ALL_CPU_FLAGS >> shift); \
  65. printf(")\n"); \
  66. test(c, simd, args); \
  67. last = simd; \
  68. } \
  69. } \
  70. } while (0)
  71.  
  72. int main(const int argc, char *const argv[]) {
  73. int n[5];
  74.  
  75. parse_args(argc, argv, 0, 30, 4, "[testname [args]]",
  76. "To run any one single test, specify the name of the test");
  77.  
  78. test1d("mc", 0, N_FILTERS)
  79. testnd(2, 0, 5)
  80. testnd(3, 0, 2)
  81. testnd(4, 0, 2)
  82. testnd(5, 0, 2)
  83. test_dsp_fn(VP9DSPContext, mc_fn, ff_vp9_dsp_init,
  84. mc, [n[0]][n[1]][n[2]][n[3]][n[4]], test_mc,
  85. "[%d][%d][%d][%d][%d]",
  86. n[0], n[1], n[2], n[3], n[4]);
  87.  
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement