public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53292] multi-threaded (OpenMP) is slower than single-threaded Date: Wed, 09 May 2012 15:02:00 -0000 [thread overview] Message-ID: <bug-53292-4-PwbuQWcsV1@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-53292-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53292 --- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> 2012-05-09 15:01:24 UTC --- Just try equivalent pthread program and you'll note the same behavior. #include <pthread.h> #include <stdlib.h> double *p; int c; void *tf (void *x) { int i, s = ((long) x) * c, e = s + c; for (i = s; i < e; i++) p[i] = 1.0; return NULL; } int main (int argc, char **argv) { int n = atoi (argv[1]), i; int sz = atoi (argv[2]); if (n > 32 || n < 1 || sz < 128 || (sz % n) != 0) return 1; p = malloc (sz * sizeof (double)); if (p == NULL) return 1; c = sz / n; pthread_t t[32]; for (i = 1; i < n; i++) pthread_create (&t[i], NULL, tf, (void *)(long) i); tf ((void *) 0L); for (i = 1; i < n; i++) pthread_join (t[i], NULL); return 0; }
next prev parent reply other threads:[~2012-05-09 15:01 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-05-09 8:18 [Bug c++/53292] New: " fh_p at hotmail dot com 2012-05-09 9:23 ` [Bug c++/53292] " fh_p at hotmail dot com 2012-05-09 10:37 ` fh_p at hotmail dot com 2012-05-09 12:20 ` jakub at gcc dot gnu.org 2012-05-09 12:56 ` fh_p at hotmail dot com 2012-05-09 13:00 ` fh_p at hotmail dot com 2012-05-09 13:33 ` jakub at gcc dot gnu.org 2012-05-09 14:48 ` fh_p at hotmail dot com 2012-05-09 15:02 ` jakub at gcc dot gnu.org [this message] 2012-05-12 21:35 ` fh_p at hotmail dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-53292-4-PwbuQWcsV1@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).