Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define testnd(idx, from, to) \
- for (n[idx - 1] = ((argc > optind + idx * 2 - 1) ? \
- atoi(argv[optind + idx * 2 - 1]) : from); \
- n[idx - 1] <= ((argc > optind + idx * 2) ? \
- atoi(argv[optind + idx * 2]) : \
- ((argc == optind + idx * 2) ? \
- atoi(argv[optind + idx * 2 - 1]) : to - 1)); \
- n[idx - 1]++)
- #define test1d(name, from, to) \
- if (argc == optind || !strcmp(argv[optind], name)) \
- testnd(1, from, to)
- static unsigned num_tests;
- static void test_mc(const mc_fn c_fn, const mc_fn simd_fn,
- const enum FilterMode filter, const int log2idx,
- const int opidx, const int have_mx, const int have_my)
- {
- ALIGN_STK_32(uint8_t, src, 96 * 96,);
- ALIGN_STK_32(uint8_t, c_dst, 64 * 64,);
- ALIGN_STK_32(uint8_t, simd_dst, 64 * 64,);
- unsigned n;
- for (n = 0; n < num_tests; n++) {
- const int mx = have_mx ? 1 + (random() % 6) : 0;
- const int my = have_my ? 1 + (random() % 6) : 0;
- uint8_t *src_ptr = src + 3 + (random() % 25) + (3 + (random() % 25)) * 96;
- fill_plane(src, 96 * 96);
- if (opidx) {
- fill_plane(c_dst, 64 * 64);
- memcpy(simd_dst, c_dst, 64 * 64);
- }
- start_timer(c, n);
- c_fn(c_dst, 4 << log2idx, src_ptr, 96, 4 << log2idx, mx, my);
- stop_timer(c);
- start_timer(simd, n);
- simd_fn(simd_dst, 4 << log2idx, src_ptr, 96, 4 << log2idx, mx, my);
- stop_timer(simd);
- assert(!memcmp(c_dst, simd_dst, 4 << (log2idx * 2)));
- }
- }
- #define test_dsp_fn(DSPCtxType, fn_type, dsp_init_fn, member, idx, test, fmt, args...) do { \
- DSPCtxType dsp; \
- fn_type c, last; \
- int shift; \
- \
- set_cpu_flags_mask_x86(0); \
- dsp_init_fn(&dsp); \
- c = last = dsp.member idx; \
- for (shift = 31; shift >= 0; shift--) { \
- fn_type simd; \
- \
- set_cpu_flags_mask_x86(X86_ALL_CPU_FLAGS >> shift); \
- dsp_init_fn(&dsp); \
- simd = dsp.member idx; \
- if (simd != last) { \
- printf("Running %s on %s.%s" fmt " %p (C) versus %p (SIMD; 0x%x=", \
- #test, #DSPCtxType, #member, args, c, simd, \
- X86_ALL_CPU_FLAGS >> shift); \
- print_cpu_flags_x86(X86_ALL_CPU_FLAGS >> shift); \
- printf(")\n"); \
- test(c, simd, args); \
- last = simd; \
- } \
- } \
- } while (0)
- int main(const int argc, char *const argv[]) {
- int n[5];
- parse_args(argc, argv, 0, 30, 4, "[testname [args]]",
- "To run any one single test, specify the name of the test");
- test1d("mc", 0, N_FILTERS)
- testnd(2, 0, 5)
- testnd(3, 0, 2)
- testnd(4, 0, 2)
- testnd(5, 0, 2)
- test_dsp_fn(VP9DSPContext, mc_fn, ff_vp9_dsp_init,
- mc, [n[0]][n[1]][n[2]][n[3]][n[4]], test_mc,
- "[%d][%d][%d][%d][%d]",
- n[0], n[1], n[2], n[3], n[4]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement