summaryrefslogtreecommitdiff
path: root/test_blit.c
diff options
context:
space:
mode:
authorYongqin Liu <yongqin.liu@linaro.org>2015-07-22 19:33:43 +0800
committerYongqin Liu <yongqin.liu@linaro.org>2015-07-22 19:33:43 +0800
commit94006fea0784791772b70a46961c3e99459fbf19 (patch)
tree170a04c88111287f2d103cec86fda25f6cfe74cc /test_blit.c
parent5c731541fe1352827cb36e0954035537a2d80726 (diff)
downloadblitVH-test-master.tar.gz
Init commit for blitV/H related testHEADmaster
Signed-off-by: Yongqin Liu <yongqin.liu@linaro.org>
Diffstat (limited to 'test_blit.c')
-rw-r--r--test_blit.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/test_blit.c b/test_blit.c
new file mode 100644
index 0000000..cb63d3e
--- /dev/null
+++ b/test_blit.c
@@ -0,0 +1,219 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<stddef.h>
+#include<stdint.h>
+#include<arm_neon.h>
+
+#include "timer.h"
+#include "blit.h"
+
+#define TEST_LENGTH_SAMPLES (10000)
+
+#define TEST_COUNT 500000
+
+static uint16_t testInput_u16[TEST_LENGTH_SAMPLES];
+
+//input and output
+static uint16_t* in0 = NULL;
+static uint16_t* in1 = NULL;
+static uint16_t* in2 = NULL;
+static uint16_t* in3 = NULL;
+
+static double time0 = 0;
+static double time1 = 0;
+
+void test_blitV_conformance()
+{
+
+ int i = 0;
+ int height = 0;
+ unsigned int sse0, sse1;
+
+
+ /* init input memory */
+ in0 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in0));
+ in1 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in1));
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ testInput_u16[i] = (uint16_t) i; //(rand()&0xffff) ;
+ }
+ fprintf (stdout, "-----------------------------------------------------------\n");
+ fprintf (stdout, "-------------------------------------------CONF TEST\n");
+ fprintf (stdout, "-----------------------------------------------------------\n");
+
+ for (height = 1; height <= 128; height += 1)
+ {
+ printf ("height %d\n", height);
+ memcpy (in0, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ memcpy (in1, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in1));
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ if (in0[i]!=in1[i])
+ printf ("pre i %6d: %10d %10d \n", i, in0[i], in1[i]);
+ }
+ SkRGB16_Opaque_Blitter_blitV_c(in0, 4, height, 25);
+ SkRGB16_Opaque_Blitter_blitV_neon(in1, 4, height, 25);
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ if (in0[i]!=in1[i])
+ printf ("pos i %6d: %10d %10d \n", i, in0[i], in1[i]);
+ }
+ }
+ free (in0);
+ free (in1);
+}
+
+
+void test_blitV_performance()
+{
+
+ int i = 0;
+ int config[] = {1, 8, 18, 32, 76, 85, 120, 128, 512};
+ int num = 0;
+ int height = 0;
+ int loop = 0;
+ unsigned int sse0, sse1;
+
+ /* init input memory */
+ in0 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in0));
+ in1 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in1));
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ testInput_u16[i] = (uint16_t) i; //(rand()&0xffff) ;
+ }
+ fprintf (stdout, "-----------------------------------------------------------\n");
+ fprintf (stdout, "-------------------------------------blitV---------PERF TEST\n");
+ fprintf (stdout, "-----------------------------------------------------------\n");
+
+ for (num = 0; num < sizeof(config)/sizeof(*config); num++)
+ {
+ loop = TEST_COUNT;
+ height = config[num];
+
+ /* C */
+ memcpy (in0, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ reset_timer();
+ for (i = 0; i < loop ; i++)
+ SkRGB16_Opaque_Blitter_blitV_c(in0, 4, height, 25);
+ time0 = get_time();
+
+ /* NEON */
+ memcpy (in1, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ reset_timer();
+ for (i = 0; i < loop ; i++)
+ SkRGB16_Opaque_Blitter_blitV_neon(in1, 4, height, 25);
+ time1 = get_time();
+
+ printf ("height %5d: %20lf %20lf\n", height, time0, time1);
+ printf ("ratio: %lf \n", time0/time1);
+
+ }
+
+ free (in0);
+ free (in1);
+}
+void test_blitH_conformance()
+{
+
+ int i = 0;
+ int height = 0;
+ unsigned int sse0, sse1;
+
+
+ /* init input memory */
+ in0 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in0));
+ in1 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in1));
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ testInput_u16[i] = (uint16_t) i; //(rand()&0xffff) ;
+ }
+ fprintf (stdout, "-----------------------------------------------------------\n");
+ fprintf (stdout, "-------------------------------------------CONF TEST\n");
+ fprintf (stdout, "-----------------------------------------------------------\n");
+
+ for (height = 1; height <= 128; height += 1)
+ {
+ printf ("height %d\n", height);
+ memcpy (in0, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ memcpy (in1, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in1));
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ if (in0[i]!=in1[i])
+ printf ("pre i %6d: %10d %10d \n", i, in0[i], in1[i]);
+ }
+ SkRGB16_Opaque_Blitter_blitH_c(in0, height, 25);
+ SkRGB16_Opaque_Blitter_blitH_neon(in1, height, 25);
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ if (in0[i]!=in1[i])
+ printf ("pos i %6d: %10d %10d \n", i, in0[i], in1[i]);
+ }
+ }
+ free (in0);
+ free (in1);
+}
+
+
+void test_blitH_performance()
+{
+
+ int i = 0;
+ int config[] = {1, 8, 18, 32, 76, 85, 120, 128, 512};
+ int num = 0;
+ int height = 0;
+ int loop = 0;
+ unsigned int sse0, sse1;
+
+ /* init input memory */
+ in0 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in0));
+ in1 = (uint16_t*) malloc ( (TEST_LENGTH_SAMPLES) * sizeof (*in1));
+
+ for (i = 0; i < TEST_LENGTH_SAMPLES; i++)
+ {
+ testInput_u16[i] = (uint16_t) i; //(rand()&0xffff) ;
+ }
+ fprintf (stdout, "-----------------------------------------------------------\n");
+ fprintf (stdout, "--------------------------------------blitH--------PERF TEST\n");
+ fprintf (stdout, "-----------------------------------------------------------\n");
+
+ for (num = 0; num < sizeof(config)/sizeof(*config); num++)
+ {
+ loop = TEST_COUNT;
+ height = config[num];
+
+ /* C */
+ memcpy (in0, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ reset_timer();
+ for (i = 0; i < loop ; i++)
+ SkRGB16_Opaque_Blitter_blitH_c(in0, height, 25);
+ time0 = get_time();
+
+ /* NEON */
+ memcpy (in1, testInput_u16, TEST_LENGTH_SAMPLES * sizeof (*in0));
+ reset_timer();
+ for (i = 0; i < loop ; i++)
+ SkRGB16_Opaque_Blitter_blitH_neon(in1, height, 25);
+ time1 = get_time();
+
+ printf ("height %5d: %20lf %20lf\n", height, time0, time1);
+ printf ("ratio: %lf \n", time0/time1);
+
+ }
+
+ free (in0);
+ free (in1);
+}
+
+
+void main (void)
+{
+ test_blitV_conformance(); // run tests
+ test_blitV_performance(); // run tests
+ test_blitH_conformance(); // run tests
+ test_blitH_performance(); // run tests
+}