Ejemplo n.º 1
0
        public BenchmarkForm()
        {
            _set = new MandelbrotSet(1280, 960)
            {
                MaxIterations = 10000,
                OffsetX       = -0.75,
                OffsetY       = 0.0,
                Zoom          = 4.0
            };

            _backEnds = new[]
            {
                BackEnd.Managed,
                BackEnd.Sse2,
                Avx.IsSupported ? BackEnd.Avx : (BackEnd?)null,
                ImplCuda.IsSupported ? BackEnd.Cuda : (BackEnd?)null,
                ImplOpenCl.IsSupported ? BackEnd.OpenCl : (BackEnd?)null
            }.Where(e => e.HasValue).Select(e => e.Value).ToArray();

            _maxThreads = Environment.ProcessorCount;
            _series     = _backEnds.SelectMany(b => new[] { new Series(BackEndLabel.Get(b) + " 64"), new Series(BackEndLabel.Get(b) + " 32") }).ToArray();
            _lock       = new object();
            _thread     = new Thread(RunBenchmark)
            {
                Name = "Benchmark"
            };

            InitializeComponent();
            InitializeSeries();
            InitializeDataGrid();

            _chartMenuStrip.Enabled = false;
            _closeButton.Enabled    = false;
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            _set = new MandelbrotSet(1, 1)
            {
                BackEnd       = Avx.IsSupported ? BackEnd.Avx : BackEnd.Sse2,
                MaxIterations = 1001,
                OffsetX       = -0.75,
                Threads       = Environment.ProcessorCount
            };

            InitializeComponent();

            // Icon
            var png = Properties.Resources.Icon;

            Icon = Icon.FromHandle(png.GetHicon());

            // Backend combo-box.
            var items = new[]
            {
                new ComboBoxItem(BackEndLabel.Get(BackEnd.Managed), BackEnd.Managed),
                new ComboBoxItem(BackEndLabel.Get(BackEnd.Sse2), BackEnd.Sse2),
                Avx.IsSupported ? new ComboBoxItem(BackEndLabel.Get(BackEnd.Avx), BackEnd.Avx) : null,
                ImplCuda.IsSupported ? new ComboBoxItem(BackEndLabel.Get(BackEnd.Cuda), BackEnd.Cuda) : null,
                ImplOpenCl.IsSupported ? new ComboBoxItem(BackEndLabel.Get(BackEnd.OpenCl), BackEnd.OpenCl) : null
            }.Where(e => e != null).ToArray();

            // ReSharper disable once CoVariantArrayConversion
            _backEndComboBox.Items.AddRange(items);
            _backEndComboBox.SelectedItem = items.Single(e => (BackEnd)e.Value == _set.BackEnd);

            // Force size initialisation. Sometimes does not seem to happen otherwise.
            pictureBox_Resize(null, null);

            // Only redraw Mandelbrot set when there is no pending messages.
            Application.Idle += OnIdle;

            RefreshLabels();
        }