Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

CUDAUtil.cu

Go to the documentation of this file.
00001 /***************************************************************************
00002  *cr
00003  *cr            (C) Copyright 1995-2008 The Board of Trustees of the
00004  *cr                        University of Illinois
00005  *cr                         All Rights Reserved
00006  *cr
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  * RCS INFORMATION:
00011  *
00012  *      $RCSfile: CUDAUtil.cu,v $
00013  *      $Author: johns $        $Locker:  $             $State: Exp $
00014  *      $Revision: 1.8 $        $Date: 2008/06/01 09:19:01 $
00015  *
00016  ***************************************************************************
00017  * DESCRIPTION:
00018  *   CUDA API wrapper for use by the CUDAAccel C++ class 
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   // Check for emulation mode 'device', and ignore it if found
00033   if (*numdev == 1) {
00034     cudaDeviceProp deviceProp;
00035     if (cudaGetDeviceProperties(&deviceProp, 0) != cudaSuccess) {
00036       *numdev = 0;
00037       return -1;
00038     }
00039 
00040     // disregard emulation mode as unusable for our purposes
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 

Generated on Mon Oct 13 01:27:26 2008 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002