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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « crosstest/mem_intrin.cpp ('k') | crosstest/runtests.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: crosstest/mem_intrin_main.cpp
diff --git a/crosstest/mem_intrin_main.cpp b/crosstest/mem_intrin_main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..76df66a1d857811d2be1cee9294a0115deff61f8
--- /dev/null
+++ b/crosstest/mem_intrin_main.cpp
@@ -0,0 +1,69 @@
+/* crosstest.py --test=mem_intrin.cpp --driver=mem_intrin_main.cpp \
+ --prefix=Subzero_ --output=mem_intrin */
+
+#include <stdint.h> /* cstdint requires -std=c++0x or higher */
+#include <cstdio>
+
+#include "mem_intrin.h"
+namespace Subzero_ {
+#include "mem_intrin.h"
+}
+
+#define XSTR(s) STR(s)
+#define STR(s) #s
+
+void testFixedLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
+#define do_test_fixed(test_func) \
+ for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
+ ++TotalTests; \
+ int llc_result = test_func(init_val); \
+ int sz_result = Subzero_::test_func(init_val); \
+ if (llc_result == sz_result) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ printf("Failure (%s): init_val=%d, llc=%d, sz=%d\n", \
+ STR(test_func), init_val, llc_result, sz_result); \
+ } \
+ }
+
+ do_test_fixed(memcpy_test_fixed_len)
+ do_test_fixed(memmove_test_fixed_len)
+ do_test_fixed(memset_test_fixed_len)
+#undef do_test_fixed
+}
+
+void testVariableLen(size_t &TotalTests, size_t &Passes, size_t &Failures) {
+ uint8_t buf[256];
+ uint8_t buf2[256];
+#define do_test_variable(test_func) \
+ for (size_t len = 4; len < 128; ++len) { \
+ for (uint8_t init_val = 0; init_val < 100; ++init_val) { \
+ ++TotalTests; \
+ int llc_result = test_func(buf, (void *)buf2, init_val, len); \
+ int sz_result = Subzero_::test_func(buf, (void *)buf2, init_val, len); \
+ if (llc_result == sz_result) { \
+ ++Passes; \
+ } else { \
+ ++Failures; \
+ printf("Failure (%s): init_val=%d, len=%d, llc=%d, sz=%d\n", \
+ STR(test_func), init_val, len, llc_result, sz_result); \
+ } \
+ } \
+ }
+
+ do_test_variable(memcpy_test)
+ do_test_variable(memmove_test)
+ do_test_variable(memset_test)
+#undef do_test_variable
+}
+
+int main(int argc, char **argv) {
+ unsigned TotalTests = 0;
+ unsigned Passes = 0;
+ unsigned Failures = 0;
+ testFixedLen(TotalTests, Passes, Failures);
+ testVariableLen(TotalTests, Passes, Failures);
+ printf("TotalTests=%u Passes=%u Failures=%u\n", TotalTests, Passes, Failures);
+ return Failures;
+}
« 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