I updated CUDA to version 13.
But it seems that cudaGetDeviceProperties has changed.
Instead of returning the cudaDeviceProp struct with clockRate, it returns a mutilated version thereof with deprecated fields missing.
struct __device_builtin__ cudaDeviceProp
{
char name[256]; /**< ASCII string identifying device */
cudaUUID_t uuid; /**< 16-byte unique identifier */
char luid[8]; /**< 8-byte locally unique identifier. Value is undefined on TCC and non-Windows platforms */
unsigned int luidDeviceNodeMask; /**< LUID device node mask. Value is undefined on TCC and non-Windows platforms */
size_t totalGlobalMem; /**< Global memory available on device in bytes */
size_t sharedMemPerBlock; /**< Shared memory available per block in bytes */
int regsPerBlock; /**< 32-bit registers available per block */
int warpSize; /**< Warp size in threads */
size_t memPitch; /**< Maximum pitch in bytes allowed by memory copies */
int maxThreadsPerBlock; /**< Maximum number of threads per block */
int maxThreadsDim[3]; /**< Maximum size of each dimension of a block */
int maxGridSize[3]; /**< Maximum size of each dimension of a grid */
//int clockRate is now missing...
size_t totalConstMem; /**< Constant memory available on device in bytes */
How do I get the clockRate from CUDA 13, now that NVidia has decided to remove these data members from the cudaDeviceProp struct?
Edit: looking at the old 12.3 data struct, I noticed that the missing fields were deprecated.
clockRate field was indeed depracated (used with cudaGetDeviceProperties) in CUDA 12.x, and removed in version 13.
In order to get the clock rate (in KHz) in version 13, you can do one of the following:
The simplest, as @paleonix commented, is to use cudaDeviceGetAttribute, with cudaDevAttrClockRate for the attr parameters.
(This is mentioned in the CUDA 13 release notes - see the section Removed Fields and Their Replacements):
int clockRateKHz;
cudaDeviceGetAttribute(&clockRateKHz, cudaDevAttrClockRate, 0); // 0 here is the device number
// do what you need with clockRateKHz
Note:
I omitted checking the cudaError_t status result for simplicity.
This should be done in the actual code.
Altenatively, you can use cuDeviceGetAttribute from the driver API (requires #include <cuda.h> and link with driver library - cuda.lib on Windows).
You need to use CU_DEVICE_ATTRIBUTE_CLOCK_RATE for the attrib parameter as shown below:
#include <cuda.h>
// ...
cuInit(0);
CUdevice device;
cuDeviceGet(&device, 0); // Or the index of the device you're interested in
int clockRateKHz;
cuDeviceGetAttribute(&clockRateKHz, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, device);
// do what you need with clockRateKHz
(again omitted checking the result of the API calls (with the CUresult status code) for simplicity).