PAPI 7.1.0.0
Loading...
Searching...
No Matches
benchSANVML.c File Reference
Include dependency graph for benchSANVML.c:

Go to the source code of this file.

Data Structures

union  uPointer_t
 
union  convert_64_t
 

Macros

#define CUDAAPI   __attribute__((weak))
 
#define CUDARTAPI   __attribute__((weak))
 
#define DECLDIR   __attribute__((weak))
 
#define _prog_fprintf   if (1) fprintf /* change to 1 to enable printing of progress debug messages. TURN OFF if benchmark timing. */
 
#define _time_fprintf   if (1) fprintf /* change to 1 to enable printing of performance timings. TURN OFF if benchmark timing. */
 
#define mCheck_DL_Status(err, str)
 
#define STRINGIFY(x)   #x
 
#define TOSTRING(x)   STRINGIFY(x)
 
#define mGet_DL_FPtr(libPtr, Name)
 
#define hostnameLen   512 /* constant used multiple times. */
 

Functions

CUresult CUDAAPI cuInit (unsigned int myInt)
 
cudaError_t CUDARTAPI cudaGetDevice (int *dest)
 
cudaError_t CUDARTAPI cudaGetDeviceCount (int *dest)
 
cudaError_t CUDARTAPI cudaDeviceGetPCIBusId (char *, int, int)
 
const char *DECLDIR nvmlErrorString (nvmlReturn_t)
 
nvmlReturn_t DECLDIR nvmlDeviceGetClockInfo (nvmlDevice_t, nvmlClockType_t, unsigned int *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetCount (unsigned int *dest)
 
nvmlReturn_t DECLDIR nvmlDeviceGetDetailedEccErrors (nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, nvmlEccErrorCounts_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetEccMode (nvmlDevice_t, nvmlEnableState_t *, nvmlEnableState_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed (nvmlDevice_t, unsigned int *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetHandleByIndex (unsigned int idx, nvmlDevice_t *dest)
 
nvmlReturn_t DECLDIR nvmlDeviceGetInforomVersion (nvmlDevice_t, nvmlInforomObject_t, char *, unsigned int)
 
nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo (nvmlDevice_t, nvmlMemory_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetName (nvmlDevice_t device, char *name, unsigned int len)
 
nvmlReturn_t DECLDIR nvmlDeviceGetPciInfo (nvmlDevice_t, nvmlPciInfo_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetPerformanceState (nvmlDevice_t, nvmlPstates_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimit (nvmlDevice_t device, unsigned int *limit)
 
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimitConstraints (nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
 
nvmlReturn_t DECLDIR nvmlDeviceGetPowerUsage (nvmlDevice_t device, unsigned int *dest)
 
nvmlReturn_t DECLDIR nvmlDeviceGetTemperature (nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetTotalEccErrors (nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, unsigned long long *)
 
nvmlReturn_t DECLDIR nvmlDeviceGetUtilizationRates (nvmlDevice_t, nvmlUtilization_t *)
 
nvmlReturn_t DECLDIR nvmlDeviceSetPowerManagementLimit (nvmlDevice_t device, unsigned int limit)
 
nvmlReturn_t DECLDIR nvmlInit (void)
 
nvmlReturn_t DECLDIR nvmlShutdown (void)
 
int main (int argc, char **argv)
 

Variables

CUresult CUDAAPI(* cuInitPtr )(unsigned int)
 
cudaError_t(* cudaGetDevicePtr )(int *)
 
cudaError_t(* cudaGetDeviceCountPtr )(int *)
 
cudaError_t(* cudaDeviceGetPCIBusIdPtr )(char *, int, int)
 
char *(* nvmlErrorStringPtr )(nvmlReturn_t)
 
nvmlReturn_t(* nvmlDeviceGetClockInfoPtr )(nvmlDevice_t, nvmlClockType_t, unsigned int *)
 
nvmlReturn_t(* nvmlDeviceGetCountPtr )(unsigned int *dest)
 
nvmlReturn_t(* nvmlDeviceGetDetailedEccErrorsPtr )(nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, nvmlEccErrorCounts_t *)
 
nvmlReturn_t(* nvmlDeviceGetEccModePtr )(nvmlDevice_t, nvmlEnableState_t *, nvmlEnableState_t *)
 
nvmlReturn_t(* nvmlDeviceGetFanSpeedPtr )(nvmlDevice_t, unsigned int *)
 
nvmlReturn_t(* nvmlDeviceGetHandleByIndexPtr )(unsigned int, nvmlDevice_t *)
 
nvmlReturn_t(* nvmlDeviceGetInforomVersionPtr )(nvmlDevice_t, nvmlInforomObject_t, char *, unsigned int)
 
nvmlReturn_t(* nvmlDeviceGetMemoryInfoPtr )(nvmlDevice_t, nvmlMemory_t *)
 
nvmlReturn_t(* nvmlDeviceGetNamePtr )(nvmlDevice_t, char *, unsigned int)
 
nvmlReturn_t(* nvmlDeviceGetPciInfoPtr )(nvmlDevice_t, nvmlPciInfo_t *)
 
nvmlReturn_t(* nvmlDeviceGetPerformanceStatePtr )(nvmlDevice_t, nvmlPstates_t *)
 
nvmlReturn_t(* nvmlDeviceGetPowerManagementLimitConstraintsPtr )(nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
 
nvmlReturn_t(* nvmlDeviceGetPowerManagementLimitPtr )(nvmlDevice_t device, unsigned int *limit)
 
nvmlReturn_t(* nvmlDeviceGetPowerUsagePtr )(nvmlDevice_t, unsigned int *)
 
nvmlReturn_t(* nvmlDeviceGetTemperaturePtr )(nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *)
 
nvmlReturn_t(* nvmlDeviceGetTotalEccErrorsPtr )(nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, unsigned long long *)
 
nvmlReturn_t(* nvmlDeviceGetUtilizationRatesPtr )(nvmlDevice_t, nvmlUtilization_t *)
 
nvmlReturn_t(* nvmlDeviceSetPowerManagementLimitPtr )(nvmlDevice_t device, unsigned int limit)
 
nvmlReturn_t(* nvmlInitPtr )(void)
 
nvmlReturn_t(* nvmlShutdownPtr )(void)
 
static void * dl1 = NULL
 
static void * dl2 = NULL
 
static void * dl3 = NULL
 
static struct timeval t1 t2
 
void(* _dl_non_dynamic_init )(void)
 

Macro Definition Documentation

◆ _prog_fprintf

#define _prog_fprintf   if (1) fprintf /* change to 1 to enable printing of progress debug messages. TURN OFF if benchmark timing. */

Definition at line 154 of file benchSANVML.c.

◆ _time_fprintf

#define _time_fprintf   if (1) fprintf /* change to 1 to enable printing of performance timings. TURN OFF if benchmark timing. */

Definition at line 155 of file benchSANVML.c.

◆ CUDAAPI

#define CUDAAPI   __attribute__((weak))

Definition at line 46 of file benchSANVML.c.

◆ CUDARTAPI

#define CUDARTAPI   __attribute__((weak))

Definition at line 51 of file benchSANVML.c.

◆ DECLDIR

#define DECLDIR   __attribute__((weak))

Definition at line 62 of file benchSANVML.c.

◆ hostnameLen

#define hostnameLen   512 /* constant used multiple times. */

◆ mCheck_DL_Status

#define mCheck_DL_Status (   err,
  str 
)
Value:
if( err ) \
{ \
fprintf(stderr, str); \
return(-1); \
}
FILE * stderr

◆ mGet_DL_FPtr

#define mGet_DL_FPtr (   libPtr,
  Name 
)
Value:
Name##Ptr = dlsym(libPtr, TOSTRING(Name)); \
mCheck_DL_Status(dlerror()!=NULL, TOSTRING(libPtr) " Library function " \
TOSTRING(Name) " not found.");
#define TOSTRING(x)

◆ STRINGIFY

#define STRINGIFY (   x)    #x

◆ TOSTRING

#define TOSTRING (   x)    STRINGIFY(x)

Function Documentation

◆ cudaDeviceGetPCIBusId()

cudaError_t CUDARTAPI cudaDeviceGetPCIBusId ( char *  ,
int  ,
int   
)

◆ cudaGetDevice()

cudaError_t CUDARTAPI cudaGetDevice ( int dest)

Definition at line 57 of file benchSANVML.c.

57{return (*cudaGetDevicePtr)(dest); };
cudaError_t(* cudaGetDevicePtr)(int *)
Definition: benchSANVML.c:53
Here is the caller graph for this function:

◆ cudaGetDeviceCount()

cudaError_t CUDARTAPI cudaGetDeviceCount ( int dest)

Definition at line 58 of file benchSANVML.c.

58{return (*cudaGetDeviceCountPtr)(dest);}
cudaError_t(* cudaGetDeviceCountPtr)(int *)
Definition: benchSANVML.c:54
Here is the caller graph for this function:

◆ cuInit()

CUresult CUDAAPI cuInit ( unsigned int  myInt)

Definition at line 48 of file benchSANVML.c.

48{return (*cuInitPtr)(myInt);}
CUresult CUDAAPI(* cuInitPtr)(unsigned int)
Definition: benchSANVML.c:47
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 269 of file benchSANVML.c.

270{
271 (void) argc; (void) argv; // Prevent not used warning.
272 #define hostnameLen 512 /* constant used multiple times. */
273 char hostname[hostnameLen]; // host name.
274 int i, j, ret;
275 int cuda_count, nvml_count;
276 nvmlReturn_t nvret;
277 cudaError_t cuerr;
278
279 //-------------------------------------------------------------------
280 // Begin initialization timing.
281 //-------------------------------------------------------------------
282
283 gettimeofday(&t1, NULL);
285 if ( ret != 0) { // Failure to get lib.
286 fprintf(stderr, "Failed attempt to link to CUDA and NVML libraries.");
287 exit(-1);
288 }
289
290 _prog_fprintf(stderr, "Linked to CUDA and NVML libraries\n"); // debug only; turn off if timing.
291
292 nvret = nvmlInit(); // Initialize the library.
293 if (nvret != NVML_SUCCESS) {
294 fprintf(stderr, "Failed nvmlInit(), ret=%i [%s].\n", nvret, nvmlErrorString(nvret));
295 exit(-1);
296 }
297
298 nvret = cuInit(0); // Initialize the CUDA library.
299 if (nvret != cudaSuccess) {
300 fprintf(stderr, "Failed cuInit(0).\n");
301 exit(-1);
302 }
303
304 nvret = nvmlDeviceGetCount(&nvml_count); // Get the device count.
305 if (nvret != NVML_SUCCESS) {
306 fprintf(stderr, "nvmlDeviceGetCount failed; ret=%i.\n", nvret); // Report an error.
307 exit(-1);
308 }
309
310 nvret = cudaGetDeviceCount(&cuda_count); // Get the device count.
311 if (nvret != cudaSuccess) {
312 fprintf(stderr, "cudaGetDeviceCount failed; ret=%i.\n", nvret); // Report an error.
313 exit(-1);
314 }
315
316
317 ret = gethostname(hostname, hostnameLen); // Try to get the host hame.
318 if( gethostname(hostname, hostnameLen) != 0) { // If we can't get the hostname,
319 fprintf(stderr, "Failed system call, gethostname() "
320 "returned %i.", ret);
321 exit(-1);
322 }
323 #undef hostnameLen /* done with it. */
324
325 fprintf(stderr, "hostname: %s\n"
326 "nvml_count=%i\n"
327 "cuda_count=%i\n", hostname, nvml_count, cuda_count);
328
329 nvmlDevice_t *handle = malloc(nvml_count * sizeof(nvmlDevice_t)); // for all device handles.
330 char name[128]; // space for device name.
331 unsigned int powerUsage, powerLimit, powerLimit2; // for the power usage and limit.
332 unsigned int minPower, maxPower; // Minimum and Maximum power.
333
334 // scan all the devices.
335 for (i=0; i<nvml_count; i++) { // Get all the handles; print as we go.
336 nvret = nvmlDeviceGetHandleByIndex(i, &handle[i]); // Read the handle.
337 if (nvret != NVML_SUCCESS) {
338 fprintf(stderr, "nvmlDeviceGetHandleByIndex %i failed; nvret=%i [%s].\n", i, nvret, nvmlErrorString(nvret));
339 handle[i]=NULL; // Set to bad value.
340 continue; // skip trying this one.
341 }
342
343 fprintf(stderr, "Handle %i: %016lX\n", i, handle[i]); // Show the handles.
344
345 nvret = nvmlDeviceGetName(handle[i], name, sizeof(name)-1); // Get the name.
346 name[sizeof(name)-1]='\0'; // Ensure z-termination.
347 fprintf(stderr, "Name='%s'.\n", name); // Show the name.
348
349 nvret = nvmlDeviceGetPowerUsage(handle[i], &powerUsage); // Attempt to get power usage.
350 if (nvret != NVML_SUCCESS) { // If it failed,
351 fprintf(stderr, "nvmlDeviceGetPowerUsage failed; nvret=%i [%s]\n", nvret, nvmlErrorString(nvret));
352 } else {
353 fprintf(stderr, "nvmlDeviceGetPowerUsage succeeded, value returned=%u mw.\n", powerUsage);
354 }
355
356 nvret = nvmlDeviceGetPowerManagementLimit(handle[i], &powerLimit);// Attempt to get power limit.
357 if (nvret != NVML_SUCCESS) { // If it failed,
358 fprintf(stderr, "nvmlDeviceGetPowerManagementLimit failed; nvret=%i [%s]\n", nvret, nvmlErrorString(nvret));
359 } else {
360 fprintf(stderr, "nvmlDeviceGetPowerManagementLimit succeeded, value returned=%u mw.\n", powerLimit);
361 }
362
363 nvret = nvmlDeviceGetPowerManagementLimitConstraints(handle[i], &minPower, &maxPower);// Attempt to get min and max of power limit.
364 if (nvret != NVML_SUCCESS) { // If it failed,
365 fprintf(stderr, "nvmlDeviceGetPowerManagementLimitConstraints failed; nvret=%i [%s]\n", nvret, nvmlErrorString(nvret));
366 } else {
367 fprintf(stderr, "nvmlDeviceGetPowerManagementLimitConstraints succeeded, values min=%u mw, max=%u mw.\n", minPower, maxPower);
368 }
369
370 // Test setting the power, to top-100.
371 unsigned int newPower=maxPower-100; // compute a new power setting.
372 nvret = nvmlDeviceSetPowerManagementLimit(handle[i], newPower); // Attempt to set it.
373 if (nvret != NVML_SUCCESS) { // If it failed,
374 fprintf(stderr, "nvmlDeviceSetPowerManagementLimit to %i failed; nvret=%i [%s]\n", newPower, nvret, nvmlErrorString(nvret));
375 } else {
376 fprintf(stderr, "nvmlDeviceSetPowerManagementLimit to %i succeeded. (Routine call did not return error).\n", newPower);
377 }
378
379 nvret = nvmlDeviceGetPowerManagementLimit(handle[i], &powerLimit2); // Attempt to get new power limit.
380 if (nvret != NVML_SUCCESS) { // If it failed,
381 fprintf(stderr, "nvmlDeviceGetPowerManagementLimit failed; nvret=%i [%s]\n", nvret, nvmlErrorString(nvret));
382 } else {
383 fprintf(stderr, "nvmlDeviceGetPowerManagementLimit call to check setting succeeded, value returned=%u mw.\n", powerLimit2);
384 if (powerLimit2 != newPower) {
385 fprintf(stderr, "Note the check failed, the limit read is not the limit we tried to set.\n");
386 } else {
387 fprintf(stderr, "Note the check is a success, the power limit was changed.\n");
388 }
389 }
390
391 nvret = nvmlDeviceSetPowerManagementLimit(handle[i], powerLimit); // In case it works, set it back to where we found it.
392 if (nvret != NVML_SUCCESS) { // If it failed,
393 fprintf(stderr, "nvmlDeviceSetPowerManagementLimit to restore %i failed; nvret=%i [%s]\n", powerLimit, nvret, nvmlErrorString(nvret));
394 } else {
395 fprintf(stderr, "nvmlDeviceSetPowerManagementLimit to restore %i succeeded.\n", powerLimit);
396 }
397
398
399
400
401
402
403 } // end of loop through devices.
404
405
406
407
408 //-------------------------------------------------------------------
409 // Cleanup, and shutdown.
410 //-------------------------------------------------------------------
411
412 return 0;
413} // end MAIN routine.
static papi_handle_t handle
Definition: Gamum.c:21
int i
nvmlReturn_t DECLDIR nvmlDeviceGetPowerUsage(nvmlDevice_t device, unsigned int *dest)
Definition: benchSANVML.c:102
const char *DECLDIR nvmlErrorString(nvmlReturn_t)
CUresult CUDAAPI cuInit(unsigned int myInt)
Definition: benchSANVML.c:48
cudaError_t CUDARTAPI cudaGetDeviceCount(int *dest)
Definition: benchSANVML.c:58
nvmlReturn_t DECLDIR nvmlDeviceGetHandleByIndex(unsigned int idx, nvmlDevice_t *dest)
Definition: benchSANVML.c:92
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimitConstraints(nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
Definition: benchSANVML.c:100
nvmlReturn_t DECLDIR nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int len)
Definition: benchSANVML.c:95
#define _prog_fprintf
Definition: benchSANVML.c:154
nvmlReturn_t DECLDIR nvmlDeviceGetCount(unsigned int *dest)
Definition: benchSANVML.c:88
#define hostnameLen
nvmlReturn_t DECLDIR nvmlDeviceSetPowerManagementLimit(nvmlDevice_t device, unsigned int limit)
Definition: benchSANVML.c:107
nvmlReturn_t DECLDIR nvmlInit(void)
Definition: benchSANVML.c:109
nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimit(nvmlDevice_t device, unsigned int *limit)
Definition: benchSANVML.c:98
volatile double t1
static int _local_linkDynamicLibraries()
Definition: linux-libmsr.c:157
const char * name
Definition: rocs.c:225
Here is the call graph for this function:

◆ nvmlDeviceGetClockInfo()

nvmlReturn_t DECLDIR nvmlDeviceGetClockInfo ( nvmlDevice_t  ,
nvmlClockType_t  ,
unsigned int  
)

◆ nvmlDeviceGetCount()

nvmlReturn_t DECLDIR nvmlDeviceGetCount ( unsigned int dest)

Definition at line 88 of file benchSANVML.c.

88{return (*nvmlDeviceGetCountPtr)(dest);}
nvmlReturn_t(* nvmlDeviceGetCountPtr)(unsigned int *dest)
Definition: benchSANVML.c:66
Here is the caller graph for this function:

◆ nvmlDeviceGetDetailedEccErrors()

nvmlReturn_t DECLDIR nvmlDeviceGetDetailedEccErrors ( nvmlDevice_t  ,
nvmlEccBitType_t  ,
nvmlEccCounterType_t  ,
nvmlEccErrorCounts_t *   
)

◆ nvmlDeviceGetEccMode()

nvmlReturn_t DECLDIR nvmlDeviceGetEccMode ( nvmlDevice_t  ,
nvmlEnableState_t *  ,
nvmlEnableState_t *   
)

◆ nvmlDeviceGetFanSpeed()

nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed ( nvmlDevice_t  ,
unsigned int  
)

◆ nvmlDeviceGetHandleByIndex()

nvmlReturn_t DECLDIR nvmlDeviceGetHandleByIndex ( unsigned int  idx,
nvmlDevice_t *  dest 
)

Definition at line 92 of file benchSANVML.c.

92{return (*nvmlDeviceGetHandleByIndexPtr)(idx, dest); }
nvmlReturn_t(* nvmlDeviceGetHandleByIndexPtr)(unsigned int, nvmlDevice_t *)
Definition: benchSANVML.c:70
Here is the caller graph for this function:

◆ nvmlDeviceGetInforomVersion()

nvmlReturn_t DECLDIR nvmlDeviceGetInforomVersion ( nvmlDevice_t  ,
nvmlInforomObject_t  ,
char *  ,
unsigned int   
)

◆ nvmlDeviceGetMemoryInfo()

nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo ( nvmlDevice_t  ,
nvmlMemory_t *   
)

◆ nvmlDeviceGetName()

nvmlReturn_t DECLDIR nvmlDeviceGetName ( nvmlDevice_t  device,
char *  name,
unsigned int  len 
)

Definition at line 95 of file benchSANVML.c.

95{(*nvmlDeviceGetNamePtr)(device, name, len); }
Here is the caller graph for this function:

◆ nvmlDeviceGetPciInfo()

nvmlReturn_t DECLDIR nvmlDeviceGetPciInfo ( nvmlDevice_t  ,
nvmlPciInfo_t *   
)

◆ nvmlDeviceGetPerformanceState()

nvmlReturn_t DECLDIR nvmlDeviceGetPerformanceState ( nvmlDevice_t  ,
nvmlPstates_t *   
)

◆ nvmlDeviceGetPowerManagementLimit()

nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimit ( nvmlDevice_t  device,
unsigned int limit 
)

Definition at line 98 of file benchSANVML.c.

98 {
99 (*nvmlDeviceGetPowerManagementLimitPtr)(device, limit); }
Here is the caller graph for this function:

◆ nvmlDeviceGetPowerManagementLimitConstraints()

nvmlReturn_t DECLDIR nvmlDeviceGetPowerManagementLimitConstraints ( nvmlDevice_t  device,
unsigned int minLimit,
unsigned int maxLimit 
)

Definition at line 100 of file benchSANVML.c.

100 {
101 (*nvmlDeviceGetPowerManagementLimitConstraintsPtr)(device, minLimit, maxLimit); }
Here is the caller graph for this function:

◆ nvmlDeviceGetPowerUsage()

nvmlReturn_t DECLDIR nvmlDeviceGetPowerUsage ( nvmlDevice_t  device,
unsigned int dest 
)

Definition at line 102 of file benchSANVML.c.

102 {
103 (*nvmlDeviceGetPowerUsagePtr)(device, dest); }
Here is the caller graph for this function:

◆ nvmlDeviceGetTemperature()

nvmlReturn_t DECLDIR nvmlDeviceGetTemperature ( nvmlDevice_t  ,
nvmlTemperatureSensors_t  ,
unsigned int  
)

◆ nvmlDeviceGetTotalEccErrors()

nvmlReturn_t DECLDIR nvmlDeviceGetTotalEccErrors ( nvmlDevice_t  ,
nvmlEccBitType_t  ,
nvmlEccCounterType_t  ,
unsigned long long  
)

◆ nvmlDeviceGetUtilizationRates()

nvmlReturn_t DECLDIR nvmlDeviceGetUtilizationRates ( nvmlDevice_t  ,
nvmlUtilization_t *   
)

◆ nvmlDeviceSetPowerManagementLimit()

nvmlReturn_t DECLDIR nvmlDeviceSetPowerManagementLimit ( nvmlDevice_t  device,
unsigned int  limit 
)

Definition at line 107 of file benchSANVML.c.

107 {
108 (*nvmlDeviceSetPowerManagementLimitPtr)(device, limit); }
Here is the caller graph for this function:

◆ nvmlErrorString()

const char *DECLDIR nvmlErrorString ( nvmlReturn_t  )
Here is the caller graph for this function:

◆ nvmlInit()

nvmlReturn_t DECLDIR nvmlInit ( void  )

Definition at line 109 of file benchSANVML.c.

109{return (*nvmlInitPtr)();}
nvmlReturn_t(* nvmlInitPtr)(void)
Definition: benchSANVML.c:83
Here is the caller graph for this function:

◆ nvmlShutdown()

nvmlReturn_t DECLDIR nvmlShutdown ( void  )

Variable Documentation

◆ _dl_non_dynamic_init

void(* _dl_non_dynamic_init) (void) ( void  )

Definition at line 164 of file benchSANVML.c.

182 { \
183 fprintf(stderr, str); \
184 return(-1); \
185 }
186
187// keys for above: Init, InitThrd, InitCtlSt, Stop, ShutdownThrd, ShutdownCmp, Start,
188// UpdateCtl, Read, Ctl, SetDom, Reset, Enum, EnumFirst, EnumNext, EnumUmasks,
189// NameToCode, CodeToName, CodeToDesc, CodeToInfo.
190
191// Simplify routine below; relies on ptr names being same as func tags.
192#define STRINGIFY(x) #x
193#define TOSTRING(x) STRINGIFY(x)
194#define mGet_DL_FPtr(libPtr, Name) \
195 Name##Ptr = dlsym(libPtr, TOSTRING(Name)); \
196 mCheck_DL_Status(dlerror()!=NULL, TOSTRING(libPtr) " Library function " \
197 TOSTRING(Name) " not found.");
198
200{
201 if (_dl_non_dynamic_init != NULL) { // If weak var is present, we are statically linked instead of dynamically.
202 fprintf(stderr, "NVML component does not support statically linked libc.");
203 return (-1);
204 }
205
206 // Exit if we cannot link the cuda or NVML libs.
207 dl1 = dlopen("libcuda.so", RTLD_NOW | RTLD_GLOBAL);
208 if (!dl1) {
209 fprintf(stderr, "CUDA library libcuda.so not found.");
210 return (-1);
211 }
212
213 dl2 = dlopen("libcudart.so", RTLD_NOW | RTLD_GLOBAL | RTLD_NODELETE);
214 if (!dl2) {
215 fprintf(stderr, "CUDA runtime library libcudart.so not found.");
216 return (-1);
217 }
218
219 dl3 = dlopen("libnvidia-ml.so", RTLD_NOW | RTLD_GLOBAL);
220 if (!dl3) {
221 fprintf(stderr, "NVML runtime library libnvidia-ml.so not found.");
222 return (-1);
223 }
224
225//-----------------------------------------------------------------------------
226// Collect pointers for routines in shared library. All below will abort this
227// routine with -1, the routine is not found in the dynamic library.
228//-----------------------------------------------------------------------------
229
230//-----------------------------------------------------------------------------
231// Collect pointers for routines in shared library. All below will abort this
232// routine with -1, the routine is not found in the dynamic library.
233//-----------------------------------------------------------------------------
234
236
240
262
263 return 0; // If we get here, all above succeeded.
264} // end routine.
cudaError_t CUDARTAPI cudaGetDevice(int *dest)
Definition: benchSANVML.c:57
nvmlReturn_t DECLDIR nvmlDeviceGetTotalEccErrors(nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, unsigned long long *)
nvmlReturn_t DECLDIR nvmlDeviceGetInforomVersion(nvmlDevice_t, nvmlInforomObject_t, char *, unsigned int)
nvmlReturn_t DECLDIR nvmlDeviceGetClockInfo(nvmlDevice_t, nvmlClockType_t, unsigned int *)
nvmlReturn_t DECLDIR nvmlDeviceGetFanSpeed(nvmlDevice_t, unsigned int *)
nvmlReturn_t DECLDIR nvmlDeviceGetPerformanceState(nvmlDevice_t, nvmlPstates_t *)
static void * dl3
Definition: benchSANVML.c:115
nvmlReturn_t DECLDIR nvmlDeviceGetMemoryInfo(nvmlDevice_t, nvmlMemory_t *)
cudaError_t CUDARTAPI cudaDeviceGetPCIBusId(char *, int, int)
static void * dl2
Definition: benchSANVML.c:114
static void * dl1
Definition: benchSANVML.c:113
nvmlReturn_t DECLDIR nvmlDeviceGetPciInfo(nvmlDevice_t, nvmlPciInfo_t *)
nvmlReturn_t DECLDIR nvmlDeviceGetUtilizationRates(nvmlDevice_t, nvmlUtilization_t *)
nvmlReturn_t DECLDIR nvmlShutdown(void)
nvmlReturn_t DECLDIR nvmlDeviceGetDetailedEccErrors(nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, nvmlEccErrorCounts_t *)
nvmlReturn_t DECLDIR nvmlDeviceGetEccMode(nvmlDevice_t, nvmlEnableState_t *, nvmlEnableState_t *)
void(* _dl_non_dynamic_init)(void)
Definition: benchSANVML.c:164
#define mGet_DL_FPtr(libPtr, Name)
nvmlReturn_t DECLDIR nvmlDeviceGetTemperature(nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *)

◆ cudaDeviceGetPCIBusIdPtr

cudaError_t(* cudaDeviceGetPCIBusIdPtr) (char *, int, int) ( char *  ,
int  ,
int   
)

Definition at line 55 of file benchSANVML.c.

◆ cudaGetDeviceCountPtr

cudaError_t(* cudaGetDeviceCountPtr) (int *) ( int )

Definition at line 54 of file benchSANVML.c.

◆ cudaGetDevicePtr

cudaError_t(* cudaGetDevicePtr) (int *) ( int )

Definition at line 53 of file benchSANVML.c.

◆ cuInitPtr

CUresult CUDAAPI(* cuInitPtr) (unsigned int) ( unsigned int  )

Definition at line 47 of file benchSANVML.c.

◆ dl1

void* dl1 = NULL
static

Definition at line 113 of file benchSANVML.c.

◆ dl2

void* dl2 = NULL
static

Definition at line 114 of file benchSANVML.c.

◆ dl3

void* dl3 = NULL
static

Definition at line 115 of file benchSANVML.c.

◆ nvmlDeviceGetClockInfoPtr

nvmlReturn_t(* nvmlDeviceGetClockInfoPtr) (nvmlDevice_t, nvmlClockType_t, unsigned int *) ( nvmlDevice_t  ,
nvmlClockType_t  ,
unsigned int  
)

Definition at line 65 of file benchSANVML.c.

◆ nvmlDeviceGetCountPtr

nvmlReturn_t(* nvmlDeviceGetCountPtr) (unsigned int *dest) ( unsigned int dest)

Definition at line 66 of file benchSANVML.c.

◆ nvmlDeviceGetDetailedEccErrorsPtr

nvmlReturn_t(* nvmlDeviceGetDetailedEccErrorsPtr) (nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, nvmlEccErrorCounts_t *) ( nvmlDevice_t  ,
nvmlEccBitType_t  ,
nvmlEccCounterType_t  ,
nvmlEccErrorCounts_t *   
)

Definition at line 67 of file benchSANVML.c.

◆ nvmlDeviceGetEccModePtr

nvmlReturn_t(* nvmlDeviceGetEccModePtr) (nvmlDevice_t, nvmlEnableState_t *, nvmlEnableState_t *) ( nvmlDevice_t  ,
nvmlEnableState_t *  ,
nvmlEnableState_t *   
)

Definition at line 68 of file benchSANVML.c.

◆ nvmlDeviceGetFanSpeedPtr

nvmlReturn_t(* nvmlDeviceGetFanSpeedPtr) (nvmlDevice_t, unsigned int *) ( nvmlDevice_t  ,
unsigned int  
)

Definition at line 69 of file benchSANVML.c.

◆ nvmlDeviceGetHandleByIndexPtr

nvmlReturn_t(* nvmlDeviceGetHandleByIndexPtr) (unsigned int, nvmlDevice_t *) ( unsigned int  ,
nvmlDevice_t *   
)

Definition at line 70 of file benchSANVML.c.

◆ nvmlDeviceGetInforomVersionPtr

nvmlReturn_t(* nvmlDeviceGetInforomVersionPtr) (nvmlDevice_t, nvmlInforomObject_t, char *, unsigned int) ( nvmlDevice_t  ,
nvmlInforomObject_t  ,
char *  ,
unsigned int   
)

Definition at line 71 of file benchSANVML.c.

◆ nvmlDeviceGetMemoryInfoPtr

nvmlReturn_t(* nvmlDeviceGetMemoryInfoPtr) (nvmlDevice_t, nvmlMemory_t *) ( nvmlDevice_t  ,
nvmlMemory_t *   
)

Definition at line 72 of file benchSANVML.c.

◆ nvmlDeviceGetNamePtr

nvmlReturn_t(* nvmlDeviceGetNamePtr) (nvmlDevice_t, char *, unsigned int) ( nvmlDevice_t  ,
char *  ,
unsigned int   
)

Definition at line 73 of file benchSANVML.c.

◆ nvmlDeviceGetPciInfoPtr

nvmlReturn_t(* nvmlDeviceGetPciInfoPtr) (nvmlDevice_t, nvmlPciInfo_t *) ( nvmlDevice_t  ,
nvmlPciInfo_t *   
)

Definition at line 74 of file benchSANVML.c.

◆ nvmlDeviceGetPerformanceStatePtr

nvmlReturn_t(* nvmlDeviceGetPerformanceStatePtr) (nvmlDevice_t, nvmlPstates_t *) ( nvmlDevice_t  ,
nvmlPstates_t *   
)

Definition at line 75 of file benchSANVML.c.

◆ nvmlDeviceGetPowerManagementLimitConstraintsPtr

nvmlReturn_t(* nvmlDeviceGetPowerManagementLimitConstraintsPtr) (nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit) ( nvmlDevice_t  device,
unsigned int minLimit,
unsigned int maxLimit 
)

Definition at line 76 of file benchSANVML.c.

◆ nvmlDeviceGetPowerManagementLimitPtr

nvmlReturn_t(* nvmlDeviceGetPowerManagementLimitPtr) (nvmlDevice_t device, unsigned int *limit) ( nvmlDevice_t  device,
unsigned int limit 
)

Definition at line 77 of file benchSANVML.c.

◆ nvmlDeviceGetPowerUsagePtr

nvmlReturn_t(* nvmlDeviceGetPowerUsagePtr) (nvmlDevice_t, unsigned int *) ( nvmlDevice_t  ,
unsigned int  
)

Definition at line 78 of file benchSANVML.c.

◆ nvmlDeviceGetTemperaturePtr

nvmlReturn_t(* nvmlDeviceGetTemperaturePtr) (nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *) ( nvmlDevice_t  ,
nvmlTemperatureSensors_t  ,
unsigned int  
)

Definition at line 79 of file benchSANVML.c.

◆ nvmlDeviceGetTotalEccErrorsPtr

nvmlReturn_t(* nvmlDeviceGetTotalEccErrorsPtr) (nvmlDevice_t, nvmlEccBitType_t, nvmlEccCounterType_t, unsigned long long *) ( nvmlDevice_t  ,
nvmlEccBitType_t  ,
nvmlEccCounterType_t  ,
unsigned long long  
)

Definition at line 80 of file benchSANVML.c.

◆ nvmlDeviceGetUtilizationRatesPtr

nvmlReturn_t(* nvmlDeviceGetUtilizationRatesPtr) (nvmlDevice_t, nvmlUtilization_t *) ( nvmlDevice_t  ,
nvmlUtilization_t *   
)

Definition at line 81 of file benchSANVML.c.

◆ nvmlDeviceSetPowerManagementLimitPtr

nvmlReturn_t(* nvmlDeviceSetPowerManagementLimitPtr) (nvmlDevice_t device, unsigned int limit) ( nvmlDevice_t  device,
unsigned int  limit 
)

Definition at line 82 of file benchSANVML.c.

◆ nvmlErrorStringPtr

char *(* nvmlErrorStringPtr) (nvmlReturn_t) ( nvmlReturn_t  )

Definition at line 64 of file benchSANVML.c.

◆ nvmlInitPtr

nvmlReturn_t(* nvmlInitPtr) (void) ( void  )

Definition at line 83 of file benchSANVML.c.

◆ nvmlShutdownPtr

nvmlReturn_t(* nvmlShutdownPtr) (void) ( void  )

Definition at line 84 of file benchSANVML.c.

◆ t2

struct timeval t1 t2
static

Definition at line 117 of file benchSANVML.c.