From: Thomas Schwinge <thomas@codesourcery.com>
To: "Iyer, Balaji V" <balaji.v.iyer@intel.com>,
<barry.m.tannenbaum@intel.com>, <igor.zamyatin@intel.com>
Cc: <gcc-patches@gcc.gnu.org>
Subject: libcilkrts: GNU Hurd port, and some code cleanup/consolidation (was: Cilk Library)
Date: Mon, 29 Sep 2014 18:14:00 -0000 [thread overview]
Message-ID: <87y4t2cn13.fsf@kepler.schwinge.homeip.net> (raw)
In-Reply-To: <BF230D13CA30DD48930C31D4099330003A48660C@FMSMSX101.amr.corp.intel.com>
[-- Attachment #1: Type: text/plain, Size: 5051 bytes --]
Hi!
On Wed, 9 Oct 2013 18:32:11 +0000, "Iyer, Balaji V" <balaji.v.iyer@intel.com> wrote:
> [libcilkrts]
Currently, by means of the libcilkrts/configure.tgt file that has been
added during patch review, libcilkrts is attempted to be built for all
*-*-gnu* system, but it has actually only been ported to GNU/Linux. This
is Debian bug <http://bugs.debian.org/734973>. Here is a basic GNU Hurd
port, and some code cleanup/consolidation. Tested on x86 GNU/Hurd, and
x86_64 GNU/Linux is in progress. OK for trunk once testing completed?
commit ca8d437e22c659aa6a8d2d57afd9e3944f9b33ce
Author: Thomas Schwinge <thomas@codesourcery.com>
Date: Sun Sep 21 20:35:49 2014 +0200
libcilkrts: GNU Hurd port, and some code cleanup/consolidation.
libcilkrts/
* runtime/cilk_malloc.c: Consider __GLIBC__ next to __linux__.
* runtime/os-unix.c: Basic port for __GNU__. Apply some code
cleanup/consolidation.
---
libcilkrts/runtime/cilk_malloc.c | 2 +-
libcilkrts/runtime/os-unix.c | 45 +++++++++++++++++++---------------------
2 files changed, 22 insertions(+), 25 deletions(-)
diff --git libcilkrts/runtime/cilk_malloc.c libcilkrts/runtime/cilk_malloc.c
index 9d02c52..d3de756 100644
--- libcilkrts/runtime/cilk_malloc.c
+++ libcilkrts/runtime/cilk_malloc.c
@@ -39,7 +39,7 @@
#include "cilk_malloc.h"
#include <stdlib.h>
-#if defined _WIN32 || defined _WIN64 || defined __linux__
+#if defined _WIN32 || defined _WIN64 || defined __GLIBC__ || defined __linux__
#include <malloc.h>
#define HAS_MEMALIGN 1
#endif
diff --git libcilkrts/runtime/os-unix.c libcilkrts/runtime/os-unix.c
index 229c438..70acb14 100644
--- libcilkrts/runtime/os-unix.c
+++ libcilkrts/runtime/os-unix.c
@@ -47,12 +47,6 @@
#elif defined __APPLE__
# include <sys/sysctl.h>
// Uses sysconf(_SC_NPROCESSORS_ONLN) in verbose output
-#elif defined __DragonFly__
-// No additional include files
-#elif defined __FreeBSD__
-// No additional include files
-#elif defined __CYGWIN__
-// Cygwin on Windows - no additional include files
#elif defined __VXWORKS__
# include <vxWorks.h>
# include <vxCpuLib.h>
@@ -60,6 +54,9 @@
// Solaris
#elif defined __sun__ && defined __svr4__
# include <sched.h>
+#elif defined __CYGWIN__ || defined __DragonFly__ || defined __FreeBSD__ \
+ || defined __GNU__
+// No additional include files.
#else
# error "Unsupported OS"
#endif
@@ -349,7 +346,12 @@ static int linux_get_affinity_count (int tid)
COMMON_SYSDEP int __cilkrts_hardware_cpu_count(void)
{
-#if defined __ANDROID__ || (defined(__sun__) && defined(__svr4__))
+#if defined __ANDROID__ \
+ || defined __CYGWIN__ \
+ || defined __DragonFly__ \
+ || defined __FreeBSD__ \
+ || defined __GNU__ \
+ || (defined (__sun__) && defined (__svr4__))
return sysconf (_SC_NPROCESSORS_ONLN);
#elif defined __MIC__
/// HACK: Usually, the 3rd and 4th hyperthreads are not beneficial
@@ -369,16 +371,10 @@ COMMON_SYSDEP int __cilkrts_hardware_cpu_count(void)
assert((unsigned)count == count);
return count;
-#elif defined __FreeBSD__ || defined __CYGWIN__ || defined __DragonFly__
- int ncores = sysconf(_SC_NPROCESSORS_ONLN);
-
- return ncores;
- // Just get the number of processors
-// return sysconf(_SC_NPROCESSORS_ONLN);
#elif defined __VXWORKS__
return __builtin_popcount( vxCpuEnabledGet() );
#else
-#error "Unknown architecture"
+# error "Unsupported architecture"
#endif
}
@@ -393,13 +389,16 @@ COMMON_SYSDEP void __cilkrts_sleep(void)
COMMON_SYSDEP void __cilkrts_yield(void)
{
-#if __APPLE__ || __FreeBSD__ || __VXWORKS__
- // On MacOS, call sched_yield to yield quantum. I'm not sure why we
+#if defined (__ANDROID__) \
+ || __APPLE__ \
+ || defined (__DragonFly__) \
+ || __FreeBSD__ \
+ || defined (__GNU__) \
+ || (defined (__sun__) && defined (__svr4__)) \
+ || __VXWORKS__
+ // Call sched_yield to yield quantum. I'm not sure why we
// don't do this on Linux also.
sched_yield();
-#elif defined(__DragonFly__)
- // On DragonFly BSD, call sched_yield to yield quantum.
- sched_yield();
#elif defined(__MIC__)
// On MIC, pthread_yield() really trashes things. Arch's measurements
// showed that calling _mm_delay_32() (or doing nothing) was a better
@@ -407,14 +406,12 @@ COMMON_SYSDEP void __cilkrts_yield(void)
// giving up the processor and latency starting up when work becomes
// available
_mm_delay_32(1024);
-#elif defined(__ANDROID__) || (defined(__sun__) && defined(__svr4__))
- // On Android and Solaris, call sched_yield to yield quantum. I'm not
- // sure why we don't do this on Linux also.
- sched_yield();
-#else
+#elif defined __linux__
// On Linux, call pthread_yield (which in turn will call sched_yield)
// to yield quantum.
pthread_yield();
+#else
+# error "Unsupported architecture"
#endif
}
Grüße,
Thomas
[-- Attachment #2: Type: application/pgp-signature, Size: 472 bytes --]
next prev parent reply other threads:[~2014-09-29 18:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BF230D13CA30DD48930C31D4099330003A47B9F3@FMSMSX101.amr.corp.intel.com>
[not found] ` <525460A9.2040409@redhat.com>
[not found] ` <BF230D13CA30DD48930C31D4099330003A48660C@FMSMSX101.amr.corp.intel.com>
2013-11-07 13:36 ` Cilk Library Thomas Schwinge
2013-11-07 17:32 ` Jeff Law
2013-11-07 23:35 ` Iyer, Balaji V
2013-11-08 9:03 ` Thomas Schwinge
2014-09-29 18:13 ` libcilkrts: Remove unused function __cilkrts_sysdep_is_worker_thread_id (was: Cilk Library) Thomas Schwinge
2014-09-29 18:26 ` Tannenbaum, Barry M
2014-09-29 21:00 ` libcilkrts: Remove unused function __cilkrts_sysdep_is_worker_thread_id Jeff Law
2014-09-29 21:06 ` Thomas Schwinge
2014-09-29 18:13 ` libcilkrts: Use AC_USE_SYSTEM_EXTENSIONS (was: Cilk Library) Thomas Schwinge
2014-10-01 14:02 ` Thomas Schwinge
2014-10-01 14:10 ` Tannenbaum, Barry M
2014-09-29 18:14 ` Thomas Schwinge [this message]
2014-09-29 18:14 ` libcilkrts: GNU toolchain, GNU linker scripts " Thomas Schwinge
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=87y4t2cn13.fsf@kepler.schwinge.homeip.net \
--to=thomas@codesourcery.com \
--cc=balaji.v.iyer@intel.com \
--cc=barry.m.tannenbaum@intel.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=igor.zamyatin@intel.com \
/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: link
Be 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).