Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Programming is an unnatural act.


devel / comp.arch.fpga / Re: How to start with FPGA as "coprocessor"

SubjectAuthor
* How to start with FPGA as "coprocessor"Thomas Koenig
+* Re: How to start with FPGA as "coprocessor"HT-Lab
|`* Re: How to start with FPGA as "coprocessor"Thomas Koenig
| `- Re: How to start with FPGA as "coprocessor"HT-Lab
+* Re: How to start with FPGA as "coprocessor"Romain Dolbeau
|`* Re: How to start with FPGA as "coprocessor"Thomas Koenig
| +- Re: How to start with FPGA as "coprocessor"Romain Dolbeau
| `- Re: How to start with FPGA as "coprocessor"HT-Lab
`* Re: How to start with FPGA as "coprocessor"Richard Damon
 `* Re: How to start with FPGA as "coprocessor"Nelson Ribeiro
  +* Re: How to start with FPGA as "coprocessor"Richard Damon
  |`- Re: How to start with FPGA as "coprocessor"Thomas Koenig
  `* Re: How to start with FPGA as "coprocessor"Thomas Koenig
   `* Re: How to start with FPGA as "coprocessor"Richard Damon
    `* Re: How to start with FPGA as "coprocessor"Nelson Ribeiro
     `* Re: How to start with FPGA as "coprocessor"Richard Damon
      `* Re: How to start with FPGA as "coprocessor"Thomas Koenig
       `* Re: How to start with FPGA as "coprocessor"Richard Damon
        `* Re: How to start with FPGA as "coprocessor"Thomas Koenig
         `- Re: How to start with FPGA as "coprocessor"Nelson Ribeiro

1
How to start with FPGA as "coprocessor"

<s76amp$j6q$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=105&group=comp.arch.fpga#105

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: How to start with FPGA as "coprocessor"
Date: Sat, 8 May 2021 15:28:25 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s76amp$j6q$1@newsreader4.netcologne.de>
Injection-Date: Sat, 8 May 2021 15:28:25 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="19674"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sat, 8 May 2021 15:28 UTC

Hi,

I have a certain interest in a mathematical puzzle that I have not
been able to solve using a normal CPU, and I thought that using
an FPGA could work.

For this, I would like to assign some work packages to search
for certain numbers to the FPGA, which then processes them and
returns the data, plus an indication that it has finished with
that particular package.

The task at hand is extremely parallel, so FPGAs should be a
good match. However, I have zero actual experience with FPGAs,
and I have no idea how to go about assigning the work packages
and getting back the results.

Any pointers? What sort of board should I look for, and how
should I handle the communication?

(For those who are interested: I want to find numbers other than
zero and one for which the sum of digits in all prime bases up
to 17 is the same, the successor to https://oeis.org/A335839 ,
so to speak).

Re: How to start with FPGA as "coprocessor"

<quzlI.654434$W%q8.279495@fx36.ams4>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=106&group=comp.arch.fpga#106

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!ecngs!feeder2.ecngs.de!178.20.174.213.MISMATCH!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx36.ams4.POSTED!not-for-mail
Reply-To: hans64@htminuslab.com
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
From: han...@htminuslab.com (HT-Lab)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s76amp$j6q$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
X-Antivirus: Avast (VPS 210508-2, 08/05/2021), Outbound message
X-Antivirus-Status: Clean
Lines: 21
Message-ID: <quzlI.654434$W%q8.279495@fx36.ams4>
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Sat, 08 May 2021 17:02:14 UTC
Organization: virginmedia.com
Date: Sat, 8 May 2021 18:02:15 +0100
X-Received-Bytes: 1591
 by: HT-Lab - Sat, 8 May 2021 17:02 UTC

On 08/05/2021 16:28, Thomas Koenig wrote:
> Hi,
>
> I have a certain interest in a mathematical puzzle that I have not
> been able to solve using a normal CPU, and I thought that using
> an FPGA could work.
>
....

I think you are moving in the wrong direction, if you can't solve it
with some numerical package like numpy/linpack then it is highly
unlikely you will succeed with an FPGA based solution.
What you probably want is a fast graphics card + CUDA/OpenCL which will
most likely outperform your FPGA based design.

Still it will be an interesting learning exercise ;-)

Hans
www.ht-lab.com

Re: How to start with FPGA as "coprocessor"

<609797c3$0$12696$426a74cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=108&group=comp.arch.fpga#108

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!cleanfeed1-b.proxad.net!nnrp1-2.free.fr!not-for-mail
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
From: rom...@dolbeau.org (Romain Dolbeau)
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 10:05:23 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.9.0
MIME-Version: 1.0
In-Reply-To: <s76amp$j6q$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 48
Message-ID: <609797c3$0$12696$426a74cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 09 May 2021 10:05:23 CEST
NNTP-Posting-Host: 82.64.60.106
X-Trace: 1620547523 news-1.free.fr 12696 82.64.60.106:58802
X-Complaints-To: abuse@proxad.net
 by: Romain Dolbeau - Sun, 9 May 2021 08:05 UTC

On 5/8/21 5:28 PM, Thomas Koenig wrote:
> I have a certain interest in a mathematical puzzle that I have not
> been able to solve using a normal CPU, and I thought that using
> an FPGA could work.

Out of curiosity, what is the specific issue you encounter using a
'normal' CPU ?

As you say:

> The task at hand is extremely parallel,

Typically, assuming a constant-time (of duration ta) atom of work and n
atoms to process over p cpu, the cpu would take a time
t_cpu = ta_cpu * round-up(n/p_cpu)

The only way a FPGA can beat that is if it:
a) has a ta_fpga <<< ta_cpu while retaining p_fpga ~= p_cpu
b) has a p_fpga >>> p_cpu while retaining ta_fpga ~= ta_cpu
c) has a ta_fpga <<< ta_cpu and a p_fpga >>> p_cpu (ideal case)

Depending on how much you're willing to spend (big FPGAs aren't cheap),
the first question would be, how big can you get 'p_cpu' ? Using MPI to
distribute the atoms of work over a lot of cores should not be very
difficult, and a 'lot of cores' can be obtained easily from cloud
providers nowadays.

FPGAs are not as easy to tryout, today I think it's pretty much Amazon
F1 in the cloud - or buying.

That being said, FPGA vendors promote a lot of solutions for this
particular problem, from low-level solutions (e.g. a PCIe core and a lot
of hand-written Verilog/VHDL/...) to high-level solutions (e.g.
<https://www.intel.com/content/www/us/en/programmable/documentation/div1537518568620.html>,
<https://www.xilinx.com/products/design-tools/vivado/integration/esl-design.html>,
etc.). Those solutions can be with stand-alone FPGAs or with the FPGA
integrated in a SoC with normal cores (e.g. Xilinx Zynq families, among
others).

There's also non-vendor solutions, mostly accelerated SoC such as
<https://www.esp.cs.columbia.edu/> or
<https://github.com/google/CFU-Playground> (extension to
<https://github.com/enjoy-digital/litex>) that can help get started.

Cordially,

--
Romain

Re: How to start with FPGA as "coprocessor"

<s7864s$q1q$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=109&group=comp.arch.fpga#109

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 08:22:52 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s7864s$q1q$1@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<quzlI.654434$W%q8.279495@fx36.ams4>
Injection-Date: Sun, 9 May 2021 08:22:52 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="26682"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 9 May 2021 08:22 UTC

HT-Lab <hans64@htminuslab.com> schrieb:
> On 08/05/2021 16:28, Thomas Koenig wrote:
>> Hi,
>>
>> I have a certain interest in a mathematical puzzle that I have not
>> been able to solve using a normal CPU, and I thought that using
>> an FPGA could work.
>>
> ...
>
> I think you are moving in the wrong direction, if you can't solve it
> with some numerical package like numpy/linpack

Definitely not the right kind of problem.

> then it is highly
> unlikely you will succeed with an FPGA based solution.

An FPGA would be quite good, IMHO.

What I would need are things like

- an efficient (base 2) popcount operation

- counters in base 3, 5, 7,11, 13 and 17

- adders for all of the bases above

- efficient popcount operations for all of the bases
above

plus handling of numbers in the region of 72 bits.

> What you probably want is a fast graphics card + CUDA/OpenCL which will
> most likely outperform your FPGA based design.

That is an alternative. I am also looking at that, but
FPGAs seem to be more interesting, at the moment.

> Still it will be an interesting learning exercise ;-)

Certainly.

Therefore, what sort of system should I be looking for? I don't
want to spend my whole time writing Linux kernel drivers or
Bluetooth communication drivers for the FPGA :-)

So, something that can be interfaced easily with a computer
(either on board or with a host computer running Linux) would
be great.

Re: How to start with FPGA as "coprocessor"

<s78iak$b7$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=110&group=comp.arch.fpga#110

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 11:50:44 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s78iak$b7$1@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<609797c3$0$12696$426a74cc@news.free.fr>
Injection-Date: Sun, 9 May 2021 11:50:44 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="359"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 9 May 2021 11:50 UTC

Romain Dolbeau <romain@dolbeau.org> schrieb:
> On 5/8/21 5:28 PM, Thomas Koenig wrote:
>> I have a certain interest in a mathematical puzzle that I have not
>> been able to solve using a normal CPU, and I thought that using
>> an FPGA could work.
>
> Out of curiosity, what is the specific issue you encounter using a
> 'normal' CPU ?

It's too slow.

I managed to search the number space up to around 2^64 in around
half a CPU year (from which you can tell that one key is to
reduce the search space).

>> The task at hand is extremely parallel,
>
> Typically, assuming a constant-time (of duration ta) atom of work and n
> atoms to process over p cpu, the cpu would take a time
> t_cpu = ta_cpu * round-up(n/p_cpu)
>
> The only way a FPGA can beat that is if it:
> a) has a ta_fpga <<< ta_cpu while retaining p_fpga ~= p_cpu
> b) has a p_fpga >>> p_cpu while retaining ta_fpga ~= ta_cpu
> c) has a ta_fpga <<< ta_cpu and a p_fpga >>> p_cpu (ideal case)

There are things that an FPGA should be able to do better than
a CPU. One example is implementing a base-n counter, which is a
serial operation on a CPU and can easily be done in parallel on
an FPGA.

> Depending on how much you're willing to spend (big FPGAs aren't cheap),
> the first question would be, how big can you get 'p_cpu' ? Using MPI to
> distribute the atoms of work over a lot of cores should not be very
> difficult, and a 'lot of cores' can be obtained easily from cloud
> providers nowadays.

That is of course a possibility. In the CPU-based approach I
simply used OpenMP with schedule(dynamic). However, for this
kind of hobbyist thing, I'd rather learn something interesting
than throw money at a cloud provider :-)

> That being said, FPGA vendors promote a lot of solutions for this
> particular problem, from low-level solutions (e.g. a PCIe core and a lot
> of hand-written Verilog/VHDL/...) to high-level solutions (e.g.
><https://www.intel.com/content/www/us/en/programmable/documentation/div1537518568620.html>,
><https://www.xilinx.com/products/design-tools/vivado/integration/esl-design.html>,
> etc.). Those solutions can be with stand-alone FPGAs or with the FPGA
> integrated in a SoC with normal cores (e.g. Xilinx Zynq families, among
> others).

> There's also non-vendor solutions, mostly accelerated SoC such as
><https://www.esp.cs.columbia.edu/> or
><https://github.com/google/CFU-Playground> (extension to
><https://github.com/enjoy-digital/litex>) that can help get started.

Thanks for the pointers.

Seems to be rather high-level, and also rather abstract (ok, so these
systems are usually aimed at professionals, not at hobbyists).

I'll look around a bit and see if I can find anything that helps me,
but at the moment, I have to say it all looks rather daunting :-)

Re: How to start with FPGA as "coprocessor"

<6097d61a$0$27449$426a34cc@news.free.fr>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=111&group=comp.arch.fpga#111

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!news.nntp4.net!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!cleanfeed2-b.proxad.net!nnrp1-2.free.fr!not-for-mail
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<609797c3$0$12696$426a74cc@news.free.fr>
<s78iak$b7$1@newsreader4.netcologne.de>
From: rom...@dolbeau.org (Romain Dolbeau)
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 14:31:22 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.9.0
MIME-Version: 1.0
In-Reply-To: <s78iak$b7$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 66
Message-ID: <6097d61a$0$27449$426a34cc@news.free.fr>
Organization: Guest of ProXad - France
NNTP-Posting-Date: 09 May 2021 14:31:22 CEST
NNTP-Posting-Host: 82.64.60.106
X-Trace: 1620563482 news-4.free.fr 27449 82.64.60.106:59804
X-Complaints-To: abuse@proxad.net
 by: Romain Dolbeau - Sun, 9 May 2021 12:31 UTC

On 5/9/21 1:50 PM, Thomas Koenig wrote:
> That is of course a possibility. In the CPU-based approach I
> simply used OpenMP with schedule(dynamic). However, for this
> kind of hobbyist thing, I'd rather learn something interesting
> than throw money at a cloud provider :-)

Agreed. But distributed computing can do wonder for many brute-force
mathematical problems (e.g.
<https://en.wikipedia.org/wiki/Lychrel_number#196_palindrome_quest> ;-) ).

> Seems to be rather high-level, and also rather abstract (ok, so these
> systems are usually aimed at professionals, not at hobbyists).
> I'll look around a bit and see if I can find anything that helps me,
> but at the moment, I have to say it all looks rather daunting :-)

It depends where you start... I see two problems to solve to use a FPGA:

(a) implementing the hardware operator(s) in a fast/efficient way;
(b) integrating said operator(s) in an acceleration framework.

Tackling both at once can be daunting. However, tackling only the first
(which is likely the most interesting one and sort-of-research) should
be quite achievable. Once that works, you can figure out how to put them
in 'production' by having the right set up (number of operators, speed,
memory requirements, etc.).

E.g., if you can express the problem as a (set of) 32x32 -> 32 operators
(with some ad-hoc encoding, presumably), you can easily add dedicated
instructions in a 32-bits softcore to evaluate the performance benefit.
Then you can figure out a way to high-performance. Some softcore might
let you do wider operands/results - 64-bits should not be much of a
problem with 64-bit softcores.

Blowing my own horn here (sorry), but for instance you can have a look
at: <https://github.com/rdolbeau/VexRiscvBPluginGenerator/> which is
designed to easily add integer-pipeline instructions to a VexRiscv
(RV32) core in a Linux-capable Litex SoC. I run a 100 MHz quad-cores on
a ~$90 board; it won't be faster than a beefy CPU, but it's a cheap way
to start evaluating implementations. There's also support for 32x32->64
instructions (from the draft P 'packed simd' extension to RISC-V [2]),
32x32x32->32 instructions (from the draft Zbt 'bitmanip ternary'
extension [1]) and you can even do 32x32x32->64 if you really want (by
abusing both systems, for instance to implement a faster Chacha [3], see
e.g.
<https://github.com/rdolbeau/VexRiscvBPluginGenerator/blob/master/data_Chacha64.txt>).
That would the easiest way to prototype some operators, I believe.

Alternatively, VexRiscv has a FPU 'coprocessor' that can be an
inspiration to implement a dedicated unit with data width up to 64 bits
(but it will be more complicated).

Finally you can go for the full-custom acceleration peripheral; the
CFU-playgrounds is one way, or you can look at the ESP project as they
are more focused on acceleration. But that's basically solving (b) along
with (a).

Cordially,

Romain

[1] <https://github.com/riscv/riscv-bitmanip>
[2] <https://github.com/riscv/riscv-p-spec>
[3] <https://en.wikipedia.org/wiki/Salsa20#ChaCha_variant>

--
Romain

Re: How to start with FPGA as "coprocessor"

<ueTlI.546674$BHVc.236563@fx32.ams4>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=112&group=comp.arch.fpga#112

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx32.ams4.POSTED!not-for-mail
Reply-To: hans64@htminuslab.com
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<quzlI.654434$W%q8.279495@fx36.ams4> <s7864s$q1q$1@newsreader4.netcologne.de>
From: han...@htminuslab.com (HT-Lab)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s7864s$q1q$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
X-Antivirus: Avast (VPS 210509-0, 09/05/2021), Outbound message
X-Antivirus-Status: Clean
Lines: 96
Message-ID: <ueTlI.546674$BHVc.236563@fx32.ams4>
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Sun, 09 May 2021 15:30:34 UTC
Organization: virginmedia.com
Date: Sun, 9 May 2021 16:30:34 +0100
X-Received-Bytes: 4270
X-Original-Bytes: 4128
 by: HT-Lab - Sun, 9 May 2021 15:30 UTC

On 09/05/2021 09:22, Thomas Koenig wrote:
> HT-Lab <hans64@htminuslab.com> schrieb:
>> On 08/05/2021 16:28, Thomas Koenig wrote:
>>> Hi,
>>>
>>> I have a certain interest in a mathematical puzzle that I have not
>>> been able to solve using a normal CPU, and I thought that using
>>> an FPGA could work.
>>>
>> ...
>>
>> I think you are moving in the wrong direction, if you can't solve it
>> with some numerical package like numpy/linpack
>
> Definitely not the right kind of problem.

OK, I must admit I didn't really look closely at the page you gave but I
do know for a lot of numerical intensive calculations a modern PC + Cuda
is not easily beaten by an FPGA especially in terms of cost and
development time.
>
>> then it is highly
>> unlikely you will succeed with an FPGA based solution.
>
> An FPGA would be quite good, IMHO.
>
> What I would need are things like
>
> - an efficient (base 2) popcount operation

This is easy as most processors have a POPCNT instruction so you should
be able to find some efficient RTL code on the web. In most cases it is
just a bunch of counters/adders.

>
> - counters in base 3, 5, 7,11, 13 and 17

This I suspect will be more difficult especially if you have to deal
with large word length, if not then a LUTs+adders could provide a fast
solution.

>
> - adders for all of the bases above

No idea, perhaps converting to base2 (allowing you to instantiate
optimised vendors cores), do all your operations and move back to base
3..17?
>
> - efficient popcount operations for all of the bases
> above
>
> plus handling of numbers in the region of 72 bits.

That could be a problem as 72bits adders/popcnt will not be fast, you
will need to heavily pipeline and optimise your design which adds
another level of complexity.

>
>> What you probably want is a fast graphics card + CUDA/OpenCL which will
>> most likely outperform your FPGA based design.
>
> That is an alternative. I am also looking at that, but
> FPGAs seem to be more interesting, at the moment.
>
>> Still it will be an interesting learning exercise ;-)
>
> Certainly.
>
> Therefore, what sort of system should I be looking for? I don't
> want to spend my whole time writing Linux kernel drivers or
> Bluetooth communication drivers for the FPGA :-)

If you looked at Bluetooth I assume the data rate required is not that
high. In this case I would go for a simple UART, you can easily get
1Mbits without much effort. No special drivers are required.
If you need more bandwidth then have a look at the many Future
Technology USB devices like the F232H which are easy to interface and
could give you up to 40MByte/sec transfer speeds. The drivers are freely
available for Windows and Linux. I have used them on a previous project
and they worked without any issue.
For anything higher get a PCIe FPGA development board which normally
come with drivers to fast DMA a block of data to and from the FPGA.

Good luck,
Hans
www.ht-lab.com

>
> So, something that can be interfaced easily with a computer
> (either on board or with a host computer running Linux) would
> be great.
>

Re: How to start with FPGA as "coprocessor"

<htTlI.218465$i669.82990@fx02.ams4>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=113&group=comp.arch.fpga#113

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx02.ams4.POSTED!not-for-mail
Reply-To: hans64@htminuslab.com
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<609797c3$0$12696$426a74cc@news.free.fr>
<s78iak$b7$1@newsreader4.netcologne.de>
From: han...@htminuslab.com (HT-Lab)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s78iak$b7$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-GB
Content-Transfer-Encoding: 7bit
X-Antivirus: Avast (VPS 210509-0, 09/05/2021), Outbound message
X-Antivirus-Status: Clean
Lines: 50
Message-ID: <htTlI.218465$i669.82990@fx02.ams4>
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Sun, 09 May 2021 15:46:21 UTC
Organization: virginmedia.com
Date: Sun, 9 May 2021 16:46:22 +0100
X-Received-Bytes: 2995
 by: HT-Lab - Sun, 9 May 2021 15:46 UTC

On 09/05/2021 12:50, Thomas Koenig wrote:
...snip
>
> That is of course a possibility. In the CPU-based approach I
> simply used OpenMP with schedule(dynamic). However, for this
> kind of hobbyist thing,

Ah, I assumed this was some commercial project, in that case go for it,
FPGA's are the best solution :-)

> I'd rather learn something interesting
> than throw money at a cloud provider :-)
>
>> That being said, FPGA vendors promote a lot of solutions for this
>> particular problem, from low-level solutions (e.g. a PCIe core and a lot
>> of hand-written Verilog/VHDL/...) to high-level solutions (e.g.
>> <https://www.intel.com/content/www/us/en/programmable/documentation/div1537518568620.html>,
>> <https://www.xilinx.com/products/design-tools/vivado/integration/esl-design.html>,
>> etc.). Those solutions can be with stand-alone FPGAs or with the FPGA
>> integrated in a SoC with normal cores (e.g. Xilinx Zynq families, among
>> others).
>
>> There's also non-vendor solutions, mostly accelerated SoC such as
>> <https://www.esp.cs.columbia.edu/> or
>> <https://github.com/google/CFU-Playground> (extension to
>> <https://github.com/enjoy-digital/litex>) that can help get started.
>
> Thanks for the pointers.
>
> Seems to be rather high-level, and also rather abstract (ok, so these
> systems are usually aimed at professionals, not at hobbyists).
>
> I'll look around a bit and see if I can find anything that helps me,
> but at the moment, I have to say it all looks rather daunting :-)

Just start small, take one of your required operators, say popcnt,
implement it in VHDL/(S)Verilog (or chisel/Python/C/etc) and simulate
it. Next get a low cost board from eBay, download the free vendor tools
and try to implement it. Depending on the prototype board you can
probably use some switches and 7-segment display for I/O.

Good luck,

Regards,
Hans.
www.ht-lab.com

Re: How to start with FPGA as "coprocessor"

<NkVlI.87862$Sx7.57490@fx18.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=114&group=comp.arch.fpga#114

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx18.iad.POSTED!not-for-mail
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s76amp$j6q$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 49
Message-ID: <NkVlI.87862$Sx7.57490@fx18.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 9 May 2021 13:53:49 -0400
X-Received-Bytes: 3229
 by: Richard Damon - Sun, 9 May 2021 17:53 UTC

On 5/8/21 11:28 AM, Thomas Koenig wrote:
> Hi,
>
> I have a certain interest in a mathematical puzzle that I have not
> been able to solve using a normal CPU, and I thought that using
> an FPGA could work.
>
> For this, I would like to assign some work packages to search
> for certain numbers to the FPGA, which then processes them and
> returns the data, plus an indication that it has finished with
> that particular package.
>
> The task at hand is extremely parallel, so FPGAs should be a
> good match. However, I have zero actual experience with FPGAs,
> and I have no idea how to go about assigning the work packages
> and getting back the results.
>
> Any pointers? What sort of board should I look for, and how
> should I handle the communication?
>
> (For those who are interested: I want to find numbers other than
> zero and one for which the sum of digits in all prime bases up
> to 17 is the same, the successor to https://oeis.org/A335839 ,
> so to speak).
>

For boards, there are a number of evaluation boards available for all
levels of processing. It might make sense to look for one with a PCIe
connector that can be just connected to a PC to be a bit easier to
interface, but even a stand alone board, maybe with small embedded
processor that just sends answers out the serial port may be simpler.

For ideas of how to build the computation. Thinking a bit, the idea that
module-N counters are fairly simple it a good starting point. You
actually don't want a 'simple' counter as that says you can't get the
parrallism, But building N count by N counters sets (of 7 base-x
counters, 2, 3, 5, 7, 11, 13, 17).

Such a counter probably costs 2-3 Luts per bit per base, At your
approximately 72 bits numbers, we are talking about 2k luts per
computation unit.

For the biggest devices, we could maybe get 1000 of these into a very
largest FPGA, and likely could be processing at a few 100 MHz clock
rate, so you will be works at a total processing rate in the 100s of
Billion tests per second, which should allow you to make a rough
estimate of the speed it will process. You may not want to plan on the
very largest of FPGAs, as those ARE pricey (the board for the one I
looked up for this size was about $16,000).

Re: How to start with FPGA as "coprocessor"

<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=115&group=comp.arch.fpga#115

  copy link   Newsgroups: comp.arch.fpga
X-Received: by 2002:ad4:4109:: with SMTP id i9mr19985861qvp.30.1620584488353;
Sun, 09 May 2021 11:21:28 -0700 (PDT)
X-Received: by 2002:aed:2167:: with SMTP id 94mr19368408qtc.378.1620584488125;
Sun, 09 May 2021 11:21:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.fpga
Date: Sun, 9 May 2021 11:21:27 -0700 (PDT)
In-Reply-To: <NkVlI.87862$Sx7.57490@fx18.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=46.50.25.207; posting-account=TcK4egoAAAB3ZADM0uNZ59IgjnBMW3JT
NNTP-Posting-Host: 46.50.25.207
References: <s76amp$j6q$1@newsreader4.netcologne.de> <NkVlI.87862$Sx7.57490@fx18.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
Subject: Re: How to start with FPGA as "coprocessor"
From: ngrr.rib...@gmail.com (Nelson Ribeiro)
Injection-Date: Sun, 09 May 2021 18:21:28 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Nelson Ribeiro - Sun, 9 May 2021 18:21 UTC

Hi Thomas.

If I understood you correctly, what you want would be an FPGA engine/coprocessor that you make the equivalent calculations of the naïve C code that I have below. That is a pretty neat mathematical problem!
I hope that you know a more efficient way of converting any number to a sequence of digits of a given base than the one I have written.
The convertBase() algorithm that I wrote is not exactly FPGA friendly, but it can be managed to put in a FPGA in a efficient way with Dividers and Multipliers in pipeline maybe...

My advice is to find some metrics that you want for a first smallish FPGA engine/coprocessor (like process 10M numbers per second, using up 2000LUTS, 500FFs, 2BRAMs, 4 mults 18x18). Any FPGA board should be good to start this project, but for a beginner it is better to use some streamline board. Then, it is a matter of replicating that FPGA engine/coprocessor and how much money you can afford in buying a board with big FPGA device or some cloud time in some FPGA cloud server. And it is possible that something that you can put to work at 100MHz in a cheap FPGA board, may run at 400MHz in a very expensive one...

For "convertBase(m, 2); sum1 = SumArray();" you can use a pipelined 'popcount' arquitecture, for the other cases you may use pipelined tree adders (with a small numbers of bits this will be really fast). With pipeline, you can execute the section "SumArray();" as if it was being execute it in just one clock cycle at 100MHz or 200MHz or even more!

The not so FPGA friendly part is really the "convertBase()" algorithm. That loop with a division (and a multiplication) is a bit troublesome... I hope you know better algorithm to perform this part. I can think in ways of using pipelined dividers... but most likely it is not the most efficient way....

Regards,
Nelson

#include <stdio.h>
#include <stdint.h>

// Definition of Constants
#define C_VALUELIMIT_INIT 2000000000
#define C_VALUELIMIT_FINIT 2010000000
#define C_BASECONVEND 0xFF
#define C_DIGITMAXSIZE 256

// Definition of Global Variables
uint8_t conv[C_DIGITMAXSIZE];

// Definition of Functions
void convertBase(uint64_t n, uint8_t k) {
uint64_t l, j;
int i = 0;
if (n == 0) conv[i++] = '0';
while (n > 0) {
l = n / k;
j = n - k * l;
conv[i] = (uint32_t) j;
n = l;
i++;
}
conv[i] = C_BASECONVEND;
}

uint32_t SumArray() {
uint32_t sum = 0; int i = 0;
while (conv[i] != C_BASECONVEND) i++; i--;
for (; i >= 0; i--) sum += conv[i];
return sum;
}

int main() {
uint32_t sum1, sum2;
uint64_t m;
for (m = C_VALUELIMIT_INIT; m < (uint64_t) C_VALUELIMIT_FINIT; m++) {
convertBase(m, 2); sum1 = SumArray();
convertBase(m, 3); sum2 = SumArray(); if (sum1 != sum2) continue;
convertBase(m, 5); sum2 = SumArray(); if (sum1 != sum2) continue;
convertBase(m, 7); sum2 = SumArray(); if (sum1 != sum2) continue;
convertBase(m, 11); sum2 = SumArray(); if (sum1 != sum2) continue;
convertBase(m, 13); sum2 = SumArray(); if (sum1 != sum2) continue;
printf("Sequence number found %lld\n", m);
}
return 0;
}

Re: How to start with FPGA as "coprocessor"

<DiWlI.115577$OF5.62312@fx07.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=116&group=comp.arch.fpga#116

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx07.iad.POSTED!not-for-mail
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 28
Message-ID: <DiWlI.115577$OF5.62312@fx07.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 9 May 2021 14:59:46 -0400
X-Received-Bytes: 3477
 by: Richard Damon - Sun, 9 May 2021 18:59 UTC

On 5/9/21 2:21 PM, Nelson Ribeiro wrote:
> Hi Thomas.
>
> If I understood you correctly, what you want would be an FPGA engine/coprocessor that you make the equivalent calculations of the naïve C code that I have below. That is a pretty neat mathematical problem!
> I hope that you know a more efficient way of converting any number to a sequence of digits of a given base than the one I have written.
> The convertBase() algorithm that I wrote is not exactly FPGA friendly, but it can be managed to put in a FPGA in a efficient way with Dividers and Multipliers in pipeline maybe...
>
> My advice is to find some metrics that you want for a first smallish FPGA engine/coprocessor (like process 10M numbers per second, using up 2000LUTS, 500FFs, 2BRAMs, 4 mults 18x18). Any FPGA board should be good to start this project, but for a beginner it is better to use some streamline board. Then, it is a matter of replicating that FPGA engine/coprocessor and how much money you can afford in buying a board with big FPGA device or some cloud time in some FPGA cloud server. And it is possible that something that you can put to work at 100MHz in a cheap FPGA board, may run at 400MHz in a very expensive one...
>
> For "convertBase(m, 2); sum1 = SumArray();" you can use a pipelined 'popcount' arquitecture, for the other cases you may use pipelined tree adders (with a small numbers of bits this will be really fast). With pipeline, you can execute the section "SumArray();" as if it was being execute it in just one clock cycle at 100MHz or 200MHz or even more!
>
> The not so FPGA friendly part is really the "convertBase()" algorithm. That loop with a division (and a multiplication) is a bit troublesome... I hope you know better algorithm to perform this part. I can think in ways of using pipelined dividers... but most likely it is not the most efficient way...
>
> Regards,
> Nelson
>
>

I would NOT do a convertBase() type archtecture for the FPGA. It is just
too unfriendly.

My thought was to build a series of 'Base-X' counters/accumulators, in
the bases, 2, 3, 5, 7, 11, 13, 17. This is a fairly simple operation,
especially since the increment value will be a constant equal to the
number copies of the system. Start with them all at the same value (like
0) and just increment them by the same value expressed in their base.

This becomes an easy one cycle to update system.

Re: How to start with FPGA as "coprocessor"

<s79g7c$fb3$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=117&group=comp.arch.fpga#117

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 20:21:00 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s79g7c$fb3$1@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 9 May 2021 20:21:00 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="15715"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 9 May 2021 20:21 UTC

Nelson Ribeiro <ngrr.ribeiro@gmail.com> schrieb:

> If I understood you correctly, what you want would be an FPGA
> engine/coprocessor that you make the equivalent calculations
> of the naïve C code that I have below. That is a pretty neat
> mathematical problem!

Yep, it's neat. What I did worked for all primes up to 13,
but 17 is just too far off (so far).

> I hope that you know a more efficient way of converting any number
> to a sequence of digits of a given base than the one I have written.

In the immortal words of Henry S. Warren of "Hacker's Delight"
fame: "On many computers, division is very time consuming and is
to be avoided when possible."

He also gives a neat bag of tricks of calculating the division
remainder of many odd constants, by selectively summing their
digits. This works for numbers n where

2 ^ m = 1 (mod n)

so you can break your number into chunks of m bits, add them
together and still have the same remainder.

Once you have calculated the remainder by repeated addition of
these chunks to a size you can manage, you can then divide by
multiplying with the modular inverse of its number.

This will give you a single digit of your base n number, to
be repeated until the number has been converted to base n.
For base three, 4 = 3+1, so any grouping of bits with
an even number works.

I understand most FPGAs have six-bit lookup tables these days.
For calculating the remainder base three, that is actually
pretty handy - use 12*2 LUTs to reduce the bits from 72
to 24 in one go. Repeat, and you are left with 8 bits,
which is definitely managable.

Of course, then comes the 72*72 bit multiplication, which is
probably going to take some time...

Base 11 and 13 are less friendly, they would need 10 respectively
12 bit lookup tables.

> For "convertBase(m, 2); sum1 = SumArray();" you can use a
> pipelined 'popcount' arquitecture,

That is one thing I already looked at. There is a rather
elegant popcnt implementation using a 6-bit counter.

Re: How to start with FPGA as "coprocessor"

<s79hjk$fb3$2@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=118&group=comp.arch.fpga#118

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Sun, 9 May 2021 20:44:36 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s79hjk$fb3$2@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<DiWlI.115577$OF5.62312@fx07.iad>
Injection-Date: Sun, 9 May 2021 20:44:36 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="15715"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Sun, 9 May 2021 20:44 UTC

Richard Damon <Richard@Damon-Family.org> schrieb:

> My thought was to build a series of 'Base-X' counters/accumulators, in
> the bases, 2, 3, 5, 7, 11, 13, 17. This is a fairly simple operation,
> especially since the increment value will be a constant equal to the
> number copies of the system. Start with them all at the same value (like
> 0) and just increment them by the same value expressed in their base.

That sounds like a good possibility.

There is one important thing: It is possible to reduce the
amount of work done rather dramatically, and this is also
necessary.

Going to 2^64 with this problem (which I have already done) means
looking at around 1.84e19 numbers. Running at 500e6 Hz and doing
one test per cycle would lead to 3.7e10 seconds running time,
or about 1170 years. Too long.

The serial version of the code consists of nested loops running from
0 to 16. The sum of digits reached so far is easy to calculate,
just add the sum of the digits to the new one. The minimum number
of digits base 17 then is that sum.

It is then possible to calculate the maximum number of bits that the
binary representation in that range can have, and skip the loop
if that is too large.

Example: If the sum of the first five leading digits base 17 is 85,
there is no way that we will find a number with 72 bits whose
popcount is equal to 85.

That has saved a _lot_ of computing effort, at the cost of adding
some complexity to the program.

So, any counter will have to have some rather complicated logic
to make it skip the values where there cannot possibly be a match.

Re: How to start with FPGA as "coprocessor"

<b_XlI.361494$2N3.334291@fx33.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=119&group=comp.arch.fpga#119

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.uzoreto.com!fdc2.netnews.com!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx33.iad.POSTED!not-for-mail
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<s79g7c$fb3$1@newsreader4.netcologne.de>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s79g7c$fb3$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 8bit
Lines: 69
Message-ID: <b_XlI.361494$2N3.334291@fx33.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 9 May 2021 16:54:30 -0400
X-Received-Bytes: 4064
 by: Richard Damon - Sun, 9 May 2021 20:54 UTC

On 5/9/21 4:21 PM, Thomas Koenig wrote:
> Nelson Ribeiro <ngrr.ribeiro@gmail.com> schrieb:
>
>> If I understood you correctly, what you want would be an FPGA
>> engine/coprocessor that you make the equivalent calculations
>> of the naïve C code that I have below. That is a pretty neat
>> mathematical problem!
>
> Yep, it's neat. What I did worked for all primes up to 13,
> but 17 is just too far off (so far).
>
>> I hope that you know a more efficient way of converting any number
>> to a sequence of digits of a given base than the one I have written.
>
> In the immortal words of Henry S. Warren of "Hacker's Delight"
> fame: "On many computers, division is very time consuming and is
> to be avoided when possible."
>
> He also gives a neat bag of tricks of calculating the division
> remainder of many odd constants, by selectively summing their
> digits. This works for numbers n where
>
> 2 ^ m = 1 (mod n)
>
> so you can break your number into chunks of m bits, add them
> together and still have the same remainder.
>
> Once you have calculated the remainder by repeated addition of
> these chunks to a size you can manage, you can then divide by
> multiplying with the modular inverse of its number.
>
> This will give you a single digit of your base n number, to
> be repeated until the number has been converted to base n.
> For base three, 4 = 3+1, so any grouping of bits with
> an even number works.
>
> I understand most FPGAs have six-bit lookup tables these days.
> For calculating the remainder base three, that is actually
> pretty handy - use 12*2 LUTs to reduce the bits from 72
> to 24 in one go. Repeat, and you are left with 8 bits,
> which is definitely managable.
>
> Of course, then comes the 72*72 bit multiplication, which is
> probably going to take some time...
>
> Base 11 and 13 are less friendly, they would need 10 respectively
> 12 bit lookup tables.
>
>> For "convertBase(m, 2); sum1 = SumArray();" you can use a
>> pipelined 'popcount' arquitecture,
>
> That is one thing I already looked at. There is a rather
> elegant popcnt implementation using a 6-bit counter.
>

Unless the problem has something I am overlooking, there is no reason to
try to convert an 'aarbirary' number into the various bases.

If you start with the representation of the number X in these bases, it
is very simple to compute X+N in all the bases for a fixed number N. By
starting with N consecutive numbers precomputed in the bases (like the
numbers 1 to N), you would then step through all numbers above that
until some base overflows its storage.

No need for big multipliers or dividers, just simple constant
incrementers. For example, for the base 17 digits, represented with 5
bits, you just need the current 5 bit, the 1 bit carry in, and 5
CONSTANT increment value, so it is simple lookup for each bit. Maybe to
do a bit of work to optimize the carry chain for speed.

Re: How to start with FPGA as "coprocessor"

<4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=120&group=comp.arch.fpga#120

  copy link   Newsgroups: comp.arch.fpga
X-Received: by 2002:a37:9e12:: with SMTP id h18mr20138154qke.483.1620595292252;
Sun, 09 May 2021 14:21:32 -0700 (PDT)
X-Received: by 2002:ac8:7d95:: with SMTP id c21mr19421114qtd.11.1620595291994;
Sun, 09 May 2021 14:21:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!paganini.bofh.team!usenet.pasdenom.info!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.fpga
Date: Sun, 9 May 2021 14:21:31 -0700 (PDT)
In-Reply-To: <b_XlI.361494$2N3.334291@fx33.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=46.50.37.127; posting-account=TcK4egoAAAB3ZADM0uNZ59IgjnBMW3JT
NNTP-Posting-Host: 46.50.37.127
References: <s76amp$j6q$1@newsreader4.netcologne.de> <NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com> <s79g7c$fb3$1@newsreader4.netcologne.de>
<b_XlI.361494$2N3.334291@fx33.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
Subject: Re: How to start with FPGA as "coprocessor"
From: ngrr.rib...@gmail.com (Nelson Ribeiro)
Injection-Date: Sun, 09 May 2021 21:21:32 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Nelson Ribeiro - Sun, 9 May 2021 21:21 UTC

I agree with you Richard. I did not thought of that!
Its definitely a very efficient way to process like 200M 72-bit numbers per second (assuming 200MHz in a cheap modern FPGA device with some pipelining) with one small FPGA engine/coprocessor.

Re: How to start with FPGA as "coprocessor"

<NTZlI.76354$iT.55155@fx19.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=121&group=comp.arch.fpga#121

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx19.iad.POSTED!not-for-mail
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<s79g7c$fb3$1@newsreader4.netcologne.de> <b_XlI.361494$2N3.334291@fx33.iad>
<4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 26
Message-ID: <NTZlI.76354$iT.55155@fx19.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Sun, 9 May 2021 19:04:12 -0400
X-Received-Bytes: 2555
 by: Richard Damon - Sun, 9 May 2021 23:04 UTC

On 5/9/21 5:21 PM, Nelson Ribeiro wrote:
> I agree with you Richard. I did not thought of that!
> Its definitely a very efficient way to process like 200M 72-bit numbers per second (assuming 200MHz in a cheap modern FPGA device with some pipelining) with one small FPGA engine/coprocessor.
>

My guess is that that would be the processing rate for a single core
unit, which will take about 2k Luts.

Reasonable cheap FPGAs will likely handle a small multiple of that.

Maybe getting 10s of copies in middle sized but still reasonably priced.

This does assume that you will be just incrementing through the values.

IF you are able to skip large jumps, that might help you with a
different algorithm, and perhaps that would be worth it. If it is just
occational jumps of large values, perhaps giving up some number of
processors to have a unit that can compute the next possible value and
factor into the needed bases, and then restart there.

I suppose the big question is how big of gaps do you tend to find, If it
can jumps thousands of values, it could well be worth it, and I suppose
it well could be. I could see the binary represtation could establish an
upper bound for the sum of digits, and if higher order digits of some
base exceed that value, you know you need to increment till those
change, which could be a very big jump.

Re: How to start with FPGA as "coprocessor"

<s7am7o$6vd$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=122&group=comp.arch.fpga#122

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Mon, 10 May 2021 07:09:44 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s7am7o$6vd$1@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<s79g7c$fb3$1@newsreader4.netcologne.de> <b_XlI.361494$2N3.334291@fx33.iad>
<4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
<NTZlI.76354$iT.55155@fx19.iad>
Injection-Date: Mon, 10 May 2021 07:09:44 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd7-6262-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd7:6262:0:7285:c2ff:fe6c:992d";
logging-data="7149"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Mon, 10 May 2021 07:09 UTC

Richard Damon <Richard@Damon-Family.org> schrieb:
> I suppose the big question is how big of gaps do you tend to find, If it
> can jumps thousands of values, it could well be worth it, and I suppose
> it well could be. I could see the binary represtation could establish an
> upper bound for the sum of digits, and if higher order digits of some
> base exceed that value, you know you need to increment till those
> change, which could be a very big jump.

You are right, the gaps are indeed huge, and the gains enormous.

If I limit myself to 72 bits, I have around 4.72237E+21 possible
binary numbers, but "only" 2.91386E+18 eligible numbers base 17 which
have a sum of digits of 72 or less, so this is a reduction by
a factor of 1600 alone, more if you look at the actual ranges
rather than the maximum as I did above. For base 13, the factor
is around 120, for 11 it is 50.

Re: How to start with FPGA as "coprocessor"

<3t9mI.324320$2A5.91075@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=123&group=comp.arch.fpga#123

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!news-out.netnews.com!news.alt.net!fdc3.netnews.com!peer04.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
Subject: Re: How to start with FPGA as "coprocessor"
Newsgroups: comp.arch.fpga
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<s79g7c$fb3$1@newsreader4.netcologne.de> <b_XlI.361494$2N3.334291@fx33.iad>
<4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
<NTZlI.76354$iT.55155@fx19.iad> <s7am7o$6vd$1@newsreader4.netcologne.de>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.10.1
MIME-Version: 1.0
In-Reply-To: <s7am7o$6vd$1@newsreader4.netcologne.de>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 47
Message-ID: <3t9mI.324320$2A5.91075@fx45.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Mon, 10 May 2021 08:14:54 -0400
X-Received-Bytes: 3669
 by: Richard Damon - Mon, 10 May 2021 12:14 UTC

On 5/10/21 3:09 AM, Thomas Koenig wrote:
> Richard Damon <Richard@Damon-Family.org> schrieb:
>> I suppose the big question is how big of gaps do you tend to find, If it
>> can jumps thousands of values, it could well be worth it, and I suppose
>> it well could be. I could see the binary represtation could establish an
>> upper bound for the sum of digits, and if higher order digits of some
>> base exceed that value, you know you need to increment till those
>> change, which could be a very big jump.
>
> You are right, the gaps are indeed huge, and the gains enormous.
>
> If I limit myself to 72 bits, I have around 4.72237E+21 possible
> binary numbers, but "only" 2.91386E+18 eligible numbers base 17 which
> have a sum of digits of 72 or less, so this is a reduction by
> a factor of 1600 alone, more if you look at the actual ranges
> rather than the maximum as I did above. For base 13, the factor
> is around 120, for 11 it is 50.
>

It sounds like this skip will be key to processing, and I suspect that
only using the highest base will probably get you enough to be
practical, and will allow still good speed.

Build the system with 1 (small FPGA), 17 (medium FPGA), or 17^2 (large
FPGA) of these computation cores.

The incrementer rather than being a fixed increment gets the increment
to do from logic looking at the sum of the upper digits of the base 17
number of the first unit, and will add a power of 17 to the current
numbers in all the bases. You will just precompute the powers of 17 in
the bases you are using.

If you start at 0, then the first unit will only roll its upper digits
when all the digits below that digit are zero, so we can rapidly skip by
just adding repeatedly that power of 17 to the sum.

Yes, we could compute a multiple of that power to add to make that digit
roll to 0, but my first guess is that this very likely will cost us more
than the at most 16 cycles to wrap it (needing a number of base-k
multiplies), so better just punt and just add 17^n repeatedly to do it.

If you have only 1 unit, then you could get more complicated skip logic
and let the other bases inject their skips, but you need to be careful
about not lettin yourself add too much and go past the roll over point
as after a skip you might not be at the right nmultiple of the power of
thqt base. The question becomes if it is worth the complexity.

Re: How to start with FPGA as "coprocessor"

<s9clb1$c2c$1@newsreader4.netcologne.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=155&group=comp.arch.fpga#155

  copy link   Newsgroups: comp.arch.fpga
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!.POSTED.2001-4dd6-2e93-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de!not-for-mail
From: tkoe...@netcologne.de (Thomas Koenig)
Newsgroups: comp.arch.fpga
Subject: Re: How to start with FPGA as "coprocessor"
Date: Fri, 4 Jun 2021 07:39:13 -0000 (UTC)
Organization: news.netcologne.de
Distribution: world
Message-ID: <s9clb1$c2c$1@newsreader4.netcologne.de>
References: <s76amp$j6q$1@newsreader4.netcologne.de>
<NkVlI.87862$Sx7.57490@fx18.iad>
<ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com>
<s79g7c$fb3$1@newsreader4.netcologne.de> <b_XlI.361494$2N3.334291@fx33.iad>
<4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com>
<NTZlI.76354$iT.55155@fx19.iad> <s7am7o$6vd$1@newsreader4.netcologne.de>
<3t9mI.324320$2A5.91075@fx45.iad>
Injection-Date: Fri, 4 Jun 2021 07:39:13 -0000 (UTC)
Injection-Info: newsreader4.netcologne.de; posting-host="2001-4dd6-2e93-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de:2001:4dd6:2e93:0:7285:c2ff:fe6c:992d";
logging-data="12364"; mail-complaints-to="abuse@netcologne.de"
User-Agent: slrn/1.0.3 (Linux)
 by: Thomas Koenig - Fri, 4 Jun 2021 07:39 UTC

Richard Damon <Richard@Damon-Family.org> schrieb:
> On 5/10/21 3:09 AM, Thomas Koenig wrote:
>> Richard Damon <Richard@Damon-Family.org> schrieb:
>>> I suppose the big question is how big of gaps do you tend to find, If it
>>> can jumps thousands of values, it could well be worth it, and I suppose
>>> it well could be. I could see the binary represtation could establish an
>>> upper bound for the sum of digits, and if higher order digits of some
>>> base exceed that value, you know you need to increment till those
>>> change, which could be a very big jump.
>>
>> You are right, the gaps are indeed huge, and the gains enormous.
>>
>> If I limit myself to 72 bits, I have around 4.72237E+21 possible
>> binary numbers, but "only" 2.91386E+18 eligible numbers base 17 which
>> have a sum of digits of 72 or less, so this is a reduction by
>> a factor of 1600 alone, more if you look at the actual ranges
>> rather than the maximum as I did above. For base 13, the factor
>> is around 120, for 11 it is 50.
>>
>
> It sounds like this skip will be key to processing, and I suspect that
> only using the highest base will probably get you enough to be
> practical, and will allow still good speed.

Maybe a bit of an update here.

I have since implemented two algorithms which gave me an
enormous speedup on traditional CPUs.

Key to both algorithms is a function which returns the range of
the sums of digits base n between integers a and b. For base 2,
this is particularly efficient.

One method is a recursive binary search - given a range between a
and b, it checks if, for all bases looked at, the ranges of sums
of digits intersect. If they don't, return. If they do, partition
into two parts and look again for each one.

The second is the skip function you mentioned above. If it
is given a base-17 number like, it looks for the next largest
number with one more zero digit at the end, like this:

01 03 16 04 03
01 03 16 05 00
01 04 00 00 00
01 04 00 00 00
02 00 00 00 00

(have to watch for carries there) and tests at each stage if the
sum of digits base 2 in the range between the original number
and the new one is still valid.

This is _extremely_ efficient - at a high number range, this can
give skips of 17^10 or so. I alternate this base 17, base 13 and
base 11.

This has allowed me to find numbers which have the same
number of digits in base 17, 13, 11, 5 and 5 (not 3), like
7172806004621143883825103 (which is larger than 2^82). There are
very few of those, and none have so far had the same sum of digits
in base 3.

A key to speed is obviously the time in which a large number
in binary format can be converted into base n. Is an FPGA
the right tool for that?

Re: How to start with FPGA as "coprocessor"

<435f538f-2c80-424e-bbcb-f09d6092c1e8n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=156&group=comp.arch.fpga#156

  copy link   Newsgroups: comp.arch.fpga
X-Received: by 2002:ae9:e84f:: with SMTP id a76mr13599638qkg.366.1623167048214; Tue, 08 Jun 2021 08:44:08 -0700 (PDT)
X-Received: by 2002:ad4:4426:: with SMTP id e6mr684526qvt.46.1623167048015; Tue, 08 Jun 2021 08:44:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!tr3.eu1.usenetexpress.com!feeder.usenetexpress.com!tr2.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.arch.fpga
Date: Tue, 8 Jun 2021 08:44:07 -0700 (PDT)
In-Reply-To: <s9clb1$c2c$1@newsreader4.netcologne.de>
Injection-Info: google-groups.googlegroups.com; posting-host=188.140.96.223; posting-account=TcK4egoAAAB3ZADM0uNZ59IgjnBMW3JT
NNTP-Posting-Host: 188.140.96.223
References: <s76amp$j6q$1@newsreader4.netcologne.de> <NkVlI.87862$Sx7.57490@fx18.iad> <ab259ca5-a2c7-490d-a911-2710c4f80568n@googlegroups.com> <s79g7c$fb3$1@newsreader4.netcologne.de> <b_XlI.361494$2N3.334291@fx33.iad> <4e487200-ab78-4a99-8822-5cdb0b0ebe50n@googlegroups.com> <NTZlI.76354$iT.55155@fx19.iad> <s7am7o$6vd$1@newsreader4.netcologne.de> <3t9mI.324320$2A5.91075@fx45.iad> <s9clb1$c2c$1@newsreader4.netcologne.de>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <435f538f-2c80-424e-bbcb-f09d6092c1e8n@googlegroups.com>
Subject: Re: How to start with FPGA as "coprocessor"
From: ngrr.rib...@gmail.com (Nelson Ribeiro)
Injection-Date: Tue, 08 Jun 2021 15:44:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 65
 by: Nelson Ribeiro - Tue, 8 Jun 2021 15:44 UTC

Well, I personally don't know any algorithm to convert a "large number in binary format into any base n, with n being a prime number" that would be a good fit for FPGAs.
Naïve algorithms make use of division operations, and FPGA are not good at these operations.
But that skip method seems to be very promising... but it may need a lot of investigation/exploration/analysis/research from my point of view....But I really can see that the gain in skipping values is really major, I simply cannot think right now in a good "architecture" to implemented it!

What I can show you is where FPGAs shine. I wrote a module in Verilog code that can be synthesizable at 100 MHz (barely!) for a Zynq 7020 when retiming is used (basically I did not pipelined the design, but used some of the tools options that tries to do it for me) and that makes use of around 2100 LUTS.

The concept idea for the system would be the following:

There would be an application running in an PC (written in C, C#, Python, whatever language it would be preferred) that would create jobs to be distributed to boards with FPGA devices (either through Ethernet, or simply through UART). In a FPGA device it would exist at least one (Soft) processor connected to many of these modules, to which those jobs are distributed. These jobs would consist in 2 72-bit numbers, one at which the processing would start, another at which the processing would end. (The module requires that the Start Number would be converted to each n Base by the (Soft) Processor before it starts processing).

The description of the module is the following:

For each base (2, 3, 5, 7, 11, 13, 17) there is a counter of that base, which at every and each 1 clock cycle advances one unit. In pipeline and in parallel with these counters there is a tree of adders ( well for base 2 the popcount module is used) to sum up all the "digits" values of that number for each base. To avoid adders with more than 7 bits, overflow flag is used whenever a sum does not fit in 7 bits. At one point every adder of each base n is compared with each other. If none overflowed, and if all have the same value then this is a relevant value, and outputs this signal.

The module that I designed is not finished, is a proof of concept, it may have bugs, but has been designed to show how to generate sequences A135127, A212222, A335839 and the next sequence of “Integers whose sum of digits in base b is the same for every prime b up to 17.”
It can be found in: https://www.edaplayground.com/x/AUaM

For the people that will look into the code, sorry for the lack of comments… just wanted to try out some things. For instance, a counter with 72 bits running at 100MHz is not something that I have done in the past (for low end FPGAs), or tree adders with like 20 7-bit adders running at the same 100MHz… These would ideally be pipelined by hand, but I got away with the tools options, after inserting a few pipeline registers. The 100 MHz objective would be easier to achieve if less bits would be used…

One module like this would process 100M numbers per second, and for the A335839 sequence would process up to 4294899857375(base 10) in half a day (Am I doing the math correctly? 4294899857375 / 100000000 /3600/ 24 = 0.49709!)

Don’t know why your target is 72-bits and above, but with less bits (lets say 64-bits numbers) 100MHz would be better achievable, and in a 150€ FPGA board, it would fit 12/15 of these modules.

Regards,
Nelson

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor