From patchwork Tue Oct 5 08:54:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Shawcroft X-Patchwork-Id: 66772 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 8D8BCB6F07 for ; Tue, 5 Oct 2010 19:54:51 +1100 (EST) Received: (qmail 1118 invoked by alias); 5 Oct 2010 08:54:49 -0000 Received: (qmail 1100 invoked by uid 22791); 5 Oct 2010 08:54:47 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_00, MIME_QP_LONG_LINE, MSGID_MULTIPLE_AT, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cam-admin0.cambridge.arm.com (HELO cam-admin0.cambridge.arm.com) (217.140.96.50) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 05 Oct 2010 08:54:38 +0000 Received: from cam-owa2.Emea.Arm.com (cam-owa2.emea.arm.com [10.1.105.18]) by cam-admin0.cambridge.arm.com (8.12.6/8.12.6) with ESMTP id o958p9F9011273 for ; Tue, 5 Oct 2010 09:51:09 +0100 (BST) Received: from e102573 ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 5 Oct 2010 09:54:34 +0100 From: "Marcus Shawcroft" To: References: In-Reply-To: Subject: [PATCH, LIBGOMP] Add ARM optimized futex support. Date: Tue, 5 Oct 2010 09:54:30 +0100 Message-ID: <000001cb646a$ecbcfab0$c636f010$@shawcroft@arm.com> MIME-Version: 1.0 x-cr-hashedpuzzle: BMGw Bay4 Bmuh CJ3Z CtLd C3L9 DELS DTt7 EupD GPxj Gswr GzCo G1t1 HPWG Hg0O ISsI; 1; ZwBjAGMALQBwAGEAdABjAGgAZQBzAEAAZwBjAGMALgBnAG4AdQAuAG8AcgBnAA==; Sosha1_v1; 7; {1C1DDAEF-DC0B-433B-981F-196F209B2293}; bQBhAHIAYwB1AHMALgBzAGgAYQB3AGMAcgBvAGYAdABAAGEAcgBtAC4AYwBvAG0A; Tue, 05 Oct 2010 08:54:27 GMT; WwBQAEEAVABDAEgALAAgAEwASQBCAEcATwBNAFAAXQAgAEEAZABkACAAQQBSAE0AIABvAHAAdABpAG0AaQB6AGUAZAAgAGYAdQB0AGUAeAAgAHMAdQBwAHAAbwByAHQALgA= x-cr-puzzleid: {1C1DDAEF-DC0B-433B-981F-196F209B2293} 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 The attached patch adds custom futex support to ARM libgomp. libgomp test suite run for arm and thumb variants, no regressions. /Marcus 2010-10-05 Marcus Shawcroft * config/linux/arm/futex.h: New. * config/linux/arm/mutex.h: New. * configure.tgt (arm*-*-linux*): Add config path. 2010-10-05 Marcus Shawcroft * config/linux/arm/futex.h: New. * config/linux/arm/mutex.h: New. * configure.tgt (arm*-*-linux*): Add config path. diff --git a/libgomp/config/linux/arm/futex.h b/libgomp/config/linux/arm/futex.h new file mode 100644 index 0000000..7324b78 --- /dev/null +++ b/libgomp/config/linux/arm/futex.h @@ -0,0 +1,75 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of the GNU OpenMP Library (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* Provide target-specific access to the futex system call. */ + +/* The include file hierachy above us (wait.h) has pushed visibility + hidden, this will be applied to prototypes with headers we include + with the effect that we cannot link against an external function + (syscall). The solution here is to push default visibility, include + our required headers then reinstante the original visibility. */ + +#pragma GCC visibility push(default) + +#define _GNU_SOURCE +#include +#include + +#pragma GCC visibility pop + +static inline void +futex_wait (int *addr, int val) +{ + long err = syscall (SYS_futex, addr, gomp_futex_wait, val); + if (__builtin_expect (err == -ENOSYS, 0)) + { + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; + syscall (SYS_futex, addr, gomp_futex_wait, val); + } +} + +static inline void +futex_wake (int *addr, int count) +{ + long err = syscall (SYS_futex, addr, gomp_futex_wake, count); + if (__builtin_expect (err == -ENOSYS, 0)) + { + gomp_futex_wait &= ~FUTEX_PRIVATE_FLAG; + gomp_futex_wake &= ~FUTEX_PRIVATE_FLAG; + syscall (SYS_futex, addr, gomp_futex_wake, count); + } +} + +static inline void +cpu_relax (void) +{ + __asm volatile ("" : : : "memory"); +} + +static inline void +atomic_write_barrier (void) +{ + __sync_synchronize (); +} diff --git a/libgomp/config/linux/arm/mutex.h b/libgomp/config/linux/arm/mutex.h new file mode 100644 index 0000000..30021d5 --- /dev/null +++ b/libgomp/config/linux/arm/mutex.h @@ -0,0 +1,28 @@ +/* Copyright (C) 2010 Free Software Foundation, Inc. + Contributed by ARM Ltd. + + This file is part of the GNU OpenMP Library (libgomp). + + Libgomp is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +/* ARM needs the same correct usage of __sync_synchronize and + __sync_lock_test_and_set as ia64. So we just use its mutex.h. */ + +#include "config/linux/ia64/mutex.h" diff --git a/libgomp/configure.tgt b/libgomp/configure.tgt index 16bb888..6ab9e4d 100644 --- a/libgomp/configure.tgt +++ b/libgomp/configure.tgt @@ -31,6 +31,10 @@ if test $enable_linux_futex = yes; then config_path="linux/alpha linux posix" ;; + arm*-*-linux*) + config_path="linux/arm linux posix" + ;; + ia64*-*-linux*) config_path="linux/ia64 linux posix" ;;