00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <string.h>
00021
00022 #if defined(__cplusplus)
00023 extern "C" {
00024 #endif
00025
00026 int vmd_cuda_num_devices(int *numdev) {
00027 if (cudaGetDeviceCount(numdev) != cudaSuccess) {
00028 *numdev = 0;
00029 return -1;
00030 }
00031
00032
00033 if (*numdev == 1) {
00034 cudaDeviceProp deviceProp;
00035 if (cudaGetDeviceProperties(&deviceProp, 0) != cudaSuccess) {
00036 *numdev = 0;
00037 return -1;
00038 }
00039
00040
00041 if (((deviceProp.major < 1) && (deviceProp.minor < 1)) ||
00042 ((deviceProp.major == 9999) && (deviceProp.minor == 9999))) {
00043 *numdev = 0;
00044 }
00045 }
00046
00047 return 0;
00048 }
00049
00050 int vmd_cuda_device_props(int dev, char *name, int namelen,
00051 int *revmajor, int *revminor,
00052 unsigned long *memb, int *clockratekhz,
00053 int *smcount, int *overlap) {
00054 cudaDeviceProp deviceProp;
00055 if (cudaGetDeviceProperties(&deviceProp, dev) != cudaSuccess)
00056 return -1;
00057
00058 strncpy(name, deviceProp.name, namelen);
00059 *revmajor = deviceProp.major;
00060 *revminor = deviceProp.minor;
00061 *memb = deviceProp.totalGlobalMem;
00062 *clockratekhz = deviceProp.clockRate;
00063 #if CUDART_VERSION >= 2000
00064 *smcount = deviceProp.multiProcessorCount;
00065 *overlap = (deviceProp.deviceOverlap != 0);
00066 #else
00067 *smcount = -1;
00068 *overlap = 0;
00069 #endif
00070
00071 return 0;
00072 }
00073
00074 #if defined(__cplusplus)
00075 }
00076 #endif
00077
00078