public double[,] WeightInitialize(MemoryMode mm, string type)
        {
            double[,] _weights = new double[numofneurons, numofprevneurons];
            //WriteLine($"{type} weights are being initialized...");
            switch (mm)
            {
            case MemoryMode.GET:
                List <string> Strings = File.ReadAllLines($"{type}_memory.txt").ToList();
                int           Count   = 0;
                for (int l = 0; l < _weights.GetLength(0); ++l)
                {
                    for (int k = 0; k < _weights.GetLength(1); ++k)
                    {
                        //double buf = RandomProvider.GetRandom();
                        // _weights[l, k] = buf * 0.001;
                        _weights[l, k] = Convert.ToDouble(Strings[Count]);
                        Count++;
                    }
                }
                break;

            case MemoryMode.SET:
                for (int l = 0; l < Neurons.Length; ++l)
                {
                    for (int k = 0; k < numofprevneurons; ++k)
                    {
                    }
                }
                //memory_el.ChildNodes.Item(k + numofprevneurons * l).InnerText = Neurons[l].Weights[k].ToString();
                break;
            }
            //memory_doc.Save($"{type}_memory.xml");
            //WriteLine($"{type} weights have been initialized...");
            return(_weights);
        }
Exemple #2
0
        /// <summary>
        /// Чтение/запись весовых коэффициентов из/в файл(а).
        /// </summary>
        /// <param name="mm">Режим работы памяти.</param>
        /// <param name="type">азвание слоя.</param>
        /// <returns>Веса слоя.</returns>
        public double[,] WeightInitialize(MemoryMode mm, string type)
        {
            double[,] weights = new double[numofneurons, numofprevneurons + 1];
            XDocument memory_doc = XDocument.Load($@"Resources\{type}_memory.dat");
            long      count;

            switch (mm)
            {
            case MemoryMode.GET:
                count = -1;
                foreach (XElement el in memory_doc.Element("weights").Elements("weight"))
                {
                    count++;
                    int k = (int)(count / weights.GetLength(1));
                    weights[k, count - k * weights.GetLength(1)] = Convert.ToDouble(el.Value);
                }
                break;

            case MemoryMode.SET:
                count = -1;
                foreach (XElement el in memory_doc.Element("weights").Elements("weight"))
                {
                    count++;
                    int k = (int)(count / weights.GetLength(1));
                    el.Value = Neurons[k].Weights[count - k * weights.GetLength(1)].ToString();
                }
                break;
            }
            memory_doc.Save($@"Resources\{type}_memory.dat");
            return(weights);
        }
Exemple #3
0
        protected override void PageLoadedCore(PageLoadedDirection direction)
        {
            if (SelectedTemplate == Template)
            {
                return;
            }

            initialising = true;

            Template = SelectedTemplate;
            if (Template.has_ballooning() && !Helpers.FeatureForbidden(Template, Host.RestrictDMC))
            {
                memoryMode = Template.memory_dynamic_max == Template.memory_static_max ? MemoryMode.MinimumAndMaximum : MemoryMode.MinimumMaximumAndStaticMax;
            }
            else
            {
                memoryMode = MemoryMode.JustMemory;
            }

            memoryRatio = VMMemoryControlsEdit.GetMemoryRatio(Template);

            FreeSpinnerLimits();

            if (memoryMode == MemoryMode.JustMemory)
            {
                spinnerDynMin.Initialize(Template.memory_static_max, Template.memory_static_max);
                labelDynMin.Text = Messages.MEMORY_COLON;
            }
            else
            {
                labelDynMin.Text = Messages.DYNAMIC_MIN_COLON;
                spinnerDynMin.Initialize(Template.memory_dynamic_min, Template.memory_static_max);
                FreeSpinnerLimits();  // same as CA-33831
                spinnerDynMax.Initialize(Template.memory_dynamic_max, Template.memory_static_max);
                if (memoryMode == MemoryMode.MinimumMaximumAndStaticMax)
                {
                    FreeSpinnerLimits();
                    spinnerStatMax.Initialize(Template.memory_static_max, Template.memory_static_max);
                }
            }
            labelDynMaxInfo.Visible  = labelDynMax.Visible = spinnerDynMax.Visible = memoryMode == MemoryMode.MinimumAndMaximum || memoryMode == MemoryMode.MinimumMaximumAndStaticMax;
            labelStatMaxInfo.Visible = labelStatMax.Visible = spinnerStatMax.Visible = memoryMode == MemoryMode.MinimumMaximumAndStaticMax;

            isVcpuHotplugSupported = Template.SupportsVcpuHotplug();
            minVCPUs = Template.MinVCPUs();

            _prevVCPUsMax = Template.VCPUs_max;  // we use variable in RefreshCurrentVCPUs for checking if VcpusAtStartup and VcpusMax were equal before VcpusMax changed

            label5.Text = GetRubric();

            InitialiseVcpuControls();

            SetSpinnerLimitsAndIncrement();

            ValuesUpdated();

            initialising = false;
        }
Exemple #4
0
        private static IntPtr Create(IntPtr data, int length, MemoryMode mode, object context, ReleaseDelegate releaseProc)
        {
            var del = releaseProc != null && context != null
                                ? new ReleaseDelegate((_) => releaseProc(context))
                                : releaseProc;
            var proxy = DelegateProxies.Create(del, DelegateProxies.ReleaseDelegateProxy, out _, out var ctx);

            return(HarfBuzzApi.hb_blob_create(data, length, mode, ctx, proxy));
        }
Exemple #5
0
 private static IntPtr Create(IntPtr data, uint length, MemoryMode mode, object user_data, BlobReleaseDelegate releaseProc)
 {
     if (releaseProc == null)
     {
         return(HarfBuzzApi.hb_blob_create(data, length, mode, IntPtr.Zero, IntPtr.Zero));
     }
     else
     {
         var ctx = new NativeDelegateContext(user_data, releaseProc);
         return(HarfBuzzApi.hb_blob_create(data, length, mode, ctx.NativeContext, destroy_func));
     }
 }
Exemple #6
0
 private static IntPtr Create(IntPtr data, int length, MemoryMode mode, object context, ReleaseDelegate releaseProc)
 {
     if (releaseProc == null)
     {
         return(HarfBuzzApi.hb_blob_create(data, length, mode, IntPtr.Zero, IntPtr.Zero));
     }
     else
     {
         var ctx = new NativeDelegateContext(context, releaseProc);
         return(HarfBuzzApi.hb_blob_create(data, length, mode, ctx.NativeContext, DestroyFunction.NativePointer));
     }
 }
Exemple #7
0
        public MemoryBankController(RomInfo romInfo)
        {
            ri = romInfo;

            Eram = new byte[romInfo.RamSize.Size];
            Wram = new byte[0x1FFF];
            Zram = new byte[128];

            Rombank       = 0;
            RamBank       = 0;
            ExternalRamOn = false;
            Mode          = MemoryMode.M16_8;
        }
Exemple #8
0
        /// <summary>
        /// Функция для сохранения или загрузки весов
        /// </summary>
        /// <param name="mm">Параметр для сохранения или загрузки</param>
        /// <param name="type"></param>
        /// <returns></returns>
        public double[,] WeightInitialize(MemoryMode mm, string type)
        {
            double[,] _weights = new double[numberOfNeurons, numerOfPreviousNeurons];
            Console.WriteLine($"{type} weights are being initialized...");
            XmlDocument memory_doc = new XmlDocument();

            memory_doc.Load($"{type}_memory.xml");
            XmlElement memory_el = memory_doc.DocumentElement;

            switch (mm)
            {
            case MemoryMode.GET:
                for (int l = 0; l < _weights.GetLength(0); ++l)
                {
                    for (int k = 0; k < _weights.GetLength(1); ++k)
                    {
                        _weights[l, k] = double.Parse(memory_el.ChildNodes.Item(k + _weights.GetLength(1) * l).InnerText.Replace(',', '.'), System.Globalization.CultureInfo.InvariantCulture);
                    }
                }
                break;

            case MemoryMode.SET:
                for (int l = 0; l < Neurons.Length; ++l)
                {
                    for (int k = 0; k < numerOfPreviousNeurons; ++k)
                    {
                        memory_el.ChildNodes.Item(k + numerOfPreviousNeurons * l).InnerText = Neurons[l].Weights[k].ToString();
                    }
                }
                break;

            case MemoryMode.DROP:
                for (int l = 0; l < Neurons.Length; ++l)
                {
                    for (int k = 0; k < numerOfPreviousNeurons; ++k)
                    {
                        memory_el.ChildNodes.Item(k + numerOfPreviousNeurons * l).InnerText = "0";
                    }
                }
                break;
            }
            memory_doc.Save($"{type}_memory.xml");
            Console.WriteLine($"{type} weights have been initialized...");
            return(_weights);
        }
Exemple #9
0
        private void TestBandwidth(Context context, Device[] devices, int start, int end, int increment, TestMode testMode, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            switch (testMode)
            {
            case TestMode.Quick:
                TestBandwidthQuick(context, devices, DefaultSize, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Range:
                TestBandwidthRange(context, devices, start, end, increment, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Shmoo:
                TestBandwidthShmoo(context, devices, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            default:
                break;
            }
        }
 private long IntCode_GetValue_Write(MemoryMode memoryMode, int position, List <long> input, int relativeBase)
 {
     IntCode_AddressCheck(position, input);
     if (memoryMode == MemoryMode.Position)
     {
         var address = (int)input[position];
         IntCode_AddressCheck(address, input);
         return(address);
     }
     if (memoryMode == MemoryMode.Immidiate)
     {
         return(input[position]);
     }
     if (memoryMode == MemoryMode.Relative)
     {
         var address = relativeBase + (int)input[position];
         IntCode_AddressCheck(address, input);
         return(address);
     }
     throw new Exception();
 }
Exemple #11
0
        public double[,] WeightInitialize(MemoryMode mm, string type)
        {
            var _weights = new double[numofneurons, numofprevneurons];

            Console.WriteLine($"{type} weights are being initialized...");
            var memory_doc = new XmlDocument();

            memory_doc.Load($"{type}_memory.xml");
            var memory_el = memory_doc.DocumentElement;

            switch (mm)
            {
            case MemoryMode.Get:
                for (var l = 0; l < _weights.GetLength(0); ++l)
                {
                    for (var k = 0; k < _weights.GetLength(1); ++k)
                    {
                        _weights[l, k] =
                            double.Parse(memory_el.ChildNodes.Item(k + _weights.GetLength(1) * l).InnerText.Replace(',', '.'),
                                         CultureInfo.InvariantCulture);                        //parsing stuff
                    }
                }
                break;

            case MemoryMode.Set:
                for (var l = 0; l < Neurons.Length; ++l)
                {
                    for (var k = 0; k < numofprevneurons; ++k)
                    {
                        memory_el.ChildNodes.Item(k + numofprevneurons * l).InnerText = Neurons[l].Weights[k].ToString();
                    }
                }
                break;
            }

            memory_doc.Save($"{type}_memory.xml");
            Console.WriteLine($"{type} weights have been initialized...");
            return(_weights);
        }
Exemple #12
0
        private void TestBandwidthRange(Context context, Device[] devices, int start, int end, int increment, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            //count the number of copies we're going to run
            int count = 1 + ((end - start) / increment);
            int[] memSizes = new int[count];
            double[] bandwidths = new double[count];

            // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
            for (int i = 0; i < count; i++)
                bandwidths[i] = 0.0;

            // Use the device asked by the user
            for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
            {
                // Allocate command queue for the device (dealloc first if already allocated)
                using (CommandQueue queue = CreateQueue(context, devices[currentDevice]))
                {
                    //run each of the copies
                    for (int i = 0; i < count; i++)
                    {
                        memSizes[i] = start + i * increment;
                        switch (memoryCopyKind)
                        {
                        case MemoryCopyKind.DeviceToHost:
                            bandwidths[i] += TestDeviceToHostTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.HostToDevice:
                            bandwidths[i] += TestHostToDeviceTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.DeviceToDevice:
                            bandwidths[i] += TestDeviceToDeviceTransfer(context, queue, memSizes[i]);
                            break;
                        }
                    }
                }
            } // Complete the bandwidth computation on all the devices

            //print results
            if (printMode == PrintMode.Csv)
            {
                PrintResultsCsv(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, (1 + endDevice - startDevice));
            }
            else
            {
                PrintResultsReadable(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, (1 + endDevice - startDevice));
            }
        }
Exemple #13
0
        private void PrintResultsReadable(int[] memSizes, double[] bandwidths, int count, MemoryCopyKind memoryCopyKind, AccessMode accessMode, MemoryMode memoryMode, int p)
        {
            if (memoryCopyKind == MemoryCopyKind.DeviceToDevice)
            {
                Console.WriteLine("Device to device bandwidth: {0} devices(s)", p);
            }
            else
            {
                if (memoryCopyKind == MemoryCopyKind.DeviceToHost)
                {
                    Console.Write("Device to host bandwidth: {0} devices(s), ", p);
                }
                else if (memoryCopyKind == MemoryCopyKind.HostToDevice)
                {
                    Console.Write("Host to device bandwidth: {0} devices(s), ", p);
                }

                if (memoryMode == MemoryMode.Pageable)
                {
                    Console.Write("Paged memory");
                }
                else if (memoryMode == MemoryMode.Pinned)
                {
                    Console.Write("Pinned memory");
                }

                if (accessMode == AccessMode.Direct)
                {
                    Console.WriteLine(", direct access");
                }
                else if (accessMode == AccessMode.Mapped)
                {
                    Console.WriteLine(", mapped access");
                }
            }

            Console.WriteLine("   Transfer size (bytes)\tBandwidth (MB/s)");
            for (int i = 0; i < count; i++)
            {
                Console.WriteLine("   {0}\t\t\t{1}{2}", memSizes[i], memSizes[i] < 10000 ? "\t" : "", bandwidths[i]);
            }

            Console.WriteLine();
        }
Exemple #14
0
 private void TestBandwidthQuick(Context context, Device[] devices, int size, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     TestBandwidthRange(context, devices, size, size, DefaultIncrement, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
 }
Exemple #15
0
 public LookupService(String databaseFile, MemoryMode memoryMode)
 {
     this.file       = new FileStream(databaseFile, FileMode.Open, FileAccess.Read);
     this.memoryMode = memoryMode;
     init();
 }
Exemple #16
0
 private void PrintResultsCsv(int[] memSizes, double[] bandwidths, int count, MemoryCopyKind memoryCopyKind, AccessMode accessMode, MemoryMode memoryMode, int p)
 {
     throw new NotImplementedException();
 }
Exemple #17
0
        public CodeManager()
        {
            Author[] author = new Author[1];
            string[] description = new string[1];
            CodeRepresentative selfRepresentative = new CodeRepresentative();

            author[0] = new Author("Maciej 'Expro' Grabowski", "*****@*****.**");
            description[0] = "Dynamic code manager, extends application features with modules and plugins.";
            managerDetails = new CodeDetails(Environment.GetCommandLineArgs()[0], typeof(CodeManager).FullName);
            managerDetails.Authors = author;
            managerDetails.Descriptions = description;
            managerDetails.IsModule = true;
            managerDetails.IsShared = true;
            managerDetails.Version = new CodeVersion(1, 0, 0);
            managerDetails.Name = "Code Manager";

            selfRepresentative.Details = managerDetails;
            selfRepresentative.Instance = this;
            selfRepresentative.Provider = this;
            selfRepresentative.State = CodeState.Created;

            modulePermissions = new PermissionSet(PermissionState.Unrestricted);

            addinPermissions = new PermissionSet(PermissionState.Unrestricted);
            addinPermissions.AddPermission(new UIPermission(PermissionState.Unrestricted));
            addinPermissions.AddPermission(new IsolatedStorageFilePermission(PermissionState.Unrestricted));

            SeparateModules = false;

            binaries = ";";
            memoryManagement = MemoryMode.FastestInitialization;

            codes = new SortedSet<CodeDetails>();
            shared = new SortedSet<CodeDetails>();
            modules = new SortedSet<CodeDetails>();
            addins = new SortedSet<CodeDetails>();
            controllable = new SortedSet<CodeDetails>();
            conditions = new SortedSet<string>();
            resolver = new SortedDictionary<string, CodeDetails>();
            representatives = new SortedDictionary<CodeDetails, CodeRepresentative>();
            domains = new SortedDictionary<CodeDetails, AppDomain>();
            files = new SortedSet<string>();
            modulesLock = new SemaphoreSlim(2);

            resolver.Add(typeof(CodeManager).FullName, managerDetails);
            domains.Add(managerDetails, AppDomain.CurrentDomain);
            representatives.Add(managerDetails, selfRepresentative);
            codes.Add(managerDetails);
            shared.Add(managerDetails);
            modules.Add(managerDetails);
        }
Exemple #18
0
 public LookupService(String databaseFile, MemoryMode memoryMode)
 {
     this.file = new FileStream (databaseFile, FileMode.Open, FileAccess.Read);
         this.memoryMode = memoryMode;
         init ();
 }
Exemple #19
0
        /// <summary>
        /// Sends a request to the kernel to set the memory mode
        /// </summary>
        /// <param name="mac">MAC address of the wocket</param>
        /// <param name="mode">Memory mode</param>
        public static void SET_MEMORY_MODE(string mac, MemoryMode mode)
        {
            ThreadPool.QueueUserWorkItem(func =>
            {
                kernelLock.WaitOne();
                try
                {
                    if ((_Registered) && (_Connected))
                    {
                        string commandPath = REGISTRY_REGISTERED_APPLICATIONS_PATH + "\\{" + _IcomingChannel + "}";
                        NamedEvents namedEvent = new NamedEvents();

                        RegistryKey rk = Registry.LocalMachine.OpenSubKey(commandPath, true);
                        rk.SetValue("Message", KernelCommand.SET_MEMORY_MODE.ToString(), RegistryValueKind.String);
                        rk.SetValue("Param", mac.ToString() + ":" + mode.ToString(), RegistryValueKind.String);
                        rk.Flush();
                        rk.Close();

                        namedEvent.Send(Core._OutgoingChannel);

                    }
                }
                catch (Exception e)
                {
                    Logger.Error("Core.cs:SET_MEMORY_MODE:" + e.ToString());
                }

                kernelLock.Release();
            });
        }
Exemple #20
0
        private void TestBandwidth(Context context, Device[] devices, int start, int end, int increment, TestMode testMode, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            switch (testMode)
            {
            case TestMode.Quick:
                TestBandwidthQuick(context, devices, DefaultSize, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Range:
                TestBandwidthRange(context, devices, start, end, increment, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            case TestMode.Shmoo:
                TestBandwidthShmoo(context, devices, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
                break;

            default:
                break;
            }
        }
Exemple #21
0
 public Blob(IntPtr data, uint length, MemoryMode mode, object userData, BlobReleaseDelegate releaseDelegate)
     : this(data, (int)length, mode, () => releaseDelegate?.Invoke(userData))
 {
 }
 private void HandleMemMode(MemoryMode eMode)
 {
     memMode = eMode;
     RefreshDisplay();
 }
Exemple #23
0
 public Blob(IntPtr data, uint length, MemoryMode mode, object userData, BlobReleaseDelegate releaseDelegate)
     : this(data, (int)length, mode, userData, releaseDelegate)
 {
 }
Exemple #24
0
 public Blob(IntPtr data, int length, MemoryMode mode, object userData, BlobReleaseDelegate releaseDelegate)
     : this(Create(data, length, mode, userData, new ReleaseDelegate(releaseDelegate)))
 {
 }
Exemple #25
0
 private void TestBandwidthShmoo(Context context, Device[] devices, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     throw new NotImplementedException();
 }
Exemple #26
0
        private static IntPtr Create(IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseProc)
        {
            var proxy = DelegateProxies.Create(releaseProc, DelegateProxies.ReleaseDelegateProxy, out _, out var ctx);

            return(HarfBuzzApi.hb_blob_create(data, length, mode, ctx, proxy));
        }
Exemple #27
0
 public Blob(IntPtr data, int length, MemoryMode mode, ReleaseDelegate releaseDelegate)
     : this(Create(data, length, mode, new ReleaseDelegate(releaseDelegate)))
 {
 }
Exemple #28
0
 private double TestHostToDeviceTransfer(Context context, CommandQueue commandQueue, int memorySize, AccessMode accessMode, MemoryMode memoryMode)
 {
     if (memoryMode == MemoryMode.Pinned)
         return TestHostToDeviceTransferPinned(context, commandQueue, memorySize, accessMode);
     else
         return TestHostToDeviceTransferPaged(context, commandQueue, memorySize, accessMode);
 }
Exemple #29
0
 private void TestBandwidthQuick(Context context, Device[] devices, int size, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     TestBandwidthRange(context, devices, size, size, DefaultIncrement, memoryCopyKind, printMode, accessMode, memoryMode, startDevice, endDevice);
 }
Exemple #30
0
 public Blob(IntPtr data, int length, MemoryMode mode)
     : this(data, length, mode, null, null)
 {
 }
Exemple #31
0
        private void TestBandwidthRange(Context context, Device[] devices, int start, int end, int increment, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
        {
            // count the number of copies we're going to run
            int count = 1 + ((end - start) / increment);

            int[]    memSizes   = new int[count];
            double[] bandwidths = new double[count];

            // Before calculating the cumulative bandwidth, initialize bandwidths array to NULL
            for (int i = 0; i < count; i++)
            {
                bandwidths[i] = 0.0;
            }

            // Use the device asked by the user
            for (int currentDevice = startDevice; currentDevice <= endDevice; currentDevice++)
            {
                // Allocate command queue for the device (dealloc first if already allocated)
                using (CommandQueue queue = CreateQueue(context, devices[currentDevice]))
                {
                    // run each of the copies
                    for (int i = 0; i < count; i++)
                    {
                        memSizes[i] = start + (i * increment);
                        switch (memoryCopyKind)
                        {
                        case MemoryCopyKind.DeviceToHost:
                            bandwidths[i] += TestDeviceToHostTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.HostToDevice:
                            bandwidths[i] += TestHostToDeviceTransfer(context, queue, memSizes[i], accessMode, memoryMode);
                            break;

                        case MemoryCopyKind.DeviceToDevice:
                            bandwidths[i] += TestDeviceToDeviceTransfer(context, queue, memSizes[i]);
                            break;
                        }
                    }
                }
            } // Complete the bandwidth computation on all the devices

            // print results
            if (printMode == PrintMode.Csv)
            {
                PrintResultsCsv(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, 1 + endDevice - startDevice);
            }
            else
            {
                PrintResultsReadable(memSizes, bandwidths, count, memoryCopyKind, accessMode, memoryMode, 1 + endDevice - startDevice);
            }
        }
Exemple #32
0
 private void TestBandwidthShmoo(Context context, Device[] devices, MemoryCopyKind memoryCopyKind, PrintMode printMode, AccessMode accessMode, MemoryMode memoryMode, int startDevice, int endDevice)
 {
     throw new NotImplementedException();
 }
Exemple #33
0
        public void TestBandwidth()
        {
            int        start      = DefaultSize;
            int        end        = DefaultSize;
            int        increment  = DefaultIncrement;
            PrintMode  printMode  = PrintMode.UserReadable;
            MemoryMode memoryMode = MemoryMode.Pageable;
            AccessMode accessMode = AccessMode.Direct;

            // Get OpenCL platform ID for NVIDIA if available, otherwise default
            Platform platform = OclUtils.GetPlatform();

            // Find out how many devices there are
            Device[] devices = platform.GetDevices(DeviceType.Gpu);
            if (devices.Length == 0)
            {
                Console.WriteLine("No GPU devices found. Falling back to CPU for test...");
                devices = platform.GetDevices(DeviceType.Cpu);
                Assert.AreNotEqual(0, devices.Length, "There are no devices supporting OpenCL");
            }

            int startDevice = 0;
            int endDevice   = 0;

            // Get and log the device info
            Console.WriteLine("Running on...");
            Console.WriteLine();
            for (int i = startDevice; i <= endDevice; i++)
            {
                Console.WriteLine(devices[i].Name);
            }

            Console.WriteLine();

            // Mode
            Console.WriteLine("Quick Mode");
            Console.WriteLine();
            TestMode testMode = TestMode.Quick;

            bool hostToDevice   = true;
            bool deviceToHost   = true;
            bool deviceToDevice = true;

            if (testMode == TestMode.Range)
            {
                throw new NotImplementedException();
            }

            using (var context = Context.Create(devices))
            {
                if (hostToDevice)
                {
                    TestBandwidth(context, devices, start, end, increment, testMode, MemoryCopyKind.HostToDevice, printMode, accessMode, memoryMode, startDevice, endDevice);
                }

                if (deviceToHost)
                {
                    TestBandwidth(context, devices, start, end, increment, testMode, MemoryCopyKind.DeviceToHost, printMode, accessMode, memoryMode, startDevice, endDevice);
                }

                if (deviceToDevice)
                {
                    TestBandwidth(context, devices, start, end, increment, testMode, MemoryCopyKind.DeviceToDevice, printMode, accessMode, memoryMode, startDevice, endDevice);
                }
            }
        }
Exemple #34
0
 public extern static hb_blob_t hb_blob_create(IntPtr data, uint length, MemoryMode mode, IntPtr user_data, IntPtr destroy);
Exemple #35
0
 private double TestHostToDeviceTransfer(Context context, CommandQueue commandQueue, int memorySize, AccessMode accessMode, MemoryMode memoryMode)
 {
     if (memoryMode == MemoryMode.Pinned)
     {
         return(TestHostToDeviceTransferPinned(context, commandQueue, memorySize, accessMode));
     }
     else
     {
         return(TestHostToDeviceTransferPaged(context, commandQueue, memorySize, accessMode));
     }
 }
Exemple #36
0
 public extern static hb_blob_t hb_blob_create(IntPtr data, int length, MemoryMode mode, IntPtr user_data, ReleaseDelegateProxyDelegate destroy);
Exemple #37
0
 public static void SwitchStorage(MemoryMode value)
 {
     currentStorageMode = value;
 }