Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8409303
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:52:16+00:00 2026-06-09T23:52:16+00:00

I am almost done with an algorithm that processes some very large integers (around

  • 0

I am almost done with an algorithm that processes some very large integers (around the order of 2 raised to the power 100,000,000). This takes a couple of hours of highly-parallel code on a 16 core server with more than adequate memory since the algorithm is not memory intensive. I make use of the BigInteger class in .NET 4.

The specifics of the algorithm are not important but for context, following is a pretty exhaustive list of operations performed on these integers and some salient features of the algorithm:

  • Addition / Subtraction.
  • Multiplication of large numbers by small numbers.
  • Division of large numbers by very small numbers (e.g. 2).
  • Base 2 Log.
  • Base 2 Power.
  • Comparison of two or more large numbers (Min/Max).
  • No involvement whatsoever of prime numbers.
  • The algorithm is specifically designed not to be memory intensive since the performance hit of memory access is more than that of some smart on-the-fly calculations. Nevertheless, if memory access were to improve, the algorithm could benefit reasonably.

I have optimized the code as much as possible and profiling now shows only two bottlenecks:

  • Calculating base 2 Log for such large numbers.
  • Checking for pre-defined patterns of binary digits in these numbers. This is because the only way to access the BigInteger underlying data is by first using ToByteArray rather than in-place operations. Also, operating on byte-sized chunks does not help performance.

Considering memory access and Log operations, I started thinking about GPUs and whether I could offload some of the work effectively. I know very little about GPUs except that they are optimized for floating point operations.

My question is, using a library like GPU .NET, how can I process such large numbers on the GPU? Can I somehow make use of the floating point optimizations to calculate Log for such large numbers?

Looking for a starting point to form a strategy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:52:18+00:00Added an answer on June 9, 2026 at 11:52 pm

    I am looking around for GPU work in C# and am considering Tidepowerd.com GPU.NET and CUDAfy.NET. Both Nvidia specific and CUDAfy did not (yet) support mono when I last checked. But they both allow for for reasonably normal looking code within C# that runs on the GPU.

    Also, did you consider using a 3d party library?. There are several very good BigInteger libraries, also open source. GMP is very good and free; http://gmplib.org/, there is at least one C# wrapper (which I have no experience with) http://www.emilstefanov.net/Projects/GnuMpDotNet/

    The BigInteger class in .NET is immutable and in my experience that is not handy. If you have 2 ints of your size (around 100MB) the Add operation results in a third 100MB BigInt. It can be done way faster if would for instance modify one of the two originals.

    C = A + B means allocating 100MB for C (this is what BigInt does)
    A = A + B means you no longer have the original A, but a much faster calculation
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to stack overflow I'm almost done with a programming problem that's been driving
I am so happy that my new game is almost done and close to
I am almost done with my project, but have one final looming problem that
I have a project that I am almost done with. One thing left that
Im almost done with a homework assignment that multiplies polynomials and has to have
I developed a desktop application, it's almost done but still contains some bugs which
I am in desperate need of some advice. I'm almost done with my junior
I'm almost done with an app and I noticed that it runs at about
I'm very new to Java and the Android SDK but I'm almost done with
I'm developing an android application and i'm almost done, and in order to have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.