7 #define ORC_ENABLE_UNSTABLE_API
10 #include <orc-test/orctest.h>
11 #include <orc-test/orcprofile.h>
14 #define ALIGN(ptr,n) ((void *)((unsigned long)(ptr) & (~(unsigned long)(n-1))))
18 int flush_cache = FALSE;
22 touch (unsigned char *ptr, int n)
32 main(int argc, char *argv[])
35 orc_uint8 *src, *dest;
39 double ave_libc, std_libc;
45 int level1, level2, level3;
47 //const uint8_t zero = 0;
55 unalign = strtoul (argv[1], NULL, 0);
60 s = malloc(1024*1024*64+1024);
61 d = malloc(1024*1024*64+1024);
62 src = ORC_PTR_OFFSET(ALIGN(s,128),unalign);
65 orc_profile_init (&prof);
67 orc_profile_start(&prof);
68 orc_profile_stop(&prof);
70 orc_profile_get_ave_std (&prof, &null, &std);
73 OrcCompileResult result;
75 p = orc_program_new ();
76 orc_program_set_name (p, "orc_memcpy");
77 //orc_program_set_name (p, "orc_memset");
78 orc_program_add_destination (p, 1, "d1");
79 orc_program_add_source (p, 1, "s1");
80 //orc_program_add_parameter (p, 1, "p1");
82 orc_program_append (p, "copyb", ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1);
84 result = orc_program_compile (p);
88 #define M_LN2 0.69314718055994530942
90 orc_get_data_cache_sizes (&level1, &level2, &level3);
92 max = (log(level3)/M_LN2 - 6.0) * 10 + 20;
93 } else if (level3 > 0) {
94 max = (log(level2)/M_LN2 - 6.0) * 10 + 20;
100 double x = i*0.1 + 6.0;
101 int size = pow(2.0, x);
104 touch (src, (1<<18));
113 orc_profile_init (&prof);
115 OrcExecutor _ex, *ex = &_ex;
116 void (*func) (OrcExecutor *);
118 orc_profile_start(&prof);
119 //orc_memcpy (dest, src, size);
122 ex->arrays[ORC_VAR_D1] = dest;
123 ex->arrays[ORC_VAR_S1] = (void *)src;
128 orc_profile_stop(&prof);
130 touch (src, (1<<18));
140 orc_profile_init (&prof_libc);
142 orc_profile_start(&prof_libc);
143 memcpy (dest, src, size);
144 orc_profile_stop(&prof_libc);
146 touch (src, (1<<18));
156 orc_profile_get_ave_std (&prof, &ave, &std);
157 orc_profile_get_ave_std (&prof_libc, &ave_libc, &std_libc);
159 ave -= null + 65 + 20;
160 ave_libc -= null + 40;
162 //printf("%d: %10.4g %10.4g %10.4g %10.4g (libc %10.4g)\n", i, ave, std,
163 // ave/(1<<i), cpufreq/(ave/(1<<i)),
164 // cpufreq/(ave_libc/(1<<i)));
165 printf("%g %10.4g %10.4g\n", x,
166 cpufreq/(ave/size), cpufreq/(ave_libc/size));
167 //printf("%g %10.4g %10.4g\n", x,
168 // 32*(ave/(size)), 32*(ave_libc/(size)));