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 5991963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:27:49+00:00 2026-05-22T23:27:49+00:00

I just managed to install my cuda SDK under Linux Ubuntu 10.04. My graphic

  • 0

I just managed to install my cuda SDK under Linux Ubuntu 10.04. My graphic card is an NVIDIA geForce GT 425M, and I’d like to use it for some heavy computational problem.
What I wonder is: is there any way to use some unsigned 128 bit int var? When using gcc to run my program on the CPU, I was using the __uint128_t type, but using it with cuda doesn’t seem to work.
Is there anything I can do to have 128 bit integers on cuda?

  • 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-05-22T23:27:49+00:00Added an answer on May 22, 2026 at 11:27 pm

    For best performance, one would want to map the 128-bit type on top of a suitable CUDA vector type, such as uint4, and implement the functionality using PTX inline assembly. The addition would look something like this:

    typedef uint4 my_uint128_t;
    __device__ my_uint128_t add_uint128 (my_uint128_t addend, my_uint128_t augend)
    {
        my_uint128_t res;
        asm ("add.cc.u32      %0, %4, %8;\n\t"
             "addc.cc.u32     %1, %5, %9;\n\t"
             "addc.cc.u32     %2, %6, %10;\n\t"
             "addc.u32        %3, %7, %11;\n\t"
             : "=r"(res.x), "=r"(res.y), "=r"(res.z), "=r"(res.w)
             : "r"(addend.x), "r"(addend.y), "r"(addend.z), "r"(addend.w),
               "r"(augend.x), "r"(augend.y), "r"(augend.z), "r"(augend.w));
        return res;
    }
    

    The multiplication can similarly be constructed using PTX inline assembly by breaking the 128-bit numbers into 32-bit chunks, computing the 64-bit partial products and adding them appropriately. Obviously this takes a bit of work. One might get reasonable performance at the C level by breaking the number into 64-bit chunks and using __umul64hi() in conjuction with regular 64-bit multiplication and some additions. This would result in the following:

    __device__ my_uint128_t mul_uint128 (my_uint128_t multiplicand, 
                                         my_uint128_t multiplier)
    {
        my_uint128_t res;
        unsigned long long ahi, alo, bhi, blo, phi, plo;
        alo = ((unsigned long long)multiplicand.y << 32) | multiplicand.x;
        ahi = ((unsigned long long)multiplicand.w << 32) | multiplicand.z;
        blo = ((unsigned long long)multiplier.y << 32) | multiplier.x;
        bhi = ((unsigned long long)multiplier.w << 32) | multiplier.z;
        plo = alo * blo;
        phi = __umul64hi (alo, blo) + alo * bhi + ahi * blo;
        res.x = (unsigned int)(plo & 0xffffffff);
        res.y = (unsigned int)(plo >> 32);
        res.z = (unsigned int)(phi & 0xffffffff);
        res.w = (unsigned int)(phi >> 32);
        return res;
    }
    

    Below is a version of the 128-bit multiplication that uses PTX inline assembly. It requires PTX 3.0, which shipped with CUDA 4.2, and the code requires a GPU with at least compute capability 2.0, i.e. a Fermi or Kepler class device. The code uses the minimal number of instructions, as sixteen 32-bit multiplies are needed to implement a 128-bit multiplication. By comparison, the variant above using CUDA intrinsics compiles to 23 instructions for an sm_20 target.

    __device__ my_uint128_t mul_uint128 (my_uint128_t a, my_uint128_t b)
    {
        my_uint128_t res;
        asm ("{\n\t"
             "mul.lo.u32      %0, %4, %8;    \n\t"
             "mul.hi.u32      %1, %4, %8;    \n\t"
             "mad.lo.cc.u32   %1, %4, %9, %1;\n\t"
             "madc.hi.u32     %2, %4, %9,  0;\n\t"
             "mad.lo.cc.u32   %1, %5, %8, %1;\n\t"
             "madc.hi.cc.u32  %2, %5, %8, %2;\n\t"
             "madc.hi.u32     %3, %4,%10,  0;\n\t"
             "mad.lo.cc.u32   %2, %4,%10, %2;\n\t"
             "madc.hi.u32     %3, %5, %9, %3;\n\t"
             "mad.lo.cc.u32   %2, %5, %9, %2;\n\t"
             "madc.hi.u32     %3, %6, %8, %3;\n\t"
             "mad.lo.cc.u32   %2, %6, %8, %2;\n\t"
             "madc.lo.u32     %3, %4,%11, %3;\n\t"
             "mad.lo.u32      %3, %5,%10, %3;\n\t"
             "mad.lo.u32      %3, %6, %9, %3;\n\t"
             "mad.lo.u32      %3, %7, %8, %3;\n\t"
             "}"
             : "=r"(res.x), "=r"(res.y), "=r"(res.z), "=r"(res.w)
             : "r"(a.x), "r"(a.y), "r"(a.z), "r"(a.w),
               "r"(b.x), "r"(b.y), "r"(b.z), "r"(b.w));
        return res;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started with JQuery and I've managed to pass a parameter using POST, firebug
I just need clarification on what a managed prototype is. I think it is
I just used Android SDK Manager to update Android SDK Tools to revision 17,
I can build a managed custom action just fine using the DTF tools (I.E
I have a fresh install of IIS 7 - I just added Web Platform
I just installed Ruby Version Manager 1.10.2 and attempted to install Ruby 1.9.2 and
I was trying to install RMR (RHadoop) package and I somehow managed to mess
I am fairly new to .NET development and have just installed a clean install
I just installed Oracle Weblogic 11g with the zip developper package on Linux. I
I managed to get a set of images loaded using Python. I'd like my

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.