aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2016-08-10 15:14:56 +0200
committerMartin Liska <marxin@gcc.gnu.org>2016-08-10 13:14:56 +0000
commita266236e856aec790b1757064eccff876fad4703 (patch)
tree4e0657ae5a14e0c48b2bae73db433a086900d985 /gcc/testsuite/gcc.dg
parent22063dbc90d0eb8a7cc7939e0941899f90b403db (diff)
downloadgcc-a266236e856aec790b1757064eccff876fad4703.zip
gcc-a266236e856aec790b1757064eccff876fad4703.tar.gz
gcc-a266236e856aec790b1757064eccff876fad4703.tar.bz2
Add new *_atomic counter update function
PR gcov-profile/58306 * Makefile.in: New functions (modules) are added. * libgcov-profiler.c (__gcov_interval_profiler_atomic): New function. (__gcov_pow2_profiler_atomic): New function. (__gcov_one_value_profiler_body): New argument is instroduced. (__gcov_one_value_profiler): Call with the new argument. (__gcov_one_value_profiler_atomic): Likewise. (__gcov_indirect_call_profiler_v2): Likewise. (__gcov_time_profiler_atomic): New function. (__gcov_average_profiler_atomic): Likewise. (__gcov_ior_profiler_atomic): Likewise. * libgcov.h: Declare the aforementioned functions. PR gcov-profile/58306 * gcc.dg/tree-prof/val-profiler-threads-1.c: New test. PR gcov-profile/58306 * tree-profile.c (gimple_init_edge_profiler): Create conditionally atomic variants of profile update functions. From-SVN: r239324
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c
new file mode 100644
index 0000000..e9b04a0
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c
@@ -0,0 +1,41 @@
+/* { dg-options "-O0 -pthread -fprofile-update=atomic" } */
+#include <pthread.h>
+
+#define NUM_THREADS 8
+#define SIZE 1024
+#define ITERATIONS (1000 * 1000)
+
+char buffer[SIZE];
+char buffer2[SIZE];
+
+void *copy_memory(char *dst, char *src, unsigned size)
+{
+ for (unsigned i = 0; i < ITERATIONS; i++)
+ {
+ dst[size % 10] = src[size % 20];
+ }
+}
+
+void *foo(void *d)
+{
+ copy_memory (buffer, buffer2, SIZE);
+}
+
+int main(int argc, char *argv[])
+{
+ pthread_t threads[NUM_THREADS];
+ int rc;
+ long t;
+ for(t=0;t<NUM_THREADS;t++){
+ rc = pthread_create(&threads[t], NULL, foo, 0);
+ if (rc){
+ return 1;
+ }
+ }
+
+ int retval;
+ for(t=0;t<NUM_THREADS;t++)
+ pthread_join (threads[t], (void**)&retval);
+
+ return buffer[10];
+}