From patchwork Wed Mar 13 23:30:23 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Iyer, Balaji V" X-Patchwork-Id: 227390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 18F5D2C0097 for ; Thu, 14 Mar 2013 10:30:36 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1363822237; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:Content-Type: MIME-Version:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=Y6U5AU0 qF5eU8vcQe8B8vKnmEZY=; b=x6kGhn8/bh+vHOUcYy/VygAMYku8DRtUrV9mako 6tqulTgFDLOKgvm4c7la4TGHyaRgR4gQ+ZyDmwGRaQ1VVbm7wyk4g843l0/Ql6xo 1iK9HGEJCjUjPhsHrIe7sBDln2ADRZzkT4LpiPL00a+OpSmTkkq0+iG3DttufPbG 1A7Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Received:From:To:Subject:Date:Message-ID:Content-Type:MIME-Version:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=NngO0Lw11AWfEubAFLyGZ2IiUnneSdd5D0GzuXei8mHcoYQGWqjh0JyMcJP6Hx Xecs5AmvsP6s0CVs7AtNMtJXWk1K0NIjpysEU8PAxYcb2fBQd9V59xmvHANT7vhT riJEEaQ2llvtyuP3KdsMC/OXgJNrvTEZvXUe417Y/7rIM=; Received: (qmail 21766 invoked by alias); 13 Mar 2013 23:30:31 -0000 Received: (qmail 21756 invoked by uid 22791); 13 Mar 2013 23:30:30 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, KAM_STOCKTIP, KHOP_RCVD_UNTRUST, KHOP_SPAMHAUS_DROP, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga01.intel.com (HELO mga01.intel.com) (192.55.52.88) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Mar 2013 23:30:25 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 13 Mar 2013 16:30:24 -0700 X-ExtLoop1: 1 Received: from fmsmsx105.amr.corp.intel.com ([10.19.9.36]) by fmsmga002.fm.intel.com with ESMTP; 13 Mar 2013 16:30:24 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.19.17.221) by FMSMSX105.amr.corp.intel.com (10.19.9.36) with Microsoft SMTP Server (TLS) id 14.1.355.2; Wed, 13 Mar 2013 16:30:24 -0700 Received: from fmsmsx102.amr.corp.intel.com ([169.254.2.241]) by fmsmsx152.amr.corp.intel.com ([169.254.7.15]) with mapi id 14.01.0355.002; Wed, 13 Mar 2013 16:30:23 -0700 From: "Iyer, Balaji V" To: "gcc-patches@gcc.gnu.org" Subject: [PATCH][Cilkplus] Build Cilk Runtime for non x86. Date: Wed, 13 Mar 2013 23:30:23 +0000 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hello Everyone, This attached patch is for the Cilk Plus branch affecting the Cilk Runtime. This patch should potentially allow the Cilk runtime library build for non-x86 targets. We have tested this on ARM (trimslice machine) and it seem to work on our test case. We encourage all the GCC target developers to help us expand Cilk on other targets. Thanks, Balaji V. Iyer. Index: libcilkrts/runtime/sysdep-unix.c =================================================================== --- libcilkrts/runtime/sysdep-unix.c (revision 196638) +++ libcilkrts/runtime/sysdep-unix.c (working copy) @@ -309,11 +309,15 @@ void __cilkrts_stop_workers(global_state_t *g) * spawn. This should be called each time a frame is resumed. */ static inline void restore_fp_state (__cilkrts_stack_frame *sf) { +#if defined __i386__ || defined __x86_64 __asm__ ( "ldmxcsr %0\n\t" "fnclex\n\t" "fldcw %1" : : "m" (sf->mxcsr), "m" (sf->fpcsr)); +#else +# warning "unimplemented: code to restore the floating point state" +#endif } /* Resume user code after a spawn or sync, possibly on a different stack. Index: libcilkrts/runtime/os-unix.c =================================================================== --- libcilkrts/runtime/os-unix.c (revision 196638) +++ libcilkrts/runtime/os-unix.c (working copy) @@ -344,7 +344,8 @@ COMMON_SYSDEP unsigned long long __cilkrts_gettick __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); return ((unsigned long long)a) | (((unsigned long long)d) << 32); #else -# error "unimplemented cycle counter" +# warning "unimplemented cycle counter" + return 0; #endif } @@ -359,7 +360,7 @@ COMMON_SYSDEP void __cilkrts_short_pause(void) #elif defined __i386__ || defined __x86_64 __asm__("pause"); #else -# error __cilkrts_short_pause undefined +# warning __cilkrts_short_pause undefined #endif } @@ -369,7 +370,7 @@ COMMON_SYSDEP int __cilkrts_xchg(volatile int *ptr /* asm statement here works around icc bugs */ __asm__("xchgl %0,%a1" :"=r" (x) : "r" (ptr), "0" (x) :"memory"); #else -# error __cilkrts_xchg undefined + x = __sync_lock_test_and_set(ptr, x); #endif return x; } Index: libcilkrts/ChangeLog.cilkplus =================================================================== --- libcilkrts/ChangeLog.cilkplus (revision 196638) +++ libcilkrts/ChangeLog.cilkplus (working copy) @@ -1,3 +1,13 @@ +2013-03-13 Balaji V. Iyer + + * runtime/sysdep-unix.c (__cilkrts_stop_workers): Inserted inline + assembly inside a #if which is only invoked when compiled for i386. + Otherwise, output a warning. + * runtime/os-unix.c (__cilkrts_gettick): Replaced #error with #warning. + (__cilkrts_short_pause): Likewise. + (__cilkrts_xchg): Likewise. + + 2013-02-05 Balaji V. Iyer * Makefile.in (am_libcilkrts_la_OBJECTS): Removed symbol_test. Index: configure =================================================================== --- configure (revision 196638) +++ configure (working copy) @@ -3159,17 +3159,6 @@ if test x$enable_libgomp = x ; then esac fi -# Disable libcilkrts on non x86 machines... for now. -if test x$enable_libcilkrts = x ; then - # Enable libcilkrts by default on x86 machines. - case "${target}" in - i[3456789]86-*-* | x86_64-*-*) - ;; - *) - noconfigdirs="$noconfigdirs target-libcilkrts" - esac -fi - # Disable libatomic on unsupported systems. if test -d ${srcdir}/libatomic; then if test x$enable_libatomic = x; then Index: ChangeLog.cilkplus =================================================================== --- ChangeLog.cilkplus (revision 0) +++ ChangeLog.cilkplus (revision 0) @@ -0,0 +1,4 @@ +2013-03-13 Balaji V. Iyer + + * configure.ac (enable_libcilkrts): Made libcilkrts unconditional. + * configure (enable_libcilkrts): Likewise. Index: configure.ac =================================================================== --- configure.ac (revision 196638) +++ configure.ac (working copy) @@ -507,17 +507,6 @@ if test x$enable_libgomp = x ; then esac fi -# Disable libcilkrts on non x86 machines... for now. -if test x$enable_libcilkrts = x ; then - # Enable libcilkrts by default on x86 machines. - case "${target}" in - i[3456789]86-*-* | x86_64-*-*) - ;; - *) - noconfigdirs="$noconfigdirs target-libcilkrts" - esac -fi - # Disable libatomic on unsupported systems. if test -d ${srcdir}/libatomic; then if test x$enable_libatomic = x; then