public TSCudaContext(int[] deviceIds)
        {
            //try
            //{
            //    this.deviceCount = CudaContext.GetDeviceCount();
            //}
            //catch
            //{
            //    // CudaContext.GetDeviceCount() throws if CUDA drivers are not installed
            //    this.deviceCount = 0;
            //}

            this.deviceIds = deviceIds;

            devices = new DeviceState[deviceIds.Length];
            for (int i = 0; i < deviceIds.Length; i++)
            {
                devices[i] = new DeviceState(deviceIds[i]);
            }


            //     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());
        }
Exemple #2
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());
        }
        public TSCudaContext(int[] deviceIds, float memoryUsageRatio = 0.9f, string[] compilerOptions = null)
        {
            this.deviceIds = deviceIds;

            devices = new DeviceState[deviceIds.Length];
            for (int i = 0; i < deviceIds.Length; i++)
            {
                devices[i] = new DeviceState(deviceIds[i], memoryUsageRatio);
            }
            p2pAccess = EnablePeerAccess(devices.Select(x => x.CudaContext).ToArray(), devices[0].CudaContext);

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

            OpRegistry.RegisterAssembly(Assembly.GetExecutingAssembly());
        }
 public CudaCompiler(KernelDiskCache diskCache)
 {
     this.diskCache = diskCache;
     RegisterAttributeHeaders(Assembly.GetExecutingAssembly());
 }
Exemple #5
0
 public CudaCompiler(KernelDiskCache diskCache, string[] options = null)
 {
     this.diskCache = diskCache;
     m_options      = options;
     RegisterAttributeHeaders(Assembly.GetExecutingAssembly());
 }