* [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c?
@ 2019-03-26  1:11 Stefan Kanthak
  2019-03-26  1:11 ` Stefan Kanthak
  2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Kanthak @ 2019-03-26  1:11 UTC (permalink / raw)
  To: dev; +Cc: hannes
Hi @ll,
<https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list
a maintainer for lib/librte_eal/common/rte_reciprocal.c
Whoever it is should take a close look at
<https://skanthak.homepage.t-online.de/division.html>,
then fix the most obvious bug plus the many deficiencies of
divide_128_div_64_to_64().
regards
Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
* [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c?
  2019-03-26  1:11 [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
@ 2019-03-26  1:11 ` Stefan Kanthak
  2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Kanthak @ 2019-03-26  1:11 UTC (permalink / raw)
  To: dev; +Cc: hannes
Hi @ll,
<https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list
a maintainer for lib/librte_eal/common/rte_reciprocal.c
Whoever it is should take a close look at
<https://skanthak.homepage.t-online.de/division.html>,
then fix the most obvious bug plus the many deficiencies of
divide_128_div_64_to_64().
regards
Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c?
  2019-03-26  1:11 [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
  2019-03-26  1:11 ` Stefan Kanthak
@ 2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
  2019-03-28  4:35   ` Pavan Nikhilesh Bhagavatula
  2019-04-05 19:17   ` [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
  1 sibling, 2 replies; 6+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2019-03-28  4:35 UTC (permalink / raw)
  To: Stefan Kanthak, dev; +Cc: hannes
Hi Stefan,
Thanks for the heads up, I am planning to use a modified version of
https://github.com/hcs0/Hackers-Delight/blob/master/divluh.c.txt
for simplicity as we don't require the remainder.
Regards,
Pavan.
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stefan Kanthak
> Sent: Tuesday, March 26, 2019 6:41 AM
> To: dev@dpdk.org
> Cc: hannes@stressinduktion.org
> Subject: [dpdk-dev] [BUG] Maintainer for
> lib/librte_eal/common/rte_reciprocal.c?
> 
> Hi @ll,
> 
> <https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list a maintainer
> for lib/librte_eal/common/rte_reciprocal.c
> 
> Whoever it is should take a close look at <https://skanthak.homepage.t-
> online.de/division.html>,
> then fix the most obvious bug plus the many deficiencies of
> divide_128_div_64_to_64().
> 
> regards
> Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c?
  2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
@ 2019-03-28  4:35   ` Pavan Nikhilesh Bhagavatula
  2019-04-05 19:17   ` [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
  1 sibling, 0 replies; 6+ messages in thread
From: Pavan Nikhilesh Bhagavatula @ 2019-03-28  4:35 UTC (permalink / raw)
  To: Stefan Kanthak, dev; +Cc: hannes
Hi Stefan,
Thanks for the heads up, I am planning to use a modified version of
https://github.com/hcs0/Hackers-Delight/blob/master/divluh.c.txt
for simplicity as we don't require the remainder.
Regards,
Pavan.
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stefan Kanthak
> Sent: Tuesday, March 26, 2019 6:41 AM
> To: dev@dpdk.org
> Cc: hannes@stressinduktion.org
> Subject: [dpdk-dev] [BUG] Maintainer for
> lib/librte_eal/common/rte_reciprocal.c?
> 
> Hi @ll,
> 
> <https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list a maintainer
> for lib/librte_eal/common/rte_reciprocal.c
> 
> Whoever it is should take a close look at <https://skanthak.homepage.t-
> online.de/division.html>,
> then fix the most obvious bug plus the many deficiencies of
> divide_128_div_64_to_64().
> 
> regards
> Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c?
  2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
  2019-03-28  4:35   ` Pavan Nikhilesh Bhagavatula
@ 2019-04-05 19:17   ` Stefan Kanthak
  2019-04-05 19:17     ` Stefan Kanthak
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Kanthak @ 2019-04-05 19:17 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula, dev; +Cc: hannes
"Pavan Nikhilesh Bhagavatula" <pbhagavatula@marvell.com> wrote Thursday, March 28, 2019 6:35 AM:
> Hi Stefan,
>
> Thanks for the heads up, I am planning to use a modified version of
> https://github.com/hcs0/Hackers-Delight/blob/master/divluh.c.txt
> for simplicity as we don't require the remainder.
Why don't you refer to the ORIGINAL source
<https://www.hackersdelight.org/hdcodetxt/divluh.c.txt> instead?
BUT: you also shouldn't use these routines, they too show quite bad
     implementations of a binary division!
     As Don Knuth wrote in volume 2 of TAoCP, hardware implementations
     are most often NOT well-suited for implementation in software.
Take a look at the following STRAIGHTFORWARD implementation, both
in ANSI C and x86 assembly (for Microsoft's Visual C compiler):
unsigned long long divide(unsigned long long dividendlow,
                          unsigned long long dividendhigh,
                          unsigned long long divisor,
                          unsigned long long *remainder)
{
#ifndef _M_IX86
    unsigned int shift = 64;
    do
    {
        if (dividendhigh < divisor)
        {
            dividendhigh <<= 1;
            dividendhigh |= dividendlow >> 63;
            dividendlow <<= 1;
        }
        else
        {
            dividendhigh -= divisor;
            dividendhigh <<= 1;
            dividendhigh |= dividendlow >> 63;
            dividendlow <<= 1;
            dividendlow |= 1;
        }
    } while (--shift != 0);
    if (*remainder != NULL)
        remainder = dividendhigh;
    return dividendlow;
#else
    __asm
    {
        mov    eax, dword ptr dividendlow
        mov    edx, dword ptr dividendlow+4
        mov    ecx, dword ptr dividendhigh
        mov    ebx, dword ptr dividendhigh+4
        mov    edi, dword ptr divisor
        mov    esi, dword ptr divisor+4
        mov    ebp, 64
    NEXT:
        cmp    ebx, esi
        ja     SUBTRACT
        jb     SHIFT
        cmp    ecx, edi
        jb     SHIFT
    SUBTRACT:
        sub    ecx, edi
        sbb    ebx, esi
    SHIFT:
        cmc
        adc    eax, eax
        adc    edx, edx
        adc    ecx, ecx
        adc    ebx, ebx
        dec    ebp
        jnz    NEXT
        or     ebp, remainder
        jz     EXIT
        mov    [ebp], ecx
        mov    [ebp+4], ebx
    EXIT:
    }
#endif
}
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stefan Kanthak
> Sent: Tuesday, March 26, 2019 6:41 AM
> To: dev@dpdk.org
> Cc: hannes@stressinduktion.org
> Subject: [dpdk-dev] [BUG] Maintainer for
> lib/librte_eal/common/rte_reciprocal.c?
> 
> Hi @ll,
> 
> <https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list a maintainer
> for lib/librte_eal/common/rte_reciprocal.c
> 
> Whoever it is should take a close look at <https://skanthak.homepage.t-
> online.de/division.html>,
> then fix the most obvious bug plus the many deficiencies of
> divide_128_div_64_to_64().
> 
> regards
> Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
* Re: [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c?
  2019-04-05 19:17   ` [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
@ 2019-04-05 19:17     ` Stefan Kanthak
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Kanthak @ 2019-04-05 19:17 UTC (permalink / raw)
  To: Pavan Nikhilesh Bhagavatula, dev; +Cc: hannes
"Pavan Nikhilesh Bhagavatula" <pbhagavatula@marvell.com> wrote Thursday, March 28, 2019 6:35 AM:
> Hi Stefan,
>
> Thanks for the heads up, I am planning to use a modified version of
> https://github.com/hcs0/Hackers-Delight/blob/master/divluh.c.txt
> for simplicity as we don't require the remainder.
Why don't you refer to the ORIGINAL source
<https://www.hackersdelight.org/hdcodetxt/divluh.c.txt> instead?
BUT: you also shouldn't use these routines, they too show quite bad
     implementations of a binary division!
     As Don Knuth wrote in volume 2 of TAoCP, hardware implementations
     are most often NOT well-suited for implementation in software.
Take a look at the following STRAIGHTFORWARD implementation, both
in ANSI C and x86 assembly (for Microsoft's Visual C compiler):
unsigned long long divide(unsigned long long dividendlow,
                          unsigned long long dividendhigh,
                          unsigned long long divisor,
                          unsigned long long *remainder)
{
#ifndef _M_IX86
    unsigned int shift = 64;
    do
    {
        if (dividendhigh < divisor)
        {
            dividendhigh <<= 1;
            dividendhigh |= dividendlow >> 63;
            dividendlow <<= 1;
        }
        else
        {
            dividendhigh -= divisor;
            dividendhigh <<= 1;
            dividendhigh |= dividendlow >> 63;
            dividendlow <<= 1;
            dividendlow |= 1;
        }
    } while (--shift != 0);
    if (*remainder != NULL)
        remainder = dividendhigh;
    return dividendlow;
#else
    __asm
    {
        mov    eax, dword ptr dividendlow
        mov    edx, dword ptr dividendlow+4
        mov    ecx, dword ptr dividendhigh
        mov    ebx, dword ptr dividendhigh+4
        mov    edi, dword ptr divisor
        mov    esi, dword ptr divisor+4
        mov    ebp, 64
    NEXT:
        cmp    ebx, esi
        ja     SUBTRACT
        jb     SHIFT
        cmp    ecx, edi
        jb     SHIFT
    SUBTRACT:
        sub    ecx, edi
        sbb    ebx, esi
    SHIFT:
        cmc
        adc    eax, eax
        adc    edx, edx
        adc    ecx, ecx
        adc    ebx, ebx
        dec    ebp
        jnz    NEXT
        or     ebp, remainder
        jz     EXIT
        mov    [ebp], ecx
        mov    [ebp+4], ebx
    EXIT:
    }
#endif
}
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Stefan Kanthak
> Sent: Tuesday, March 26, 2019 6:41 AM
> To: dev@dpdk.org
> Cc: hannes@stressinduktion.org
> Subject: [dpdk-dev] [BUG] Maintainer for
> lib/librte_eal/common/rte_reciprocal.c?
> 
> Hi @ll,
> 
> <https://git.dpdk.org/dpdk/plain/MAINTAINERS> does NOT list a maintainer
> for lib/librte_eal/common/rte_reciprocal.c
> 
> Whoever it is should take a close look at <https://skanthak.homepage.t-
> online.de/division.html>,
> then fix the most obvious bug plus the many deficiencies of
> divide_128_div_64_to_64().
> 
> regards
> Stefan Kanthak
^ permalink raw reply	[flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-04-05 20:07 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-26  1:11 [dpdk-dev] [BUG] Maintainer for lib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
2019-03-26  1:11 ` Stefan Kanthak
2019-03-28  4:35 ` Pavan Nikhilesh Bhagavatula
2019-03-28  4:35   ` Pavan Nikhilesh Bhagavatula
2019-04-05 19:17   ` [dpdk-dev] [BUG] Maintainer forlib/librte_eal/common/rte_reciprocal.c? Stefan Kanthak
2019-04-05 19:17     ` Stefan Kanthak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).