Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: crosstest/mem_intrin_main.cpp

Issue 321993002: Add a few Subzero intrinsics (not the atomic ones yet). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: remove TODO Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/mem_intrin.cpp ('k') | crosstest/runtests.sh » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* crosstest.py --test=mem_intrin.cpp --driver=mem_intrin_main.cpp \
2 --prefix=Subzero_ --output=mem_intrin */
3
4 #include <stdint.h> /* cstdint requires -std=c++0x or higher */
5 #include <cstdio>
6
7 #include "mem_intrin.h"
8 namespace Subzero_ {
9 #include "mem_intrin.h"
10 }
11
12 #define XSTR(s) STR(s)
13 #define STR(s) #s
14
15 void testFixedLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
16 #define do_test_fixed(test_func) \
17 for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
18 ++TotalTests; \
19 int llc_result = test_func(init_val); \
20 int sz_result = Subzero_::test_func(init_val); \
21 if (llc_result == sz_result) { \
22 ++Passes; \
23 } else { \
24 ++Failures; \
25 printf("Failure (%s): init_val=%d, llc=%d, sz=%d\n", \
26 STR(test_func), init_val, llc_result, sz_result); \
27 } \
28 }
29
30 do_test_fixed(memcpy_test_fixed_len)
31 do_test_fixed(memmove_test_fixed_len)
32 do_test_fixed(memset_test_fixed_len)
33 #undef do_test_fixed
34 }
35
36 void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
37 uint8_t buf[256];
38 uint8_t buf2[256];
39 #define do_test_variable(test_func) \
40 for (size_t len = 4; len < 128; ++len) { \
41 for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
42 ++TotalTests; \
43 int llc_result = test_func(buf, (void *)buf2, init_val, len); \
44 int sz_result = Subzero_::test_func(buf, (void *)buf2, init_val, len); \
45 if (llc_result == sz_result) { \
46 ++Passes; \
47 } else { \
48 ++Failures; \
49 printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \
50 STR(test_func), init_val, len, llc_result, sz_result); \
51 } \
52 } \
53 }
54
55 do_test_variable(memcpy_test)
56 do_test_variable(memmove_test)
57 do_test_variable(memset_test)
58 #undef do_test_variable
59 }
60
61 int main(int argc, char **argv) {
62 unsigned TotalTests = 0;
63 unsigned Passes = 0;
64 unsigned Failures = 0;
65 testFixedLen(TotalTests, Passes, Failures);
66 testVariableLen(TotalTests, Passes, Failures);
67 printf("TotalTests=%u Passes=%u Failures=%u\n", TotalTests, Passes, Failures);
68 return Failures;
69 }
OLDNEW
« no previous file with comments | « crosstest/mem_intrin.cpp ('k') | crosstest/runtests.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698