Exemple #1
0
            public GlobalContext()
            {
                Log.EnsureBlankLine();
                Log.WriteLine("Acquiring number of CUDA-capable devices...");
                var deviceCount = cuDeviceGetCount();
                Log.WriteLine("{0} device(s) found.", cuDeviceGetCount());
                (deviceCount > 0).AssertTrue();

                Log.EnsureBlankLine();
                Log.WriteLine("Accessing device #0...");
                var device = CudaDevice.First;
                Log.WriteLine("Success.");

                Log.EnsureBlankLine();
                Log.WriteLine(device);

                Log.EnsureBlankLine();
                Log.WriteLine("Creating CUDA context for device #0...");
                _handle = cuCtxCreate(CUctx_flags.None, device.Handle);
                Log.WriteLine("Success.");
            }
Exemple #2
0
 private static void cuCtxDestroy(CUcontext ctx)
 {
     Wrap(() =>
     {
         try
         {
             var error = nativeCtxDestroy(ctx);
             if (error != CUresult.CUDA_SUCCESS) throw new CudaException(error);
         }
         catch (CudaException)
         {
             throw;
         }
         catch (DllNotFoundException dnfe)
         {
             throw new CudaException(CudaError.NoDriver, dnfe);
         }
         catch (Exception e)
         {
             throw new CudaException(CudaError.Unknown, e);
         }
     });
 }
Exemple #3
0
 public bool Equals(CUcontext other) { return other.Handle.Equals(Handle); }
Exemple #4
0
 // http://developer.download.nvidia.com/compute/cuda/3_1/toolkit/docs/online/group__CUCTX_g23bf81c24c28be3495fec41146f9e025.html
 private static extern CUresult nativeCtxDestroy(CUcontext ctx);
Exemple #5
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);
Exemple #6
0
 public bool Equals(CUcontext other)
 {
     return(other.Handle.Equals(Handle));
 }