From patchwork Mon Mar 3 05:05:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Badicioiu X-Patchwork-Id: 25593 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 12A5520540 for ; Mon, 3 Mar 2014 08:07:32 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp18sf20788318obc.8 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=fUGNH95NDHJpNQkWkLNU9TvBNwQ5ovknWuVWQ2Ou0g4=; b=JEl9CfeBEka65p6i0fIkZEaasGOY9EU9zVAjRfLJGaL1o8bMUHFwQeTS+ALskUHB29 lOHaLkg8N1RTMIvWg1ImPuTe+EQI1MOeNcH/CgOHoPtdCjdy18+YEkg942RYU0FQZNb4 5QEwaFWKbxdKVL5Hw6+9E+Z3m19pzfjGqqa8tQJYQWuyOckLheW5MqerY4SIftNnDUmW TmslVflvWogwAifvgLEqBegEmZ06Iy18Y0wKlgKCflwqYRCQeJaBRSkOl0MIegaqeRq5 O71/9IIFscFOEtXr+p05vvhYZjYIYM9IEPSb2sphBbN+QTp3CS5GK0YmJ7MpQ+mmXoCj mNpg== X-Gm-Message-State: ALoCoQmcHclxmkSxqMOcCUQ0LCKWeUZJp987pXhl3Z9X3N+ct41Zy3v1ODa/DPMJ7o1rLg613KyS X-Received: by 10.182.29.196 with SMTP id m4mr12815662obh.26.1393834052652; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-BeenThere: lng-odp@linaro.org Received: by 10.140.22.139 with SMTP id 11ls1997147qgn.84.gmail; Mon, 03 Mar 2014 00:07:32 -0800 (PST) X-Received: by 10.236.98.104 with SMTP id u68mr6176493yhf.1.1393834052523; Mon, 03 Mar 2014 00:07:32 -0800 (PST) Received: by 10.224.156.133 with SMTP id x5msqaw; Sun, 2 Mar 2014 21:05:09 -0800 (PST) X-Received: by 10.140.44.33 with SMTP id f30mr20062702qga.31.1393823108998; Sun, 02 Mar 2014 21:05:08 -0800 (PST) Received: from mail-qg0-f48.google.com (mail-qg0-f48.google.com [209.85.192.48]) by mx.google.com with ESMTPS id b79si5282682qge.179.2014.03.02.21.05.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 02 Mar 2014 21:05:08 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.48 is neither permitted nor denied by best guess record for domain of alexandru.badicioiu@linaro.org) client-ip=209.85.192.48; Received: by mail-qg0-f48.google.com with SMTP id a108so10061706qge.7 for ; Sun, 02 Mar 2014 21:05:08 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.5.136 with SMTP id 8mr21093739qav.42.1393823108857; Sun, 02 Mar 2014 21:05:08 -0800 (PST) Received: by 10.229.219.134 with HTTP; Sun, 2 Mar 2014 21:05:08 -0800 (PST) Date: Mon, 3 Mar 2014 13:05:08 +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.192.48 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