Ejemplo n.º 1
0
 public static String cuDeviceGetName(CUdevice dev)
 {
     return Wrap(() =>
     {
         try
         {
             var deviceName_buf = new StringBuilder { Capacity = 255 };
             var error = nativeDeviceGetName(deviceName_buf, deviceName_buf.Capacity, dev);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
             return deviceName_buf.ToString();
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Ejemplo n.º 2
0
 private static CUcontext cuCtxCreate(CUctx_flags flags, CUdevice dev)
 {
     return Wrap(() =>
     {
         try
         {
             CUcontext ctx;
             var error = nativeCtxCreate(out ctx, flags, dev);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
             return ctx;
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Ejemplo n.º 3
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUDEVICE_gea189b5fe198ceb909f2a8bc3188e36f.html
 private static extern CUresult nativeDeviceGetName(StringBuilder name, int len, CUdevice dev);
Ejemplo n.º 4
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUDEVICE_g0864f76e0c101311b2e1eb5c40a54ea9.html
 private static extern CUresult nativeDeviceGet(out CUdevice device, int ordinal);
Ejemplo n.º 5
0
 public static uint cuDeviceTotalMem(CUdevice dev)
 {
     return Wrap(() =>
     {
         try
         {
             uint bytes;
             var error = nativeDeviceTotalMem(out bytes, dev);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
             return bytes;
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Ejemplo n.º 6
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUDEVICE_g7ff0e9bbf5268a053a77e7063b8a6bec.html
 private static extern CUresult nativeDeviceTotalMem(out uint bytes, CUdevice dev);
Ejemplo n.º 7
0
 public static bool cuDeviceGetFlag(CUdevice_attribute attrib, CUdevice dev)
 {
     var value = cuDeviceGetAttribute(attrib, dev);
     if (value == 0)
     {
         return false;
     }
     else if (value == 1)
     {
         return true;
     }
     else
     {
         var fex = new FormatException(String.Format("Attribute \"{0}\" has value \"{1}\" which isn't convertible to bool.", attrib, value));
         throw new CudaException(CudaError.InvalidValue, fex);
     }
 }
Ejemplo n.º 8
0
 public static int cuDeviceGetAttribute(CUdevice_attribute attrib, CUdevice dev)
 {
     return Wrap(() =>
     {
         try
         {
             int i;
             var error = nativeDeviceGetAttribute(out i, attrib, dev);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
             return i;
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Ejemplo n.º 9
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUDEVICE_ge283d0251a80fe5a82ec8f6e552eb248.html
 private static extern CUresult nativeDeviceGetAttribute(out int pi, CUdevice_attribute attrib, CUdevice dev);
Ejemplo n.º 10
0
 public static HardwareIsa cuDeviceComputeCapability(CUdevice dev)
 {
     return Wrap(() =>
     {
         try
         {
             int major, minor;
             var error = nativeDeviceComputeCapability(out major, out minor, dev);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
             return (HardwareIsa)(major * 10 + minor);
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Ejemplo n.º 11
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUDEVICE_g2f36c6412efa2b6b89feefa233fb7519.html
 private static extern CUresult nativeDeviceComputeCapability(out int major, out int minor, CUdevice dev);
Ejemplo n.º 12
0
 public bool Equals(CUdevice other)
 {
     return(other.Handle.Equals(Handle));
 }
Ejemplo n.º 13
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUCTX_g02b31a192b32043c0787696292f1ffbe.html
 private static extern CUresult nativeCtxCreate(out CUcontext pctx, CUctx_flags flags, CUdevice dev);
Ejemplo n.º 14
0
 public bool Equals(CUdevice other) { return other.Handle.Equals(Handle); }