1

How do I get the CUDA cores count in jcuda?

I've tried this but it doesn't produce the right output:

int cudacount = cudaDeviceAttr.cudaDevAttrMultiProcessorCount;

It returns 16 but I have 1 Nvidia GPU with 640 cudacores.

The JavaDoc for the above property is available here. Any help will be appreciated.

Michael
  • 41,989
  • 11
  • 82
  • 128
  • it gets 16. but my nvidia gpu have only 1gpu and 640 cudacores (maxwell) – Sanjula Madumal Hewage Jul 06 '17 at 12:52
  • 1
    If you are getting 16 for that call, on a Maxwell GPU with 640 cudacores, then something is broken in that call or in your code or interpretation of it. You should be getting 5. I believe the posted answer is correct, but it won't give you the correct answer (640) if this call is actually returning 16. – Robert Crovella Jul 06 '17 at 14:01

1 Answers1

2

It seems that this answer does almost exactly what you want. It's written in C, and the types are slightly different, so here's a Java version (it's hardly any different):

int getSPCount()
{  
    final int mp    = cudaDeviceAttr.cudaDevAttrMultiProcessorCount;
    final int major = cudaDeviceAttr.cudaDevAttrComputeCapabilityMajor;
    final int minor = cudaDeviceAttr.cudaDevAttrComputeCapabilityMinor;

    switch (major)
    {
       case 2: // Fermi
           return (minor == 1) ? mp * 48 : mp * 32;
       case 3: // Kepler
           return mp * 192;
       case 5: // Maxwell
           return mp * 128;
       case 6: // Pascal
           if (minor == 1) {
               return mp * 128;
           }
           else if (minor == 0) {
               return mp * 64;
           }
    }
    throw new RuntimeException("Unknown device type");
}

Use this function like so:

int cudacount = getSPCount();
Michael
  • 41,989
  • 11
  • 82
  • 128