From patchwork Mon Mar 3 04:53:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 25595 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f69.google.com (mail-pa0-f69.google.com [209.85.220.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 68E7120E7C for ; Mon, 3 Mar 2014 08:07:33 +0000 (UTC) Received: by mail-pa0-f69.google.com with SMTP id hz1sf2094738pad.4 for ; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe:content-type; bh=/GjPi6VZuhk0rsi8JLTbFqe9pdqQ7wvj/IiNKe044+s=; b=U8VvDf4FkhPk+e1tSQqO49t/5Azgb8wu0fSe6P4HqUOG2QRRSAleM+f8c2mSnWwq3Y jmRkzyDiXSnA8Zdg945/R48utbysmD556qUrBkH3MyWREYLQ6bNu5D0hSyFmfwvZdRwT cC4vamnxLK33JSi/Qeukrr79pbEcRYRS87Q22bWveXxVlmSP5lALwiTgf4B85EfOoLBl 49mDd5i4Acv38KMyn2q3oOm/kDGvtxaanLFp2a0WliRlXgoUnNH2XrOWNdLsTIa6ZCPN NDZEPwTfHgu03SanF8Ho4BdUd4lvkIkZrITr1RyyU3m2g8F/5jCaZ0UpbrjIV5H0J2oL osIg== X-Gm-Message-State: ALoCoQntWHqRVS/xseHCb8z/mj04flAGkD9dhhtDkguuMHGEh5hKWP68BFBYZ1LmA5bDuYzkWq5Q X-Received: by 10.66.142.131 with SMTP id rw3mr7445166pab.18.1393834052626; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-BeenThere: lng-odp@linaro.org Received: by 10.140.25.33 with SMTP id 30ls2004571qgs.22.gmail; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-Received: by 10.236.111.73 with SMTP id v49mr6265003yhg.46.1393834052522; Mon, 03 Mar 2014 00:07:32 -0800 (PST) Received: by 10.224.156.133 with SMTP id x5msqaw; Sun, 2 Mar 2014 20:53:42 -0800 (PST) X-Received: by 10.224.66.8 with SMTP id l8mr20878557qai.16.1393822422066; Sun, 02 Mar 2014 20:53:42 -0800 (PST) Received: from mail-qa0-f43.google.com (mail-qa0-f43.google.com [209.85.216.43]) by mx.google.com with ESMTPS id u90si5300964qge.3.2014.03.02.20.53.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 20:53:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.216.43 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) client-ip=209.85.216.43; Received: by mail-qa0-f43.google.com with SMTP id j15so2417864qaq.16 for ; Sun, 02 Mar 2014 20:53:42 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.229.119.73 with SMTP id y9mr20807582qcq.18.1393822421947; Sun, 02 Mar 2014 20:53:41 -0800 (PST) Received: by 10.229.219.134 with HTTP; Sun, 2 Mar 2014 20:53:41 -0800 (PST) Date: Mon, 3 Mar 2014 12:53:41 +0800 Message-ID: Subject: [lng-odp] [ODP/PATCH 1/1] Compile ODP for PowerPC platforms From: Alexandru Badicioiu To: "LNG ODP Sub-team - lng-odp@linaro.org" X-Original-Sender: alexandru.badicioiu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.216.43 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) smtp.mail=alexandru.badicioiu@linaro.org Precedence: list Mailing-list: list lng-odp@linaro.org; contact lng-odp+owners@linaro.org List-ID: X-Google-Group-Id: 474323889996 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Alexandru Badicioiu - define cache line size - fallback to 32bit atomics on 32bit platforms - enable hugetlb mappings - fix compilation errors when hugetlb mappings are not used - cpuinfo parser Signed-off-by: Alexandru Badicioiu --- include/odp_align.h | 4 ++ include/odp_atomic.h | 21 ++++++++- platform/linux-generic/source/odp_shared_memory.c | 5 ++- platform/linux-generic/source/odp_system_info.c | 50 ++++++++++++++++++++- 4 files changed, 75 insertions(+), 5 deletions(-) #error GCC target not found @@ -231,13 +272,18 @@ static odp_compiler_info_t compiler_info = { .cpu_arch_str = "octeon", .cpuinfo_parser = cpuinfo_octeon + #elif defined __powerpc__ + .cpu_arch_str = "powerpc", + .cpuinfo_parser = cpuinfo_powerpc + #else #error GCC target not found #endif }; -#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ +#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ +defined __powerpc__ /* * Analysis of /sys/devices/system/cpu/ files -- 1.7.3.4 diff --git a/include/odp_align.h b/include/odp_align.h index 0f0c614..67a7cdc 100644 --- a/include/odp_align.h +++ b/include/odp_align.h @@ -42,6 +42,10 @@ extern "C" { #define ODP_CACHE_LINE_SIZE 128 +#elif defined __powerpc__ + +#define ODP_CACHE_LINE_SIZE 64 + #else #error GCC target not found #endif diff --git a/include/odp_atomic.h b/include/odp_atomic.h index 3a8a18d..763436a 100644 --- a/include/odp_atomic.h +++ b/include/odp_atomic.h @@ -353,12 +353,21 @@ static inline void odp_atomic_add_u64(odp_atomic_u64_t *ptr, uint64_t value) * * @return Value of the variable before the operation */ + +#if defined __powerpc__ && !defined __powerpc64__ +static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr, + uint64_t value) +{ + return __sync_fetch_and_add((odp_atomic_u32_t *)ptr, + (uint32_t)value); +} +#else static inline uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *ptr, uint64_t value) { return __sync_fetch_and_add(ptr, value); } - +#endif /** * Subtract atomic uint64 * @@ -379,12 +388,20 @@ static inline void odp_atomic_sub_u64(odp_atomic_u64_t *ptr, uint64_t value) * * @return Value of the variable before the operation */ +#if defined __powerpc__ && !defined __powerpc64__ +static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr, + uint64_t value) +{ + return __sync_fetch_and_sub((odp_atomic_u32_t *)ptr, + (uint32_t)value); +} +#else static inline uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *ptr, uint64_t value) { return __sync_fetch_and_sub(ptr, value); } - +#endif /** * Fetch and increment atomic uint64 by 1 * diff --git a/platform/linux-generic/source/odp_shared_memory.c b/platform/linux-generic/source/odp_shared_memory.c index ef4bfcd..b4ec87c 100644 --- a/platform/linux-generic/source/odp_shared_memory.c +++ b/platform/linux-generic/source/odp_shared_memory.c @@ -13,6 +13,9 @@ #include #include +#ifdef __powerpc__ +#include +#endif #include #include @@ -97,7 +100,7 @@ void *odp_shm_reserve(const char *name, uint64_t size, uint64_t align) int i; odp_shm_block_t *block; void *addr; - uint64_t huge_sz, page_sz; + uint64_t huge_sz ODP_UNUSED, page_sz ODP_UNUSED; huge_sz = odp_sys_huge_page_size(); page_sz = odp_sys_page_size(); diff --git a/platform/linux-generic/source/odp_system_info.c b/platform/linux-generic/source/odp_system_info.c index 43129db..17617b0 100644 --- a/platform/linux-generic/source/odp_system_info.c +++ b/platform/linux-generic/source/odp_system_info.c @@ -60,7 +60,8 @@ static int sysconf_core_count(void) } -#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ +#if defined __x86_64__ || defined __i386__ || defined __OCTEON__ || \ +defined __powerpc__ /* * Analysis of /sys/devices/system/cpu/ files */ @@ -213,6 +214,46 @@ static int cpuinfo_octeon(FILE *file, odp_system_info_t *sysinfo) return 0; } +#elif defined __powerpc__ +static int cpuinfo_powerpc(FILE *file, odp_system_info_t *sysinfo) +{ + char str[1024]; + char *pos; + double mhz = 0.0; + int model = 0; + int count = 2; + + while (fgets(str, sizeof(str), file) != NULL && count > 0) { + if (!mhz) { + pos = strstr(str, "clock"); + + if (pos) { + sscanf(pos, "clock : %lf", &mhz); + count--; + } + } + + if (!model) { + pos = strstr(str, "cpu"); + + if (pos) { + int len; + pos = strchr(str, ':'); + strncpy(sysinfo->model_str, pos+2, + sizeof(sysinfo->model_str)); + len = strlen(sysinfo->model_str); + sysinfo->model_str[len - 1] = 0; + model = 1; + count--; + } + } + + sysinfo->cpu_hz = (uint64_t) (mhz * 1000000.0); + } + + + return 0; +} #else