From patchwork Thu Dec 27 00:37:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geunsik Lim X-Patchwork-Id: 208246 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 27F582C00BE for ; Thu, 27 Dec 2012 11:38:56 +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=1357173537; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: From:To:Cc:Subject:Date:Message-Id:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=KpcmazkY9t1Z/cjsK4OPTHQJIXA=; b=VHgtSfpFLMoRn5w 2phDImonojuIn8Xkc6vtTW1rLbur8FKnUxgkNaWfGGfw8l9ghqm0wC8nb2b7mKzx 4Sc4wjBEWYfmmbN04W3OHPgzWFFXJtFe9e25Gl0LROyflPefeyInTcaz2FV6phMX XoGDnq5BnUnex4bnjiAnOUNOYjM8= 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-Received:Received:From:To:Cc:Subject:Date:Message-Id:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=dGgDltiEkQQFWUwmmxO4KVDDdwIuvoD5C9axyPX97MVxuPY06hIg+CwDcKMfsH xlX2tyr7t48CagSQUmx02JzwGiX6kxSphJ0pPbieYBljTeBCSl5ZZNQtNxgCRr8I rPDN8/AQ0TNgCFRh+aIGp+SdqlIXm4/fg9XambCe+k4hQ=; Received: (qmail 32358 invoked by alias); 27 Dec 2012 00:38:48 -0000 Received: (qmail 32207 invoked by uid 22791); 27 Dec 2012 00:38:44 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-pb0-f53.google.com (HELO mail-pb0-f53.google.com) (209.85.160.53) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Dec 2012 00:38:32 +0000 Received: by mail-pb0-f53.google.com with SMTP id jt11so5019530pbb.12 for ; Wed, 26 Dec 2012 16:38:31 -0800 (PST) X-Received: by 10.66.81.68 with SMTP id y4mr85139083pax.66.1356568711657; Wed, 26 Dec 2012 16:38:31 -0800 (PST) Received: from invain.dnip.net ([115.137.19.99]) by mx.google.com with ESMTPS id n10sm6688499pav.18.2012.12.26.16.38.28 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 26 Dec 2012 16:38:30 -0800 (PST) From: Geunsik Lim To: gcc-patch Cc: Tobias Burnus , Jakub Jelinek Subject: [PATCH] Support OpenMP for task parallelism on Android-ICS/GCC-4.6.3 Date: Thu, 27 Dec 2012 09:37:49 +0900 Message-Id: <1356568669-3612-1-git-send-email-geunsik.lim@gmail.com> 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 From: Geunsik Lim The patch supports OpenMP library to parallelize the existing C/C++ code rapidly/easily without any modification of android platform on multicore embedded devices. The original patch is made by Keith Obenschain (using GCC 4.4.3). . Archive - https://android-review.googlesource.com/#/c/34491/ I just moved GCC version from 4.4.3 to 4.6.3 for ktoolchain ver 2.5. The patch is good to me when I evaluate a lot of C/C++ source code with OpenMP's #parama. Please, refer to the "kandroid toolchain" menu in www.kandroid.org to compile source code including bionic and openmp library on real Android devices. http://kandroid.org/board/board.php?board=toolchain&command=body&no=16 I tested Openmp library with the latest GCC 4.6.3 on Android/ARM devices as following. Please refer to the below example. geunsik@rhel6$> ./arm-linux-androideabi-gcc openmptest.c -L /usr/local/ktoolchain-cortexa9-ver2.5-20120515-bionic/arm-linux-androideabi/lib -lgomp -o openmptest [ENTER] geunsik@rhel6$> geunsik@rhel6$> geunsik@rhel6$> file ./openmptest ./openmptest: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped Signed-off-by: Geunsik Lim Acked-by: Geunsik Lim --- gcc/config/arm/linux-eabi.h | 2 +- gcc/config/linux-android.h | 3 ++- libgomp/configure | 52 ++++++++++++++++++++++++++++++++++++++++++- libgomp/configure.ac | 9 +++++++- libgomp/env.c | 1 + 5 files changed, 63 insertions(+), 4 deletions(-) diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h index 8330052..c3e632c 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -82,7 +82,7 @@ #undef LIB_SPEC #define LIB_SPEC \ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LIB_SPEC, \ - GNU_USER_TARGET_LIB_SPEC " " ANDROID_LIB_SPEC) + ANDROID_LIB_SPEC " " GNU_USER_TARGET_LIB_SPEC ) #undef STARTFILE_SPEC #define STARTFILE_SPEC \ diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h index 94c5274..b1a9021 100644 --- a/gcc/config/linux-android.h +++ b/gcc/config/linux-android.h @@ -50,7 +50,8 @@ "%{!frtti:%{!fno-rtti: -fno-rtti}}" #define ANDROID_LIB_SPEC \ - "%{!static: -ldl}" + "%{!static: -ldl}" \ + "%{pthread:-lc}" #define ANDROID_STARTFILE_SPEC \ "%{!shared:" \ diff --git a/libgomp/configure b/libgomp/configure index 6f25c6f..3d8ce6b 100755 --- a/libgomp/configure +++ b/libgomp/configure @@ -15015,7 +15015,54 @@ _ACEOF if ac_fn_c_try_link "$LINENO"; then : XPCFLAGS=" -Wc,-pthread" else - CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +CFLAGS="$save_CFLAGS" LIBS="$LIBS" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + void *g(void *d) { return NULL; } +int +main () +{ +pthread_t t; pthread_create(&t,NULL,g,NULL); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" + || test ! -s conftest.err' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -15038,6 +15085,9 @@ rm -f core conftest.err conftest.$ac_objext \ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext # Check for functions needed. for ac_func in getloadavg clock_gettime strtoull diff --git a/libgomp/configure.ac b/libgomp/configure.ac index d87ed29..292db2a 100644 --- a/libgomp/configure.ac +++ b/libgomp/configure.ac @@ -184,6 +184,13 @@ AC_LINK_IFELSE( void *g(void *d) { return NULL; }], [pthread_t t; pthread_create(&t,NULL,g,NULL);])], [XPCFLAGS=" -Wc,-pthread"], + [CFLAGS="$save_CFLAGS" LIBS="$LIBS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [#include + void *g(void *d) { return NULL; }], + [pthread_t t; pthread_create(&t,NULL,g,NULL);])], + [], [CFLAGS="$save_CFLAGS" LIBS="-lpthread $LIBS" AC_LINK_IFELSE( [AC_LANG_PROGRAM( @@ -191,7 +198,7 @@ AC_LINK_IFELSE( void *g(void *d) { return NULL; }], [pthread_t t; pthread_create(&t,NULL,g,NULL);])], [], - [AC_MSG_ERROR([Pthreads are required to build libgomp])])]) + [AC_MSG_ERROR([Pthreads are required to build libgomp])])])]) # Check for functions needed. AC_CHECK_FUNCS(getloadavg clock_gettime strtoull) diff --git a/libgomp/env.c b/libgomp/env.c index 92fa8c3..8b1e29e 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -44,6 +44,7 @@ #endif #include #include +#include #ifndef HAVE_STRTOULL # define strtoull(ptr, eptr, base) strtoul (ptr, eptr, base)