From ec2a96b0adc1c7c95791db4e43d084752159d153 Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Sun, 8 Oct 2023 07:29:55 -0400 Subject: [PATCH] Very small changes Considering ways to take the algorithm and turn it into OpenCL/Boost::Compute functions/code which would offer a large speed increase. Also, if I can figure out how to start from any arbitrary digit (which is supposed to be possible) then multi-threading would also give great speedups. --- .gitignore | 1 + Spigot.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/.gitignore b/.gitignore index a49b595..a53295d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +cfg/ *.txt main .gdb_history diff --git a/Spigot.cpp b/Spigot.cpp index 79228ed..2ddc522 100644 --- a/Spigot.cpp +++ b/Spigot.cpp @@ -15,6 +15,12 @@ void Spigot::pump(void) { int tempPreDigit = 0; int j = this->spigotListLength - 1; int i = j; + + /* + * This could be handled using boost::compute + * with a BOOST_COMPUTE_FUNCTION that just + * multiplies every item by 10. + */ while(i >= 0) { this->spigotList[i] *= 10; i--; @@ -22,6 +28,13 @@ void Spigot::pump(void) { this->carry = 0; i = j; // note this does *not* handle the i=0 case + /* + * This might also be able to be sped up + * with OpenCL/boost::compute by creating + * another custom function, but because + * the carry has to be passed along this might + * not work well + */ while(i > 0) { this->spigotList[i] += this->carry; this->carry = (this->spigotList[i] / (i * 2 + 1)) * i;