Sanjula Madumal Hewage
Sanjula Madumal Hewage

Reputation: 150

How do you get CUDA cores count in jcuda?

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.

Upvotes: 1

Views: 329

Answers (1)

Michael
Michael

Reputation: 44090

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();

Upvotes: 2

Related Questions