Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TSCudaContext"/> class.
        /// </summary>
        public TSCudaContext()
        {
            try
            {
                this.deviceCount = CudaContext.GetDeviceCount();
            }
            catch
            {
                // CudaContext.GetDeviceCount() throws if CUDA drivers are not installed
                this.deviceCount = 0;
            }

            this.devices = Enumerable.Repeat(0, deviceCount)
                           .Select(x => new DeviceState(x))
                           .ToArray();

            if (deviceCount > 0)
            {
                p2pAccess = EnablePeerAccess(devices.Select(x => x.CudaContext).ToArray(), devices[0].CudaContext);
            }
            else
            {
                p2pAccess = new bool[0, 0];
            }

            this.diskCache = new RuntimeCompiler.KernelDiskCache(Path.Combine(Environment.CurrentDirectory, CacheDir));
            this.compiler  = new RuntimeCompiler.CudaCompiler(diskCache);

            OpRegistry.RegisterAssembly(Assembly.GetExecutingAssembly());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CudaCompiler"/> class.
 /// </summary>
 /// <param name="diskCache">The disk cache.</param>
 public CudaCompiler(KernelDiskCache diskCache)
 {
     this.diskCache = diskCache;
     RegisterAttributeHeaders(Assembly.GetExecutingAssembly());
 }