static int sum_square_diff_u8 (uint8_t * s1, uint8_t * s2, int n) { #ifndef HAVE_ORC int sum = 0; int i; int x; for (i = 0; i < n; i++) { x = s1[i] - s2[i]; sum += x * x; } return sum; #else static OrcProgram *p = NULL; OrcExecutor *ex; int val; if (p == NULL) { OrcCompileResult ret; p = orc_program_new_ass (4, 1, 1); orc_program_add_temporary (p, 2, "t1"); orc_program_add_temporary (p, 2, "t2"); orc_program_add_temporary (p, 4, "t3"); orc_program_append_ds_str (p, "convubw", "t1", "s1"); orc_program_append_ds_str (p, "convubw", "t2", "s2"); orc_program_append_str (p, "subw", "t1", "t1", "t2"); orc_program_append_str (p, "mullw", "t1", "t1", "t1"); orc_program_append_ds_str (p, "convuwl", "t3", "t1"); orc_program_append_ds_str (p, "accl", "a1", "t3"); ret = orc_program_compile (p); if (!ORC_COMPILE_RESULT_IS_SUCCESSFUL (ret)) { GST_ERROR ("Orc compiler failure"); return 0; } } ex = orc_executor_new (p); orc_executor_set_n (ex, n); orc_executor_set_array_str (ex, "s1", s1); orc_executor_set_array_str (ex, "s2", s2); orc_executor_run (ex); val = orc_executor_get_accumulator (ex, 0); orc_executor_free (ex); return val; #endif }
void test_opcode_const (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; int ret; if (opcode->src_size[1] == 0) { return; } p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); orc_program_add_constant (p, opcode->src_size[1], 1, "c1"); sprintf(s, "test_c_%s", opcode->name); orc_program_set_name (p, s); orc_program_append_str (p, opcode->name, "d1", "s1", "c1"); ret = orc_test_compare_output (p); if (!ret) { error = TRUE; } orc_program_free (p); }
void test_opcode_src (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; int ret; if (opcode->src_size[1] == 0) { p = orc_program_new_ds (opcode->dest_size[0], opcode->src_size[0]); } else { p = orc_program_new_dss (opcode->dest_size[0], opcode->src_size[0], opcode->src_size[1]); } sprintf(s, "test_s_%s", opcode->name); orc_program_set_name (p, s); orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); ret = orc_test_compare_output (p); if (!ret) { error = TRUE; } orc_program_free (p); }
static void test_simple (int max, int (*adder) (OrcProgram *, int, const char *)) { OrcProgram *p; int v; OrcCompileResult result; p = orc_program_new (); /* dummy program so compile doesn't barf */ orc_program_add_destination (p, 2, "d1"); orc_program_add_source (p, 2, "s1"); orc_program_append_str (p, "addw", "d1", "d1", "s1"); /* we've alreay added one of those */ if (adder == orc_program_add_destination || adder == orc_program_add_source) max--; /* Check we can add up to the claimed max */ for (v = 0; v < max; v++) (*adder) (p, 2, names + v); result = orc_program_compile (p); if (ORC_COMPILE_RESULT_IS_FATAL (result)) error = TRUE; orc_program_reset (p); /* Check we can not add one more */ (*adder) (p, 2, names + v); result = orc_program_compile (p); if (ORC_COMPILE_RESULT_IS_SUCCESSFUL (result)) error = TRUE; orc_program_free (p); }
void vips_vector_asm3( VipsVector *vector, const char *op, const char *a, const char *b, const char *c ) { vector->n_instruction += 1; #ifdef DEBUG printf( " %s %s %s %s\n", op, a, b, c ); #endif /*DEBUG*/ #ifdef HAVE_ORC orc_program_append_str( vector->program, op, a, b, c ); #endif /*HAVE_ORC*/ }
void test_opcode_src_const_n_2d (OrcStaticOpcode *opcode) { OrcProgram *p; char s[40]; int ret; int flags = 0; if (opcode->flags & ORC_STATIC_OPCODE_SCALAR) { return; } p = orc_program_new (); if (opcode->flags & ORC_STATIC_OPCODE_ACCUMULATOR) { orc_program_add_accumulator (p, opcode->dest_size[0], "d1"); } else { orc_program_add_destination (p, opcode->dest_size[0], "d1"); } if (opcode->dest_size[1] != 0) { orc_program_add_destination (p, opcode->dest_size[1], "d2"); } orc_program_add_source (p, opcode->src_size[0], "s1"); if (opcode->src_size[1] != 0) { orc_program_add_source (p, opcode->src_size[1], "s2"); } if ((opcode->flags & ORC_STATIC_OPCODE_FLOAT_SRC) || (opcode->flags & ORC_STATIC_OPCODE_FLOAT_DEST)) { flags = ORC_TEST_FLAGS_FLOAT; } sprintf(s, "test_s_%s", opcode->name); orc_program_set_name (p, s); orc_program_set_2d (p); orc_program_set_constant_n (p, 8); if (opcode->dest_size[1] != 0) { orc_program_append_dds_str (p, opcode->name, "d1", "d2", "s1"); } else { orc_program_append_str (p, opcode->name, "d1", "s1", "s2"); } ret = orc_test_compare_output_full (p, flags); if (!ret) { printf("FAIL: %s src_const_n_2d\n", opcode->name); error = TRUE; } orc_program_free (p); }
void vips_vector_asm3( VipsVector *vector, const char *op, const char *a, const char *b, const char *c ) { vector->n_instruction += 1; #ifdef DEBUG printf( " %s %s %s %s\n", op, a, b, c ); #endif /*DEBUG*/ #ifdef HAVE_ORC #ifdef DEBUG_TRACE printf( "orc_program_append_str( %s, \"%s\", " "\"%s\", \"%s\", \"%s\" );\n", vector->unique_name, op, a, b, c ); #endif /*DEBUG_TRACE*/ orc_program_append_str( vector->program, op, a, b, c ); #endif /*HAVE_ORC*/ }