This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch hjl/x86/optimize updated. glibc-2.25-306-g2b3bde8
- From: hjl at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 10 May 2017 23:07:31 -0000
- Subject: GNU C Library master sources branch hjl/x86/optimize updated. glibc-2.25-306-g2b3bde8
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, hjl/x86/optimize has been updated
via 2b3bde8ba2a75313052a68a4138af8706f9ffa5f (commit)
via 8f07f75489b386b9b86ac0e2d41a38fa3ed80848 (commit)
via c1a94c7328259943a2ab9cf5a997246c79c04f08 (commit)
via 72e5bea21c362d722e0e1c3801c58aca9265711f (commit)
via a701cdc86b476aabd5eff13941cdcd823f208cc6 (commit)
from e6afc30fdf51f7dbe7c6464213acd47ba3d1acd4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=2b3bde8ba2a75313052a68a4138af8706f9ffa5f
commit 2b3bde8ba2a75313052a68a4138af8706f9ffa5f
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 10 16:05:09 2017 -0700
Integrate memcpy_benchmark.cc with glibc benchtests
diff --git a/benchtests/memcpy_benchmark.cc b/benchtests/memcpy_benchmark.cc
index 51dff26..979373c 100644
--- a/benchtests/memcpy_benchmark.cc
+++ b/benchtests/memcpy_benchmark.cc
@@ -24,6 +24,13 @@
#include <map>
#include <string>
+#define TEST_MAIN
+#define TEST_NAME "memcpy"
+#include "bench-string.h"
+
+typedef char *(*proto_t) (char *, const char *, size_t);
+IMPL (memcpy, 1)
+
std::chrono::time_point<std::chrono::high_resolution_clock> start;
std::chrono::time_point<std::chrono::high_resolution_clock> stop;
size_t bytes;
@@ -35,7 +42,7 @@ int size_list[] = {1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19,
1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24, 1 << 25, 1 << 26};
size_t buffer_size = 1 << 28;
-void BM_memcpy_readwritecache(int iters, int size) {
+void BM_memcpy_readwritecache(impl_t *impl, int iters, int size) {
unsigned char * buf1 = new unsigned char [size];
unsigned char * buf2 = new unsigned char [size];
@@ -43,14 +50,14 @@ void BM_memcpy_readwritecache(int iters, int size) {
start_timing();
for (int i = 0; i < iters; ++i) {
- memcpy(buf2, buf1, size);
+ CALL(impl, buf2, buf1, size);
}
stop_timing();
delete[] buf1; delete[] buf2;
}
-void BM_memcpy_nocache(int iters, int size) {
+void BM_memcpy_nocache(impl_t *impl, int iters, int size) {
unsigned char * buf1 = new unsigned char [buffer_size];
unsigned char * buf2 = new unsigned char [buffer_size];
@@ -59,7 +66,7 @@ void BM_memcpy_nocache(int iters, int size) {
size_t offset = 0;
start_timing();
for (int i = 0; i < iters; ++i) {
- memcpy(buf2 + offset, buf1 + offset, size);
+ CALL(impl, buf2 + offset, buf1 + offset, size);
offset += std::max(4097, size + 1);
if (offset >= buffer_size - size) offset = 0;
}
@@ -68,7 +75,7 @@ void BM_memcpy_nocache(int iters, int size) {
delete[] buf1; delete[] buf2;
}
-void BM_memcpy_readcache(int iters, int size) {
+void BM_memcpy_readcache(impl_t *impl, int iters, int size) {
unsigned char * buf1 = new unsigned char [size];
unsigned char * buf2 = new unsigned char [buffer_size];
@@ -77,7 +84,7 @@ void BM_memcpy_readcache(int iters, int size) {
size_t offset = 0;
start_timing();
for (int i = 0; i < iters; ++i) {
- memcpy(buf2 + offset, buf1, size);
+ CALL(impl, buf2 + offset, buf1, size);
offset += std::max(4097, size + 1);
if (offset >= buffer_size - size) offset = 0;
}
@@ -86,30 +93,42 @@ void BM_memcpy_readcache(int iters, int size) {
delete[] buf1; delete[] buf2;
}
-double do_timing(std::function<void(int, int)> &fn, int size) {
+double do_timing(std::function<void(impl_t *, int, int)> &fn, impl_t *impl, int size) {
int iters = 2; double time = 0;
while (time < 500) {
iters *= 3;
- fn(iters, size);
+ fn(impl, iters, size);
time = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start).count();
bytes = (2UL * iters * size);
}
return time;
}
-std::map<std::string, std::function<void(int, int)>> schemes =
+std::map<std::string, std::function<void(impl_t *, int, int)>> schemes =
{{"Read and Write Cache", BM_memcpy_readwritecache},
{"No Cache", BM_memcpy_nocache},
{"Read Cache", BM_memcpy_readcache}};
-int main(void) {
+void test(impl_t *impl) {
std::cout << " Size (bytes) Time (msec) BW (Gbytes/sec)" << std::endl;
for (auto scheme : schemes) {
std::cout << scheme.first << std::endl;
for (auto size : size_list) {
- int time = do_timing(scheme.second, size);
+ int time = do_timing(scheme.second, impl, size);
printf("%12d %10d %10.2f\n", size, time, (bytes * 1000L / time) / 1e9);
}
std::cout << "----------------\n";
}
-}
\ No newline at end of file
+ return 0;
+}
+
+int test_main(void) {
+ test_init ();
+ FOR_EACH_IMPL (impl, 0)
+ {
+ std::cout << impl->name << std::endl;
+ test (impl);
+ }
+ return 0;
+}
+#include <support/test-driver.c>
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=8f07f75489b386b9b86ac0e2d41a38fa3ed80848
commit 8f07f75489b386b9b86ac0e2d41a38fa3ed80848
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 10 15:25:54 2017 -0700
Build memcpy_benchmark in benchtests
Compile memcpy_benchmark.cc with -fpermissive -Wno-error to silence GCC.
diff --git a/benchtests/Makefile b/benchtests/Makefile
index 7f5fda5..79fab64 100644
--- a/benchtests/Makefile
+++ b/benchtests/Makefile
@@ -99,6 +99,12 @@ binaries-bench := $(addprefix $(objpfx)bench-,$(bench))
binaries-benchset := $(addprefix $(objpfx)bench-,$(benchset))
binaries-bench-malloc := $(addprefix $(objpfx)bench-,$(bench-malloc))
+ifneq (,$(CXX))
+binaries-bench += $(objpfx)memcpy_benchmark
+CFLAGS-memcpy_benchmark.cc = -fpermissive -Wno-error
+LDLIBS-memcpy_benchmark = -lstdc++
+endif
+
# The default duration: 10 seconds.
ifndef BENCH_DURATION
BENCH_DURATION := 10
@@ -122,6 +128,9 @@ endif
# for all these modules.
cpp-srcs-left := $(binaries-benchset:=.c) $(binaries-bench:=.c) \
$(binaries-bench-malloc:=.c)
+ifneq (,$(CXX))
+cpp-srcs-left += memcpy_benchmark.cc
+endif
lib := nonlib
include $(patsubst %,$(..)libof-iterator.mk,$(cpp-srcs-left))
diff --git a/string/memcpy_benchmark.cc b/benchtests/memcpy_benchmark.cc
similarity index 100%
rename from string/memcpy_benchmark.cc
rename to benchtests/memcpy_benchmark.cc
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c1a94c7328259943a2ab9cf5a997246c79c04f08
commit c1a94c7328259943a2ab9cf5a997246c79c04f08
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 10 16:02:56 2017 -0700
Add __BEGIN_DECLS/__END_DECLS for C++
diff --git a/include/ifunc-impl-list.h b/include/ifunc-impl-list.h
index 22ca05f..f4be574 100644
--- a/include/ifunc-impl-list.h
+++ b/include/ifunc-impl-list.h
@@ -22,6 +22,8 @@
#include <stdbool.h>
#include <stddef.h>
+__BEGIN_DECLS
+
struct libc_ifunc_impl
{
/* The name of function to be tested. */
@@ -53,4 +55,6 @@ extern size_t __libc_ifunc_impl_list (const char *name,
struct libc_ifunc_impl *array,
size_t max);
+__END_DECLS
+
#endif /* ifunc-impl-list.h */
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=72e5bea21c362d722e0e1c3801c58aca9265711f
commit 72e5bea21c362d722e0e1c3801c58aca9265711f
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 10 14:54:22 2017 -0700
Check __cplusplus in addition to _ISOMAC
diff --git a/include/wctype.h b/include/wctype.h
index a71b103..74f9f47 100644
--- a/include/wctype.h
+++ b/include/wctype.h
@@ -1,6 +1,6 @@
#ifndef _WCTYPE_H
-#ifndef _ISOMAC
+#if !defined _ISOMAC && !defined __cplusplus
/* We try to get wint_t from <stddef.h>, but not all GCC versions define it
there. So define it ourselves if it remains undefined. */
# define __need_wint_t
@@ -38,7 +38,7 @@ libc_hidden_proto (towupper)
#include <wctype/wctype.h>
-#ifndef _ISOMAC
+#if !defined _ISOMAC && !defined __cplusplus
/* Internal interfaces. */
extern int __iswspace (wint_t __wc);
extern int __iswctype (wint_t __wc, wctype_t __desc);
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=a701cdc86b476aabd5eff13941cdcd823f208cc6
commit a701cdc86b476aabd5eff13941cdcd823f208cc6
Author: H.J. Lu <hjl.tools@gmail.com>
Date: Wed May 10 14:30:08 2017 -0700
Import memcpy_benchmark.cc
From
https://gist.github.com/ekelsen/b66cc085eb39f0495b57679cdb1874fa
diff --git a/string/memcpy_benchmark.cc b/string/memcpy_benchmark.cc
new file mode 100644
index 0000000..51dff26
--- /dev/null
+++ b/string/memcpy_benchmark.cc
@@ -0,0 +1,115 @@
+/* Copyright 2017 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ======================================================================*/
+
+#if !defined DO_STRING_INLINES
+#undef __USE_STRING_INLINES
+#endif
+
+#include <string.h>
+#include <chrono>
+#include <iostream>
+#include <functional>
+#include <map>
+#include <string>
+
+std::chrono::time_point<std::chrono::high_resolution_clock> start;
+std::chrono::time_point<std::chrono::high_resolution_clock> stop;
+size_t bytes;
+
+void start_timing() { start = std::chrono::high_resolution_clock::now(); }
+void stop_timing() { stop = std::chrono::high_resolution_clock::now(); }
+
+int size_list[] = {1 << 14, 1 << 15, 1 << 16, 1 << 17, 1 << 18, 1 << 19,
+ 1 << 20, 1 << 21, 1 << 22, 1 << 23, 1 << 24, 1 << 25, 1 << 26};
+size_t buffer_size = 1 << 28;
+
+void BM_memcpy_readwritecache(int iters, int size) {
+ unsigned char * buf1 = new unsigned char [size];
+ unsigned char * buf2 = new unsigned char [size];
+
+ memset (buf1, 0xa5, size); memset (buf2, 0x5a, size);
+
+ start_timing();
+ for (int i = 0; i < iters; ++i) {
+ memcpy(buf2, buf1, size);
+ }
+ stop_timing();
+
+ delete[] buf1; delete[] buf2;
+}
+
+void BM_memcpy_nocache(int iters, int size) {
+ unsigned char * buf1 = new unsigned char [buffer_size];
+ unsigned char * buf2 = new unsigned char [buffer_size];
+
+ memset (buf1, 0xa5, buffer_size); memset (buf2, 0x5a, buffer_size);
+
+ size_t offset = 0;
+ start_timing();
+ for (int i = 0; i < iters; ++i) {
+ memcpy(buf2 + offset, buf1 + offset, size);
+ offset += std::max(4097, size + 1);
+ if (offset >= buffer_size - size) offset = 0;
+ }
+ stop_timing();
+
+ delete[] buf1; delete[] buf2;
+}
+
+void BM_memcpy_readcache(int iters, int size) {
+ unsigned char * buf1 = new unsigned char [size];
+ unsigned char * buf2 = new unsigned char [buffer_size];
+
+ memset (buf1, 0xa5, size); memset (buf2, 0x5a, buffer_size);
+
+ size_t offset = 0;
+ start_timing();
+ for (int i = 0; i < iters; ++i) {
+ memcpy(buf2 + offset, buf1, size);
+ offset += std::max(4097, size + 1);
+ if (offset >= buffer_size - size) offset = 0;
+ }
+ stop_timing();
+
+ delete[] buf1; delete[] buf2;
+}
+
+double do_timing(std::function<void(int, int)> &fn, int size) {
+ int iters = 2; double time = 0;
+ while (time < 500) {
+ iters *= 3;
+ fn(iters, size);
+ time = std::chrono::duration_cast<std::chrono::milliseconds>(stop - start).count();
+ bytes = (2UL * iters * size);
+ }
+ return time;
+}
+
+std::map<std::string, std::function<void(int, int)>> schemes =
+ {{"Read and Write Cache", BM_memcpy_readwritecache},
+ {"No Cache", BM_memcpy_nocache},
+ {"Read Cache", BM_memcpy_readcache}};
+
+int main(void) {
+ std::cout << " Size (bytes) Time (msec) BW (Gbytes/sec)" << std::endl;
+ for (auto scheme : schemes) {
+ std::cout << scheme.first << std::endl;
+ for (auto size : size_list) {
+ int time = do_timing(scheme.second, size);
+ printf("%12d %10d %10.2f\n", size, time, (bytes * 1000L / time) / 1e9);
+ }
+ std::cout << "----------------\n";
+ }
+}
\ No newline at end of file
-----------------------------------------------------------------------
Summary of changes:
benchtests/Makefile | 9 +++
benchtests/memcpy_benchmark.cc | 134 ++++++++++++++++++++++++++++++++++++++++
include/ifunc-impl-list.h | 4 +
include/wctype.h | 4 +-
4 files changed, 149 insertions(+), 2 deletions(-)
create mode 100644 benchtests/memcpy_benchmark.cc
hooks/post-receive
--
GNU C Library master sources