Message ID | 000901d014fd$106f85d0$314e9170$@com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 603746A95; Thu, 11 Dec 2014 05:44:22 +0100 (CET) Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3on0081.outbound.protection.outlook.com [157.55.234.81]) by dpdk.org (Postfix) with ESMTP id A7CA06A87 for <dev@dpdk.org>; Thu, 11 Dec 2014 05:44:15 +0100 (CET) Received: from zhigangTHINK (124.207.145.166) by DB4PR02MB0590.eurprd02.prod.outlook.com (10.242.223.149) with Microsoft SMTP Server (TLS) id 15.1.31.17; Thu, 11 Dec 2014 04:44:10 +0000 From: Tony Lu <zlu@ezchip.com> To: 'Neil Horman' <nhorman@tuxdriver.com> References: <1418029178-25162-1-git-send-email-zlu@ezchip.com> <1418029178-25162-15-git-send-email-zlu@ezchip.com> <20141209150321.GC28871@hmsreliant.think-freely.org> In-Reply-To: <20141209150321.GC28871@hmsreliant.think-freely.org> Date: Thu, 11 Dec 2014 12:43:36 +0800 Message-ID: <000901d014fd$106f85d0$314e9170$@com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook 12.0 Thread-Index: AdATwVbSTwWDT0v/Srewx5RpPnxsUgBOfQ0w Content-Language: zh-cn X-Originating-IP: [124.207.145.166] X-ClientProxiedBy: BLUPR11CA0051.namprd11.prod.outlook.com (10.141.30.19) To DB4PR02MB0590.eurprd02.prod.outlook.com (10.242.223.149) X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:DB4PR02MB0590; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601003); SRVR:DB4PR02MB0590; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(13464003)(199003)(377454003)(24454002)(51704005)(189002)(52604005)(40100003)(122386002)(84116002)(19580405001)(46102003)(89996001)(19580395003)(23726002)(46406003)(106356001)(87976001)(107046002)(120916001)(97736003)(2656002)(99396003)(105586002)(59696002)(92566001)(68736005)(50466002)(33716001)(77096005)(50986999)(76176999)(64706001)(86362001)(20776003)(66066001)(47776003)(33646002)(96836002)(110136001)(31966008)(101416001)(14726001)(61296003)(97756001)(42186005)(102836002)(50226001)(21056001)(77156002)(62966003)(4396001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB4PR02MB0590; H:zhigangTHINK; FPR:; SPF:None; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:; SRVR:DB4PR02MB0590; X-OriginatorOrg: ezchip.com Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag checks for tile architecture X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Zhigang Lu
Dec. 11, 2014, 4:43 a.m. UTC
>-----Original Message----- >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman >Sent: Tuesday, December 09, 2014 11:03 PM >To: Zhigang Lu >Cc: dev@dpdk.org >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag checks for tile >architecture > >On Mon, Dec 08, 2014 at 04:59:37PM +0800, Zhigang Lu wrote: >> Tile processor doesn't have CPU flag hardware registers, so this patch >> turns off cpu flag checks for tile. >> >> Signed-off-by: Zhigang Lu <zlu@ezchip.com> >> Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com> >> --- >> app/test/test_cpuflags.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c index >> 5aeba5d..da93af5 100644 >> --- a/app/test/test_cpuflags.c >> +++ b/app/test/test_cpuflags.c >> @@ -113,7 +113,7 @@ test_cpuflags(void) >> >> printf("Check for ICACHE_SNOOP:\t\t"); >> CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP); >> -#else >> +#elif !defined(RTE_ARCH_TILE) >> printf("Check for SSE:\t\t"); >> CHECK_FOR_FLAG(RTE_CPUFLAG_SSE); >> >Please stop this. It doesn't make sense for a library that supports multiple >arches, we need some way to generically test for flags that doesn't involve >forcing applications to do ton's of ifdeffing. Perhaps rte_cpu_get_flag_enabled >needs to do a flag table lookup based on the detected arch at run time, and >return the appropriate response. In the case of tile, it can just be an empty >table, so 0 is always returned. But making an application responsible for doing >arch checks is a guarantee to write non-portable applications > >Neil > Thanks for taking a look at this. This change just follows what PPC did in commit 9ae15538. The root cause is that the test_cpuflags.c explicitly tests X86-specific CPU flags, so we might need to revise this test case to make it architecture-independent. A alternative change to this test case is as follows.
Comments
On Thu, Dec 11, 2014 at 12:43:36PM +0800, Tony Lu wrote: > >-----Original Message----- > >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman > >Sent: Tuesday, December 09, 2014 11:03 PM > >To: Zhigang Lu > >Cc: dev@dpdk.org > >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag checks > for tile > >architecture > > > >On Mon, Dec 08, 2014 at 04:59:37PM +0800, Zhigang Lu wrote: > >> Tile processor doesn't have CPU flag hardware registers, so this patch > >> turns off cpu flag checks for tile. > >> > >> Signed-off-by: Zhigang Lu <zlu@ezchip.com> > >> Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com> > >> --- > >> app/test/test_cpuflags.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c index > >> 5aeba5d..da93af5 100644 > >> --- a/app/test/test_cpuflags.c > >> +++ b/app/test/test_cpuflags.c > >> @@ -113,7 +113,7 @@ test_cpuflags(void) > >> > >> printf("Check for ICACHE_SNOOP:\t\t"); > >> CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP); > >> -#else > >> +#elif !defined(RTE_ARCH_TILE) > >> printf("Check for SSE:\t\t"); > >> CHECK_FOR_FLAG(RTE_CPUFLAG_SSE); > >> > >Please stop this. It doesn't make sense for a library that supports > multiple > >arches, we need some way to generically test for flags that doesn't involve > >forcing applications to do ton's of ifdeffing. Perhaps > rte_cpu_get_flag_enabled > >needs to do a flag table lookup based on the detected arch at run time, and > >return the appropriate response. In the case of tile, it can just be an > empty > >table, so 0 is always returned. But making an application responsible for > doing > >arch checks is a guarantee to write non-portable applications > > > >Neil > > > > Thanks for taking a look at this. > This change just follows what PPC did in commit 9ae15538. The root cause is Yes, and I objected to it there as well: http://dpdk.org/ml/archives/dev/2014-November/008628.html To which the response was effectively "Sure, we'll do that later". You're effectively making the same argument. If no one ever steps up to change the interface when adding a new arch, it will never get done, and we'll have a fragmented cpuflag test mechanism that creates completely non-portable code accross arches. > that > the test_cpuflags.c explicitly tests X86-specific CPU flags, so we might > need to revise > this test case to make it architecture-independent. > Exactly what I said in my email to the powerpc people. If you're going to add a new arch, and a given interface doesn't support doing so, please try to re-design the interface to make it more friendly, otherwise we'll be left with unmaintainable code. Thinking about it, you probably don't even need to change the api call to do this. You just need to create a unified map for all flags of all supported arches, that is to say a two dimensional array with the indicies [arch][flag] where the stored value is the arch specific data to help determine if the feature is supported, or a universal "not supported" flag. Neil
>-----Original Message----- >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman >Sent: Thursday, December 11, 2014 9:39 PM >To: Tony Lu >Cc: dev@dpdk.org >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag checks for tile >architecture > >On Thu, Dec 11, 2014 at 12:43:36PM +0800, Tony Lu wrote: >> >-----Original Message----- >> >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman >> >Sent: Tuesday, December 09, 2014 11:03 PM >> >To: Zhigang Lu >> >Cc: dev@dpdk.org >> >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag >> >checks >> for tile >> >architecture >> > >> >On Mon, Dec 08, 2014 at 04:59:37PM +0800, Zhigang Lu wrote: >> >> Tile processor doesn't have CPU flag hardware registers, so this >> >> patch turns off cpu flag checks for tile. >> >> >> >> Signed-off-by: Zhigang Lu <zlu@ezchip.com> >> >> Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com> >> >> --- >> >> app/test/test_cpuflags.c | 2 +- >> >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> >> >> diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c >> >> index >> >> 5aeba5d..da93af5 100644 >> >> --- a/app/test/test_cpuflags.c >> >> +++ b/app/test/test_cpuflags.c >> >> @@ -113,7 +113,7 @@ test_cpuflags(void) >> >> >> >> printf("Check for ICACHE_SNOOP:\t\t"); >> >> CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP); >> >> -#else >> >> +#elif !defined(RTE_ARCH_TILE) >> >> printf("Check for SSE:\t\t"); >> >> CHECK_FOR_FLAG(RTE_CPUFLAG_SSE); >> >> >> >Please stop this. It doesn't make sense for a library that supports >> multiple >> >arches, we need some way to generically test for flags that doesn't >> >involve forcing applications to do ton's of ifdeffing. Perhaps >> rte_cpu_get_flag_enabled >> >needs to do a flag table lookup based on the detected arch at run >> >time, and return the appropriate response. In the case of tile, it >> >can just be an >> empty >> >table, so 0 is always returned. But making an application >> >responsible for >> doing >> >arch checks is a guarantee to write non-portable applications >> > >> >Neil >> > >> >> Thanks for taking a look at this. >> This change just follows what PPC did in commit 9ae15538. The root >> cause is >Yes, and I objected to it there as well: >http://dpdk.org/ml/archives/dev/2014-November/008628.html > >To which the response was effectively "Sure, we'll do that later". You're >effectively making the same argument. If no one ever steps up to change the >interface when adding a new arch, it will never get done, and we'll have a >fragmented cpuflag test mechanism that creates completely non-portable code >accross arches. > >> that >> the test_cpuflags.c explicitly tests X86-specific CPU flags, so we >> might need to revise this test case to make it >> architecture-independent. >> >Exactly what I said in my email to the powerpc people. If you're going to add a >new arch, and a given interface doesn't support doing so, please try to re-design >the interface to make it more friendly, otherwise we'll be left with >unmaintainable code. Agree, Make sense. >Thinking about it, you probably don't even need to change the api call to do this. >You just need to create a unified map for all flags of all supported arches, that is >to say a two dimensional array with the indicies [arch][flag] where the stored >value is the arch specific data to help determine if the feature is supported, or a >universal "not supported" flag. Yes, in order not to break ACL or other libs/apps, we need to make the flags of all supported arches accessible. But I don't feel as strongly to create a [arch][flag] array, since checking if the specified flag is supported is at runtime, so we can not assign it in a predefine array according to its arch. For example, some old X86 processor does not support SSE3. Instead I prefer a one dimensional arch-specific [flag] array which contains all the flags of all supported arches, and we mark the flags that do not belong to the current arch as "not available". To implement this, we need to move the enum rte_cpu_flag_t from arch-specific rte_cpuflags.c to the generic one, and combine them as one enumeration. ACL rte_acl_init() itself has a bug that it should check the return value of rte_cpu_get_flag_enabled() if it is "1", but not "!0", as it may return "-EFAULT". Thanks -Zhigang
On Fri, Dec 12, 2014 at 04:10:21PM +0800, Tony Lu wrote: > >-----Original Message----- > >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman > >Sent: Thursday, December 11, 2014 9:39 PM > >To: Tony Lu > >Cc: dev@dpdk.org > >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag checks > for tile > >architecture > > > >On Thu, Dec 11, 2014 at 12:43:36PM +0800, Tony Lu wrote: > >> >-----Original Message----- > >> >From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Neil Horman > >> >Sent: Tuesday, December 09, 2014 11:03 PM > >> >To: Zhigang Lu > >> >Cc: dev@dpdk.org > >> >Subject: Re: [dpdk-dev] [PATCH 14/15] app/test: turn off cpu flag > >> >checks > >> for tile > >> >architecture > >> > > >> >On Mon, Dec 08, 2014 at 04:59:37PM +0800, Zhigang Lu wrote: > >> >> Tile processor doesn't have CPU flag hardware registers, so this > >> >> patch turns off cpu flag checks for tile. > >> >> > >> >> Signed-off-by: Zhigang Lu <zlu@ezchip.com> > >> >> Signed-off-by: Cyril Chemparathy <cchemparathy@ezchip.com> > >> >> --- > >> >> app/test/test_cpuflags.c | 2 +- > >> >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> >> > >> >> diff --git a/app/test/test_cpuflags.c b/app/test/test_cpuflags.c > >> >> index > >> >> 5aeba5d..da93af5 100644 > >> >> --- a/app/test/test_cpuflags.c > >> >> +++ b/app/test/test_cpuflags.c > >> >> @@ -113,7 +113,7 @@ test_cpuflags(void) > >> >> > >> >> printf("Check for ICACHE_SNOOP:\t\t"); > >> >> CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP); > >> >> -#else > >> >> +#elif !defined(RTE_ARCH_TILE) > >> >> printf("Check for SSE:\t\t"); > >> >> CHECK_FOR_FLAG(RTE_CPUFLAG_SSE); > >> >> > >> >Please stop this. It doesn't make sense for a library that supports > >> multiple > >> >arches, we need some way to generically test for flags that doesn't > >> >involve forcing applications to do ton's of ifdeffing. Perhaps > >> rte_cpu_get_flag_enabled > >> >needs to do a flag table lookup based on the detected arch at run > >> >time, and return the appropriate response. In the case of tile, it > >> >can just be an > >> empty > >> >table, so 0 is always returned. But making an application > >> >responsible for > >> doing > >> >arch checks is a guarantee to write non-portable applications > >> > > >> >Neil > >> > > >> > >> Thanks for taking a look at this. > >> This change just follows what PPC did in commit 9ae15538. The root > >> cause is > >Yes, and I objected to it there as well: > >http://dpdk.org/ml/archives/dev/2014-November/008628.html > > > >To which the response was effectively "Sure, we'll do that later". You're > >effectively making the same argument. If no one ever steps up to change > the > >interface when adding a new arch, it will never get done, and we'll have a > >fragmented cpuflag test mechanism that creates completely non-portable code > >accross arches. > > > >> that > >> the test_cpuflags.c explicitly tests X86-specific CPU flags, so we > >> might need to revise this test case to make it > >> architecture-independent. > >> > >Exactly what I said in my email to the powerpc people. If you're going to > add a > >new arch, and a given interface doesn't support doing so, please try to > re-design > >the interface to make it more friendly, otherwise we'll be left with > >unmaintainable code. > > Agree, Make sense. > > >Thinking about it, you probably don't even need to change the api call to > do this. > >You just need to create a unified map for all flags of all supported > arches, that is > >to say a two dimensional array with the indicies [arch][flag] where the > stored > >value is the arch specific data to help determine if the feature is > supported, or a > >universal "not supported" flag. > > Yes, in order not to break ACL or other libs/apps, we need to make the flags > of all > supported arches accessible. But I don't feel as strongly to create a > [arch][flag] array, > since checking if the specified flag is supported is at runtime, so we can > not assign it in > a predefine array according to its arch. For example, some old X86 processor > does not > support SSE3. > > Instead I prefer a one dimensional arch-specific [flag] array which contains > all the flags > of all supported arches, and we mark the flags that do not belong to the > current arch > as "not available". > > To implement this, we need to move the enum rte_cpu_flag_t from > arch-specific > rte_cpuflags.c to the generic one, and combine them as one enumeration. > > ACL rte_acl_init() itself has a bug that it should check the return value of > rte_cpu_get_flag_enabled() if it is "1", but not "!0", as it may return > "-EFAULT". > Thats all fine with me. We can debate the relative merits of implementation when its available. Its getting the interface right that I think is currently the priority. Neil > Thanks > -Zhigang > >
--- a/app/test/test_cpuflags.c +++ b/app/test/test_cpuflags.c @@ -77,81 +77,13 @@ cpu_flag_result(int result) static int test_cpuflags(void) { - int result; + int i, result; printf("\nChecking for flags from different registers...\n"); -#ifdef RTE_ARCH_PPC_64 - printf("Check for PPC64:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_PPC64); - - printf("Check for PPC32:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_PPC32); - - printf("Check for VSX:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_VSX); - - printf("Check for DFP:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_DFP); - - printf("Check for FPU:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_FPU); - - printf("Check for SMT:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SMT); - - printf("Check for MMU:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_MMU); - - printf("Check for ALTIVEC:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_ALTIVEC); - - printf("Check for ARCH_2_06:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_ARCH_2_06); - - printf("Check for ARCH_2_07:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_ARCH_2_07); - - printf("Check for ICACHE_SNOOP:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_ICACHE_SNOOP); -#else - printf("Check for SSE:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SSE); - - printf("Check for SSE2:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SSE2); - - printf("Check for SSE3:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SSE3); - - printf("Check for SSE4.1:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_1); - - printf("Check for SSE4.2:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_SSE4_2); - - printf("Check for AVX:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_AVX); - - printf("Check for AVX2:\t\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_AVX2); - - printf("Check for TRBOBST:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_TRBOBST); - - printf("Check for ENERGY_EFF:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_ENERGY_EFF); - - printf("Check for LAHF_SAHF:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_LAHF_SAHF); - - printf("Check for 1GB_PG:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_1GB_PG); - - printf("Check for INVTSC:\t"); - CHECK_FOR_FLAG(RTE_CPUFLAG_INVTSC); - - -#endif + for (i = 0; i < RTE_CPUFLAG_NUMFLAGS; i++) { + printf("Check for %s:\t\t", cpu_feature_table[i].name); + CHECK_FOR_FLAG(i); + } Thanks -Zhigang