public MultiRunGPUGravityModel(int length, Action<float> progressCallback = null, float epsilon = 0.8f, int maxIterations = 100) { var programPath = Assembly.GetEntryAssembly().CodeBase.Replace( "file:///", String.Empty ); try { this.gpu = new GPU(); } catch { throw new XTMFRuntimeException( "Unable to create a connection to the GPU, please make sure you are using a DirectX11+ card!" ); } Task initialize = new Task( delegate() { this.length = length; this.ProgressCallback = progressCallback; this.Epsilon = epsilon; this.MaxIterations = maxIterations; CreateBuffers(); } ); initialize.Start(); // while everything else is being initialized, compile the shader this.gravityModelShader = gpu.CompileComputeShader( Path.Combine( Path.GetDirectoryName( programPath ), "Modules", "GravityModel.hlsl" ), "CSMain" ); initialize.Wait(); if ( this.gravityModelShader == null ) { throw new XTMFRuntimeException( "Unable to compile GravityModel.hlsl!" ); } }
static void Main(string[] args) { PC pc = new PC(); GPU gpu = new GPU(); gpu.Name = "Titan X"; gpu.Memory = "12"; List<GPU> gpus = new List<GPU>(); gpus.Add(gpu); gpus.Add(gpu); RAM ram = new RAM(); RAM ram2 = new RAM(); List<RAM> rams = new List<RAM>(); ram.Memory = 8; ram2.Memory = 4; rams.Add(ram); rams.Add(ram); rams.Add(ram2); rams.Add(ram2); CPU cpu = new CPU(); cpu.Cores = 4; cpu.Speed = 3.5; pc.CPU = cpu; pc.GPU = gpus; pc.RAM = rams; pc.PrintData(); }
} //Dodaje produkt do bazy danych. public void EditProduct(GPU product) { var EfDbEntry = context.GPUs.FirstOrDefault(x => x.Product_ID == product.Product_ID); foreach (var property in EfDbEntry.GetType().GetProperties()) { property.SetValue(EfDbEntry, product.GetType().GetProperty(property.Name).GetValue(product)); } context.SaveChanges(); } //Edytuje produkt w bazie danych.
static async Task AmazonScrape() { var parser = new HtmlParser(); var page1 = "https://www.amazon.com/Graphics-Cards-Computer-Add-Ons-Computers/b/ref=dp_bc_4?ie=UTF8&node=284822"; ChromeOptions options = new ChromeOptions(); options.AddArgument("--headless"); IWebDriver chromeDriver = new ChromeDriver(options); var page = 1; chromeDriver.Url = page1 + "&page=" + page; bool pageLoading = true; while (page < 40) { string result = null; if (!pageLoading) { chromeDriver.Url = page1 + "&page=" + page; } result = chromeDriver.PageSource; var document = parser.Parse(result); var items = document.QuerySelectorAll(".s-item-container"); if (items.Length == 0) { pageLoading = true; continue; } pageLoading = false; GPU gpu = null; foreach (var item in items) { gpu = new GPU(); if (item.QuerySelector(".s-access-title") != null) { gpu.Card = item.QuerySelector(".s-access-title").TextContent; } else { continue; } if (item.QuerySelector(".sx-price-whole") != null) { gpu.Price = Double.Parse(item.QuerySelector(".sx-price-whole").TextContent) + Double.Parse(item.QuerySelector(".sx-price-fractional").TextContent); } gpu.Source = "Amazon"; gpu.ImageUrl = item.QuerySelector(".s-access-image").GetAttribute("src"); gpu.Url = item.QuerySelector(".a-link-normal").GetAttribute("href"); SQLInsert(gpu); } page++; } chromeDriver.Close(); }
public OpcodeTests() { var gpu = new GPU(); var cpu = new CPU(); var mmu = new MMU(); Bus.Init(cpu, gpu, mmu); _romReader = new Mock <IROMReader>(); _gameboy = new GameboyDevice(_romReader.Object); }
public BUS(GPU gpu, CDROM cdrom, SPU spu, JOYPAD joypad, TIMERS timers, MDEC mdec, InterruptController interruptController) { dma = new DMA(this); this.gpu = gpu; this.cdrom = cdrom; this.timers = timers; this.mdec = mdec; this.spu = spu; this.joypad = joypad; this.interruptController = interruptController; }
public ActionResult Create([Bind(Include = "GPUId,Name,GPULength,GPUWidth,GPUThick")] GPU gPU) { if (ModelState.IsValid) { db.GPUs.Add(gPU); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gPU)); }
public GPU DeleteGPU(Guid gpuId) { GPU dbEntry = context.GPUs.Find(gpuId); if (dbEntry != null) { context.GPUs.Remove(dbEntry); context.SaveChanges(); } return(dbEntry); }
public void UpdateGPUStats() { int NDevices = GPU.GetDeviceCount(); string[] Stats = new string[NDevices]; for (int i = 0; i < NDevices; i++) { Stats[i] = "GPU" + i + ": " + GPU.GetFreeMemory(i) + " MB"; } Runtime.GPUStats = string.Join(", ", Stats); }
public BUS(IHostWindow window, Controller controller, CDROM cdrom) { interruptController = new InterruptController(); dma = new DMA(this); gpu = new GPU(window); this.cdrom = cdrom; timers = new TIMERS(); joypad = new JOYPAD(controller); mdec = new MDEC(); spu = new SPU(); }
public ActionResult Create([Bind(Include = "GPUId,Nome,Preco")] GPU gpu) { if (ModelState.IsValid) { db.GPUs.Add(gpu); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(gpu)); }
public CreateViewModel() { Item = new Item(); CPU = new CPU(); CPUCooler = new CPUCooler(); GPU = new GPU(); Motherboard = new Motherboard(); PSU = new PSU(); RAM = new RAM(); Case = new Case(); }
public void Delete(string MaGPU) { if (MaGPU == null) { throw new ArgumentNullException(); } GPU gpu = context.GPUs.SingleOrDefault(r => r.MaGPU == MaGPU); context.GPUs.Remove(gpu); context.SaveChanges(); }
private void removeGPUButton_Click(object sender, EventArgs e) { for (int i = 0; i < gpuPanel.Controls.Count; i++) { if (((CheckBox)gpuPanel.Controls[i]).Checked == true) { GPU toBeDeleted = data.getGPU(i); data.removeGPU(toBeDeleted); } } loadCPUs(); }
static void Main(string[] args) { GPU gpu = new GPU(); // SAMPLE AND TEST CODE Vector vec = Vector.Linspace(gpu, 0, 25, 25, 5); Vector vec2 = Vector.Fill(gpu, 0, 25, 5); vec.Print(); vec2.Print(); Vector vecR = Vector.ConsecutiveOP(vec, vec2, "/"); vecR.Print(); //Vector vec2 = Vector.Fill(gpu, 8, 10, 2); //Vector vec3 = Vector.Fill(gpu, 8, 10, 2); //vec.Print(); //vec2.Print(); //vec._Append(vec2,'c'); //vec._Prepend(vec3, 'c'); //vec.Print(); //Vector.Append(vec, vec3, 'c').Print(); //Vector vectorA = Vector.Linspace(gpu, -100, -1, 100); //Vector vectorB = Vector.Linspace(gpu, -100, 100, 200); //Vector vectorC = Vector.Linspace(gpu, 100000000, 250000000, 100); //Vector vectorD = Vector.Linspace(gpu, -100000000, -250000000, 25); //Vector vectorE = Vector.Linspace(gpu, 100, -100, 201); //Vector vectorF = Vector.Linspace(gpu, 642.21f, 8412.1f, 55); //vectorB = Vector.Arange(gpu, -10, 10, 1); //vectorB.Print(); //Vector vectorD = Vector.Linspace(-5, 5, 10); //vectorA.Columns = 10; //vectorB.Columns = 10; //vectorC.Columns = 5; //vectorD.Columns = 5; //vectorE.Columns = 10; //vectorF.Columns = 11; //vectorD.Columns = 5; //vectorB.Print(); //Console.Write(vectorB.ToCSV()); //Console.WriteLine(); }
public void SetGPU(GPU _gpu) { gpu = _gpu; UIInGame.Instance.gpuMining.SetGPU(gpu); PlayDataManager.Instance.SaveGPU(gpu.id); if (mining != null) { StopCoroutine(mining); } mining = StartCoroutine(Mining()); }
public ActionResult Create([Bind(Exclude = "Id")] GPU gpuToCreate) { if (!ModelState.IsValid) { return(View()); } _db.AddToGPUSet(gpuToCreate); _db.SaveChanges(); return(RedirectToAction("Index")); }
public async Task <bool> CreateGPUPart(GPUServiceModel gPUServiceModel) { GPU gPUEntity = gPUServiceModel.To <GPU>(); gPUEntity.Id = Guid.NewGuid().ToString(); bool result = await this.pCCDbContext.AddAsync(gPUEntity) != null; await this.pCCDbContext.SaveChangesAsync(); return(result); }
public Computer(PowerSupply psu, Motherboard mb, Monitor monitor, RAM[] rams, GPU gpu, Keyboard kb = null, Mouse mouse = null, Headphone headphone = null, Microphone mic = null) { this.psu = psu; this.mb = mb; this.monitor = monitor; this.rams = rams; this.gpu = gpu; this.kb = kb; this.mouse = mouse; this.headphone = headphone; this.mic = mic; }
public static Matrix2D ScalerProduct(Matrix2D matrix1, Matrix2D matrix2) { if (matrix1.Columns != matrix2.Rows) { throw new ArithmeticException("Matrixes can not be multiplied - different amount of rows and columns"); } float[,] resultMatrix = new float[matrix1.Rows, matrix2.Columns]; GPU.matrixScalerProduct(matrix1.Matrix, matrix2.Matrix, resultMatrix, matrix1.Rows, matrix2.Columns, matrix1.Columns); return(new Matrix2D(resultMatrix)); }
public static void ForEachGPU <T>(IEnumerable <T> items, GPUTaskIterator <T> iterator, int perDevice = 1, List <int> deviceList = null) { int NDevices = GPU.GetDeviceCount(); if (deviceList == null) { deviceList = Helper.ArrayOfSequence(0, Math.Min(NDevices, items.Count()), 1).ToList(); } Queue <DeviceToken> Devices = new Queue <DeviceToken>(); for (int i = 0; i < perDevice; i++) { for (int d = deviceList.Count - 1; d >= 0; d--) { Devices.Enqueue(new DeviceToken(deviceList[d])); } } int NTokens = Devices.Count; foreach (var item in items) { while (Devices.Count <= 0) { Thread.Sleep(5); } DeviceToken CurrentDevice; lock (Devices) CurrentDevice = Devices.Dequeue(); Thread DeviceThread = new Thread(() => { GPU.SetDevice(CurrentDevice.ID % NDevices); iterator(item, CurrentDevice.ID); lock (Devices) Devices.Enqueue(CurrentDevice); }) { Name = $"ForEachGPU Device {CurrentDevice.ID}" }; DeviceThread.Start(); } while (Devices.Count != NTokens) { Thread.Sleep(5); } }
public void Post(GPU gpu) { string ID = "GP"; GPU GPULast = new GPU(); GPULast = context.GPUs.OrderByDescending(r => r.MaGPU).FirstOrDefault(); string temp = GPULast.MaGPU.ToString().Substring(2); temp = (Int32.Parse(temp) + 1).ToString(); if (temp.Count() == 4) { ID = ID + int.Parse(temp); } else if (temp.Count() == 3) { ID = ID + "0" + int.Parse(temp); } else if (temp.Count() == 2) { ID = ID + "00" + int.Parse(temp); } else { ID = ID + "000" + int.Parse(temp); } gpu.MaGPU = ID; GPU GPUNeedAdd = new GPU { MaGPU = gpu.MaGPU, HangSX = gpu.HangSX, HangChipset = gpu.HangSX, Model = gpu.Model, PCI = gpu.PCI, BoNho = Convert.ToInt32(gpu.BoNho), LoaiRam = gpu.LoaiRam, DienNang = Convert.ToInt32(gpu.DienNang), Diem = Convert.ToInt32(gpu.Diem), DanhGia = Convert.ToInt32(gpu.DanhGia), Giaban = Convert.ToInt32(gpu.Giaban), URL = gpu.URL }; if (gpu == null) { throw new ArgumentNullException(); } context.GPUs.Add(GPUNeedAdd); context.SaveChanges(); }
public Hardware() { Lib.Generic.Opcode.Open(); Lib.Generic.Ring0.Open(); this.drives = HardDrive.DetectDrives(); this.cpu = CPU.DetectCPU(); this.ram = Ram.DetectRam(); this.gpus = GPU.DetectGPUS(); this.envTempSensor = TempSensor.DetectSensor(); this.Update(); }
public static Matrix2D operator /(Matrix2D matrix1, Matrix2D matrix2) { if (matrix1.Rows != matrix2.Rows || matrix1.Columns != matrix2.Columns) { throw new ArgumentException(); } float[,] resultMatrix = new float[matrix1.Rows, matrix1.Columns]; GPU.matrixDivMatrix(matrix1.Matrix, matrix2.Matrix, resultMatrix, matrix1.Rows, matrix1.Columns); return(new Matrix2D(resultMatrix)); }
public BUS() { interruptController = new InterruptController(); //refactor this to interface and callbacks dma = new DMA(this); gpu = new GPU(); cdrom = new CDROM(); timers = new TIMERS(); joypad = new JOYPAD(); mdec = new MDEC(); initMem(); }
public GPUAnalyzer(GPU gpu, GPUAnalyzerSettings settings) { this.settings = settings; BusLoad = new SensoredThresholdProperty(gpu.BusLoad, settings.BusLoad); CoreClock = new SensoredThresholdProperty(gpu.CoreClock, settings.CoreClock); CoreLoad = new SensoredThresholdProperty(gpu.CoreLoad, settings.CoreLoad); CoreTemperature = new SensoredThresholdProperty(gpu.CoreTemperature, settings.CoreTemperature); FanSpeed = new SensoredThresholdProperty(gpu.FanSpeed, settings.FanSpeed); FrameBufferLoad = new SensoredThresholdProperty(gpu.FrameBufferLoad, settings.FrameBufferLoad); ShaderClock = new SensoredThresholdProperty(gpu.ShaderClock, settings.ShaderClock); VideoEngineLoad = new SensoredThresholdProperty(gpu.VideoEngineLoad, settings.VideoEngineLoad); }
public ActionResult GPU(GPU gpu) { newItem.GPU = gpu; // save to database DatabaseController db = new DatabaseController(); db.AddItem(newItem.Item, newItem.GPU); newItem = null; return(RedirectToAction("Index", "Inventory")); }
protected virtual void Dispose(bool userCalled) { if (this.gravityModelShader != null) { this.gravityModelShader.Dispose(); this.gravityModelShader = null; } if (this.gpu != null) { this.gpu.Dispose(); this.gpu = null; } }
public void Dispose() { if (DefectLocations != IntPtr.Zero) { GPU.FreeDevice(DefectLocations); DefectLocations = IntPtr.Zero; } if (DefectNeighbors != IntPtr.Zero) { GPU.FreeDevice(DefectNeighbors); DefectNeighbors = IntPtr.Zero; } }
static async Task NeweggScrape() { var parser = new HtmlParser(); var page1 = "https://www.newegg.com/Desktop-Graphics-Cards/SubCategory/ID-48/?recaptcha=pass&PageSize=96"; ChromeOptions options = new ChromeOptions(); options.AddArgument("--disable-javascript"); options.AddArgument("incognito"); options.AddArgument("--disable-bundled-ppapi-flash"); options.AddArgument("--disable-extensions"); //options.AddArgument("--headless"); options.PageLoadStrategy = (PageLoadStrategy)3; var rnd = new Random(); //options.AddArgument("--proxy-server=http://" + proxyList[rnd.Next(1,proxyList.Count - 1)]); IWebDriver chromeDriver = new ChromeDriver(options); string result = null; var page = 1; chromeDriver.Url = page1; while (page < 16) { var newUrl = "https://www.newegg.com/Desktop-Graphics-Cards/SubCategory/ID-48/" + "Page-" + page + "?&PageSize=96"; if (page != 1 && chromeDriver.Url != newUrl) { chromeDriver.Url = newUrl; } result = chromeDriver.PageSource; var document = parser.Parse(result); var items = document.QuerySelectorAll(".item-container"); if (items.Length < 90) { continue; } GPU gpu = null; foreach (var item in items) { gpu = new GPU(); gpu.Card = item.QuerySelector(".item-title").TextContent; if (item.QuerySelector(".price-current > strong") != null) { gpu.Price = Double.Parse(item.QuerySelector(".price-current > strong").TextContent) + Double.Parse(item.QuerySelector(".price-current > sup").TextContent); } gpu.Source = "Newegg"; gpu.Url = item.QuerySelector(".item-img").Attributes["href"].Value; gpu.ImageUrl = "http:" + item.QuerySelector(".item-img").FirstElementChild.Attributes["src"].Value; SQLInsert(gpu); } page++; } chromeDriver.Close(); }
/// <summary> /// El método acceptData creará una lista de productos /// y asignará esa lista a la lista para poder visualizar /// el detalle del pedido /// </summary> /// <remarks> /// Usando una observable collection, vamos a ir rellenando los datos /// Por otra parte, vamos a asignar a la variable order el Pedido. /// </remarks> /// <returns></returns> private async Task AcceptData() { //creamos una lista de objetos y la asignamos ObservableCollection <Producto> productList = new ObservableCollection <Producto>(); //obtenemos todos los datos de los productos if (pickerCpu.SelectedItem != null && pickerGpu.SelectedItem != null && pickerMotherBoard.SelectedItem != null && pickerPcBox.SelectedItem != null && pickerRam.SelectedItem != null) { CPU cpu = (CPU)pickerCpu.SelectedItem; GPU gpu = (GPU)pickerGpu.SelectedItem; MotherBoard board = (MotherBoard)pickerMotherBoard.SelectedItem; PcBox box = (PcBox)pickerPcBox.SelectedItem; Ram ram = (Ram)pickerRam.SelectedItem; double total; //creamos los productos productList.Add(new Producto { ProductName = cpu.Name, Price = cpu.Price }); productList.Add(new Producto { ProductName = gpu.Name, Price = gpu.Price }); productList.Add(new Producto { ProductName = board.Name, Price = board.Price }); productList.Add(new Producto { ProductName = box.Name, Price = box.Price }); productList.Add(new Producto { ProductName = ram.Name, Price = ram.Price }); //pasamos la lista al listView lstPedidos.ItemsSource = productList; //calculamos el total total = OperationUtils.GetTotalPrice(cpu, gpu, board, box, ram); lblTotal.Text = total.ToString(); order = new Pedido { IdCase = box.IdCase, IdCpu = cpu.IdCpu, IdGpu = gpu.IdGpu, IdMotherBoard = board.IdMotherBoard, IdRam = ram.IdRam, IdUser = user.IdUser, Price = total }; } }
Stack <int> stack; //Стек public CPU() { ram = new byte[4096]; stack = new Stack <int>(); regs = new byte[16]; now = 512; delaytimer = 0; soundtimer = 0; gpu = new GPU(); //timer = new System.Timers.Timer(16.666666); timer = new System.Timers.Timer(2); timer.Elapsed += new ElapsedEventHandler(TimerTick); timer.Start(); }
public List<GPUEnumerator.GPU> SuckInGPUs() { ErrorCode error; Platform[] platforms = Cl.GetPlatformIDs(out error); List<Device> devicesList = new List<Device>(); List<GPU> GPUList = new List<GPU>(); CheckErr(error, "Cl.GetPlatformIDs"); int id = 0; foreach (Platform platform in platforms) { //ToDO:Log Platform Device Name; // status = clGetPlatformInfo(platform, CL_PLATFORM_NAME, sizeof(pbuff), pbuff, NULL); // status = clGetPlatformInfo(platform, CL_PLATFORM_VERSION, sizeof(pbuff), pbuff, NULL); // status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices); //ToDO: Saved the compiled version so it can be built the next time as a binary: //ToDO: Enable certain cards, fan control, scheduling string platformName = Cl.GetPlatformInfo(platform, PlatformInfo.Name, out error).ToString(); Console.WriteLine("Platform: " + platformName); CheckErr(error, "Cl.GetPlatformInfo"); //We will be looking only for GPU devices foreach (OpenCL.Net.Device device in Cl.GetDeviceIDs(platform, DeviceType.Gpu, out error)) { CheckErr(error, "Cl.GetDeviceIDs"); Console.WriteLine("Device: " + device.ToString()); string vendor = Cl.GetDeviceInfo(device, OpenCL.Net.DeviceInfo.Vendor, out error).ToString(); string version = Cl.GetDeviceInfo(device, OpenCL.Net.DeviceInfo.Version, out error).ToString(); string name = Cl.GetDeviceInfo(device, OpenCL.Net.DeviceInfo.Name, out error).ToString(); string avail = Cl.GetDeviceInfo(device, OpenCL.Net.DeviceInfo.Available, out error).ToString(); GPU g = new GPU(); g.avail = false; if (avail == "") g.avail = true; g.id = id; g.name = name; g.version = version; g.vendor = vendor; id++; GPUList.Add(g); } } return GPUList; }
//void renderInfoPane(float left, float top, float width, float height Motherboard fabricateDebugRig() { Motherboard returnMobo = new Motherboard(); returnMobo.name = "Mother of All Boards"; CPU debugCPU = new CPU ("Hammond DebugHammer 750XL", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 30, 0, 1, 6, 32); GPU debugGPU = new GPU ("Zhu Industries Mothra 8800", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 20, 0, 3, 1); HDD debugHDD = new HDD ("DataPlatter Stack 5", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 2, 0, 10, 8); RAM debugRAM = new RAM ("RYAM Interceptor 1 MB", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 1, 0, 1, 10, 1); PowerSupply debugPower = new PowerSupply ("ArEmEs 200W Power Supply", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 200); CompInput debugInput = new CompInput ("Cobra Katana", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 50, 60, false); CompOutput debugOutput = new CompOutput ("AudiVisual AV2350", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 320, 30, 5); CompNetwork debugNet = new CompNetwork ("Digiline Dial-up Package", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, NetworkType.DIALUP, 40, 4); Chassis debugChassis = new Chassis ("CompuTech Tower of Power", Company.COMPUTECH, 125.0f, DEBUG_INTERFACE, 0, 0, 10); GPU badGPU = new GPU ("Bad GPU", Company.COMPUTECH, 125.0f, "Pudding Cup Interface", 20, 0, 3, 1); returnMobo.CPUInterface = DEBUG_INTERFACE; returnMobo.GPUInterface = DEBUG_INTERFACE; returnMobo.HDDInterface = DEBUG_INTERFACE; returnMobo.RAMInterface = DEBUG_INTERFACE; returnMobo.powerInterface = DEBUG_INTERFACE; returnMobo.compInputInterface = DEBUG_INTERFACE; returnMobo.compOutputInterface = DEBUG_INTERFACE; returnMobo.networkInterface = DEBUG_INTERFACE; returnMobo.formFactor = DEBUG_INTERFACE; returnMobo.plugIn(debugCPU); returnMobo.plugIn(debugGPU); returnMobo.plugIn(debugHDD); returnMobo.plugIn(debugRAM); returnMobo.plugIn(debugInput); returnMobo.plugIn(debugOutput); returnMobo.plugIn(debugNet); returnMobo.plugIn(debugPower); returnMobo.plugIn(debugChassis); return returnMobo; }
public object generatePart(Type partType, Company company) { object returnPart = null; if (partType == typeof(CPU)) { /* CPU = new CPU( generatePartName(partType, company), companyToString(company), 499.0f, "Generic Interface", 100, 1 ) * */ returnPart = new CPU(generatePartName(partType, company), company, 500.0f * (float)CPU[company] * (float)CPU[company], "Debug", 100 * (int)((float)CPU[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1), rand.Next(ranges.PE1980.cpu_ClockRange.getLeft(), ranges.PE1980.cpu_ClockRange.getRight() + 1), rand.Next(ranges.PE1980.cpu_BitsRange.getLeft(), ranges.PE1980.cpu_BitsRange.getRight() + 1) ); //returnPart = new CPU(generatePartName(partType, company), // company, // 500.0f * (float)CPU[company] * (float)CPU[company], // "Debug", // 100 * (int)((float)CPU[company] * 100.0f) / 100, // 1.0f, // rand.Next(ranges.PE1980.cpu_CoresRange.getLeft(), ranges.PE1980.cpu_CoresRange.getRight() + 1), 1, 1); } else if (partType == typeof(GPU)) { returnPart = new GPU(generatePartName(partType, company), company, 500.0f * (float)GPU[company] * (float)GPU[company], "Debug", 200 * (int)((float)GPU[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.gpu_MegaflopsRange.getLeft(), ranges.PE1980.gpu_MegaflopsRange.getRight() + 1), rand.Next(ranges.PE1980.gpu_MemoryRange.getLeft(), ranges.PE1980.gpu_MemoryRange.getRight() + 1) ); } else if (partType == typeof(HDD)) { returnPart = new HDD(generatePartName(partType, company), company, 500.0f * (float)HDD[company] * (float)HDD[company], "Debug", 5 * (int)((float)HDD[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.hdd_SizeRange.getLeft(), ranges.PE1980.hdd_SizeRange.getRight() + 1), rand.Next(ranges.PE1980.hdd_SpeedRange.getLeft(), ranges.PE1980.hdd_SpeedRange.getRight() + 1) ); } else if (partType == typeof(RAM)) { returnPart = new RAM(generatePartName(partType, company), company, 500.0f * (float)RAM[company] * (float)RAM[company], "Debug", 5 * (int)((float)RAM[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.ram_SizeRange.getLeft(), ranges.PE1980.ram_SizeRange.getRight() + 1), rand.Next(ranges.PE1980.ram_SpeedRange.getLeft(), ranges.PE1980.ram_SpeedRange.getRight() + 1), rand.Next(ranges.PE1980.ram_ChannelsRange.getLeft(), ranges.PE1980.ram_ChannelsRange.getRight() + 1) ); } else if (partType == typeof(CompInput)) { returnPart = new CompInput(generatePartName(partType, company), company, 500.0f * (float)INPUT[company] * (float)INPUT[company], "Debug", 5 * (int)((float)INPUT[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.input_DPIRange.getLeft(), ranges.PE1980.input_DPIRange.getRight() + 1), rand.Next(ranges.PE1980.input_PollingRange.getLeft(), ranges.PE1980.input_PollingRange.getRight() + 1), rand.Next(10) <= 7 ? false : true ); } else if (partType == typeof(CompOutput)) { returnPart = new CompOutput(generatePartName(partType, company), company, 500.0f * (float)OUTPUT[company] * (float)OUTPUT[company], "Debug", 50 * (int)((float)OUTPUT[company] * 100.0f) / 100, 1.0f, rand.Next(ranges.PE1980.output_ResolutionRange.getLeft(), ranges.PE1980.output_ResolutionRange.getRight() + 1), rand.Next(ranges.PE1980.output_RefreshRange.getLeft(), ranges.PE1980.output_RefreshRange.getRight() + 1), rand.Next(ranges.PE1980.output_SQRange.getLeft(), ranges.PE1980.output_SQRange.getRight() + 1) ); } else if (partType == typeof(CompNetwork)) { returnPart = new CompNetwork(generatePartName(partType, company), company, 500.0f * (float)NETWORK[company] * (float)NETWORK[company], "Debug", 0, 1.0f, rand.Next(2) == 0 ? ranges.PE1980.network_TypeRange.getLeft() : ranges.PE1980.network_TypeRange.getRight(), rand.Next(ranges.PE1980.network_PingRange.getLeft(), ranges.PE1980.network_PingRange.getRight() + 1), rand.Next(ranges.PE1980.network_BandwidthRange.getLeft(), ranges.PE1980.network_BandwidthRange.getRight() + 1) ); } else if (partType == typeof(PowerSupply)) { returnPart = new PowerSupply(generatePartName(partType, company), company, 500.0f * (float)PSU[company] * (float)PSU[company], "Debug", 0, 1.0f, rand.Next(ranges.PE1980.pSupply_WattageRange.getLeft(), ranges.PE1980.pSupply_WattageRange.getRight() + 1) ); } else if (partType == typeof(Chassis)) { returnPart = new Chassis(generatePartName(partType, company), company, 500.0f * (float)CHASSIS[company] * (float)CHASSIS[company], "Debug", 0, 1.0f, rand.Next(ranges.PE1980.chassis_CoolRange.getLeft(), ranges.PE1980.chassis_CoolRange.getRight() + 1) ); } else if (partType == typeof(Motherboard)) { returnPart = new Motherboard(generatePartName(partType, company), 500.0f * (float)MOBO[company] * (float)MOBO[company], 1.0f, "Debug", "Debug", "Debug", "Debug", "Debug", "Debug", "Debug", "Debug", "Debug", null, null, null, null, null, null, null, null, null ); } return returnPart; }
private int Balance(GPU gpu, ComputeShader gravityModelShader, GPUBuffer balancedBuffer, GPUBuffer parameters, float[] balanced, int iterations, int[] step1, int[] step2) { do { if ( this.ProgressCallback != null ) { this.ProgressCallback( (float)iterations / this.MaxIterations ); } gpu.Write( parameters, step1 ); // Compute Flows gpu.ExecuteComputeShader( gravityModelShader ); gpu.Write( parameters, step2 ); // Compute Residues and check to see if we are all balanced gpu.ExecuteComputeShader( gravityModelShader ); gpu.Read( balancedBuffer, balanced ); } while ( ( ++iterations ) < this.MaxIterations && balanced[0] == 0 ); if ( this.ProgressCallback != null ) { this.ProgressCallback( 1f ); } return iterations; }
protected virtual void Dispose(bool userCalled) { if ( this.gravityModelShader != null ) { this.gravityModelShader.Dispose(); this.gravityModelShader = null; } if ( this.gpu != null ) { this.gpu.Dispose(); this.gpu = null; } }
public GPU makeGPU() { newGPU = new MediaGPU(); return newGPU; }
public SparseTwinIndex<float> ProcessFlow(SparseArray<float> O, SparseArray<float> D) { float[] o = O.GetFlatData(); float[] d = D.GetFlatData(); var oLength = o.Length; var dLength = d.Length; var squareSize = oLength * dLength; float[] flows = new float[squareSize]; float[] residules = new float[dLength]; GPU gpu = new GPU(); string programPath; var codeBase = Assembly.GetEntryAssembly().CodeBase; try { programPath = Path.GetFullPath( codeBase ); } catch { programPath = codeBase.Replace( "file:///", String.Empty ); } // Since the modules are always located in the ~/Modules subdirectory for XTMF, // we can just go in there to find the script ComputeShader gravityModelShader = null; Task compile = new Task( delegate() { gravityModelShader = gpu.CompileComputeShader( Path.Combine( Path.GetDirectoryName( programPath ), "Modules", "GravityModel.hlsl" ), "CSMain" ); gravityModelShader.NumberOfXThreads = oLength; gravityModelShader.NumberOfYThreads = 1; gravityModelShader.ThreadGroupSizeX = 64; gravityModelShader.ThreadGroupSizeY = 1; } ); compile.Start(); GPUBuffer flowsBuffer = gpu.CreateBuffer( squareSize, 4, true ); GPUBuffer attractionStarBuffer = gpu.CreateBuffer( oLength, 4, true ); GPUBuffer balancedBuffer = gpu.CreateBuffer( 2, 4, true ); GPUBuffer productionBuffer = gpu.CreateBuffer( dLength, 4, false ); GPUBuffer attractionBuffer = gpu.CreateBuffer( oLength, 4, false ); GPUBuffer frictionBuffer = gpu.CreateBuffer( squareSize, 4, false ); GPUBuffer parameters = gpu.CreateConstantBuffer( 16 ); float[] balanced = new float[] { 0, this.Epsilon }; int iterations = 0; var step1 = new int[] { oLength, 0, this.MaxIterations }; var step2 = new int[] { oLength, 1, this.MaxIterations }; compile.Wait(); Stopwatch watch = new Stopwatch(); watch.Start(); FillAndLoadBuffers( o, d, Friction, gpu, gravityModelShader, flowsBuffer, attractionStarBuffer, balancedBuffer, productionBuffer, attractionBuffer, frictionBuffer, parameters, balanced ); if ( gravityModelShader == null ) { throw new XTMF.XTMFRuntimeException( "Unable to compile the GravityModel GPU Kernel!" ); } iterations = Balance( gpu, gravityModelShader, balancedBuffer, parameters, balanced, iterations, step1, step2 ); gpu.Read( flowsBuffer, flows ); gravityModelShader.RemoveAllBuffers(); watch.Stop(); using ( StreamWriter writer = new StreamWriter( "GPUPerf.txt", true ) ) { writer.Write( "Iteraions:" ); writer.WriteLine( iterations ); writer.Write( "Time(ms):" ); writer.WriteLine( watch.ElapsedMilliseconds ); } gravityModelShader.Dispose(); gpu.Release(); return BuildDistribution( O, D, oLength, flows ); }
public Motherboard(string name, float price, float defectiveChance, string CPUI, string GPUI, string HDDI, string RAMI, string powerI, string compInputI, string compOutputI, string networkI, string formFactor, CPU cpu, GPU gpu, HDD hdd, RAM ram, CompInput input, CompOutput output, CompNetwork network, PowerSupply pSupply, Chassis chassis) { this.name = name; this.price = price; this.defectiveChance = defectiveChance; this.CPUInterface = CPUI; this.GPUInterface = GPUI; this.HDDInterface = HDDI; this.RAMInterface = RAMI; this.powerInterface = powerI; this.compInputInterface = compInputI; this.compOutputInterface = compOutputI; this.networkInterface = networkI; this.formFactor = formFactor; this.cpu = cpu; this.gpu = gpu; this.hdd = hdd; this.ram = ram; this.input = input; this.output = output; this.network = network; this.pSupply = pSupply; this.chassis = chassis; }
public void Dispose() { if ( this.Gpu != null ) { this.Gpu.Dispose(); this.Gpu = null; } }
public void Start() { this.Gpu = new GPU(); if ( this.Gpu == null ) { throw new XTMFRuntimeException( "We were unable to initialize the connection to the GPU!" ); } TestWriting(); RunAddTest(); }
public GPU makeGPU() { newGPU = new FamilyGPU(); return newGPU; }
public GPU makeGPU() { newGPU = new LaptopGPU(); return newGPU; }
public bool plugIn(Part part) { bool returnValue = false; if (part.GetType() == typeof(CPU)) { if (part.partInterface == CPUInterface) { this.cpu = (CPU) part; returnValue = true; } } if (part.GetType() == typeof(GPU)) { if (part.partInterface == GPUInterface) { this.gpu = (GPU)part; returnValue = true; } } if (part.GetType() == typeof(HDD)) { if (part.partInterface == HDDInterface) { this.hdd = (HDD)part; returnValue = true; } } if (part.GetType() == typeof(RAM)) { if (part.partInterface == RAMInterface) { this.ram = (RAM)part; returnValue = true; } } if (part.GetType() == typeof(CompInput)) { if (part.partInterface == compInputInterface) { this.input = (CompInput)part; returnValue = true; } } if (part.GetType() == typeof(CompOutput)) { if (part.partInterface == compOutputInterface) { this.output = (CompOutput)part; returnValue = true; } } if (part.GetType() == typeof(CompNetwork)) { if (part.partInterface == networkInterface) { this.network = (CompNetwork) part; returnValue = true; } } if (part.GetType() == typeof(PowerSupply)) { if (part.partInterface == powerInterface) { this.pSupply = (PowerSupply)part; returnValue = true; } } if (part.GetType() == typeof(Chassis)) { if (part.partInterface == formFactor) { this.chassis = (Chassis)part; returnValue = true; } } return returnValue; }
private static void FillAndLoadBuffers(float[] o, float[] d, float[] Friction, GPU gpu, ComputeShader gravityModelShader, GPUBuffer flowsBuffer, GPUBuffer attractionStarBuffer, GPUBuffer balancedBuffer, GPUBuffer productionBuffer, GPUBuffer attractionBuffer, GPUBuffer frictionBuffer, GPUBuffer parameters, float[] balanced) { gpu.Write( balancedBuffer, balanced ); gpu.Write( productionBuffer, o ); gpu.Write( attractionBuffer, d ); gpu.Write( attractionStarBuffer, d ); gpu.Write( frictionBuffer, Friction ); // The order matters, needs to be the same as in the shader code!!! gravityModelShader.AddBuffer( parameters ); gravityModelShader.AddBuffer( flowsBuffer ); gravityModelShader.AddBuffer( attractionStarBuffer ); gravityModelShader.AddBuffer( balancedBuffer ); gravityModelShader.AddBuffer( productionBuffer ); gravityModelShader.AddBuffer( attractionBuffer ); gravityModelShader.AddBuffer( frictionBuffer ); }