|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stdio.h> |
|
19 #include <stdlib.h> |
|
20 #include <string.h> |
|
21 |
|
22 #define LOG_FILE "c:\\logs\\memcpy-speed_logs.txt" |
|
23 #include "std_log_result.h" |
|
24 #define LOG_FILENAME_LINE __FILE__, __LINE__ |
|
25 |
|
26 void create_xml(int result) |
|
27 { |
|
28 if(result) |
|
29 assert_failed = 1; |
|
30 |
|
31 testResultXml("memcpy-speed"); |
|
32 close_log_file(); |
|
33 } |
|
34 |
|
35 #include <liboil/liboil.h> |
|
36 #include <liboil/liboilprofile.h> |
|
37 #include <liboil/liboilfunction.h> |
|
38 #include <liboil/globals.h> |
|
39 |
|
40 #define ALIGN(ptr,n) ((void *)((unsigned long)(ptr) & (~(unsigned long)(n-1)))) |
|
41 |
|
42 int |
|
43 main(int argc, char *argv[]) |
|
44 { |
|
45 char *s=NULL, *d=NULL; |
|
46 uint32_t *src, *dest; |
|
47 int16_t res=0; |
|
48 OilProfile prof; |
|
49 double ave, std; |
|
50 int i,j, cnt; |
|
51 double cpufreq; |
|
52 OilFunctionClass *klass; |
|
53 OilFunctionImpl *impl; |
|
54 int the_class; |
|
55 |
|
56 std_log(LOG_FILENAME_LINE,"Test Started memcpy-speed"); |
|
57 |
|
58 oil_init (); |
|
59 |
|
60 s = malloc(512*1024+1024); |
|
61 d = malloc(512*1024+1024); |
|
62 // src = ((void *)((unsigned long)(s) | 0xFF )); |
|
63 //dest = ((void *)((unsigned long)(d) | 0xFF )); |
|
64 src = ((void *)((unsigned long)(s) )); |
|
65 dest = ((void *)((unsigned long)(d) )); |
|
66 |
|
67 for(the_class=0; the_class<3; the_class++) |
|
68 { |
|
69 cpufreq = 1788e6; |
|
70 switch(the_class) { |
|
71 case 0: |
|
72 klass = oil_class_get ("splat_u32_ns"); |
|
73 break; |
|
74 case 1: |
|
75 klass = oil_class_get ("copy_u8"); |
|
76 break; |
|
77 case 2: |
|
78 klass = oil_class_get ("sum_s16"); |
|
79 break; |
|
80 } |
|
81 |
|
82 for(impl=klass->first_impl;impl;impl=impl->next) { |
|
83 std_log(LOG_FILENAME_LINE,"impl %s\n", impl->name); |
|
84 |
|
85 if (!oil_impl_is_usable(impl)) { |
|
86 std_log(LOG_FILENAME_LINE," not usable\n"); |
|
87 continue; |
|
88 } |
|
89 |
|
90 oil_class_choose_by_name (klass, impl->name); |
|
91 |
|
92 for(i=10;i<20;i++){ |
|
93 oil_profile_init (&prof); |
|
94 for(j=0;j<10;j++){ |
|
95 switch(the_class) { |
|
96 case 0: |
|
97 oil_profile_start(&prof); |
|
98 oil_splat_u32_ns (dest, src, 1<<(i-2)); |
|
99 oil_profile_stop(&prof); |
|
100 for(cnt=0; cnt<(1<<(i-2)); cnt++){ |
|
101 if(dest[cnt]!=*src){ |
|
102 std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); |
|
103 assert_failed =1; |
|
104 } |
|
105 } |
|
106 |
|
107 break; |
|
108 case 1: |
|
109 oil_profile_start(&prof); |
|
110 oil_memcpy (dest, src, 1<<i); |
|
111 oil_profile_stop(&prof); |
|
112 for(cnt=0; cnt<(1<<(i-2)); cnt++){ //cnt is checked with 1<<(i-2) because dest & src are of type uint32_t* |
|
113 if(dest[cnt]!=src[cnt]){ |
|
114 std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, cnt=%d, i=%d, j=%d, impl->name=%s\n", the_class, cnt, i, j, impl->name); |
|
115 assert_failed =1; |
|
116 } |
|
117 } |
|
118 |
|
119 break; |
|
120 case 2: |
|
121 { |
|
122 int16_t* src1 = (int16_t*)src; |
|
123 int16_t* dest1 = (int16_t*)dest; |
|
124 oil_profile_start(&prof); |
|
125 oil_sum_s16 (dest1, src1, 1<<(i-1)); |
|
126 oil_profile_stop(&prof); |
|
127 res=0; |
|
128 for(cnt=0; cnt<(1<<(i-1)); cnt++){ |
|
129 res += src1[cnt]; |
|
130 } |
|
131 if(*dest1 != res){ |
|
132 std_log(LOG_FILENAME_LINE,"Failed at the_class=%d, impl->name=%s\n", the_class, impl->name); |
|
133 assert_failed =1; |
|
134 } |
|
135 |
|
136 } |
|
137 break; |
|
138 } |
|
139 } |
|
140 oil_profile_get_ave_std (&prof, &ave, &std); |
|
141 std_log(LOG_FILENAME_LINE,"%d: %10.4g %10.4g %10.4g\n", i, ave, std, |
|
142 ave/(1<<i)); |
|
143 |
|
144 } |
|
145 } |
|
146 |
|
147 } |
|
148 free(s); |
|
149 free(d); |
|
150 |
|
151 if(!assert_failed) |
|
152 std_log(LOG_FILENAME_LINE, "Test Passed"); |
|
153 else |
|
154 std_log(LOG_FILENAME_LINE, "Test Failed"); |
|
155 create_xml(0); |
|
156 return 0; |
|
157 } |