コード例 #1
0
        public MyFourierBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
            : base(owner, inputSize, tempBlock)
        {
            m_stream = new CudaStream();

            m_fft = new CudaFFTPlan1D(inputSize, cufftType.R2C, 1);
            m_fft.SetStream(m_stream.Stream);
            m_ifft = new CudaFFTPlan1D(inputSize, cufftType.C2R, 1);
            m_ifft.SetStream(m_stream.Stream);

            m_mulkernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "MulComplexElementWise");
            m_mulkernel.SetupExecution(inputSize + 1);

            m_involutionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "InvolveVector");
            m_involutionKernel.SetupExecution(inputSize - 1);

            m_inversionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\InvertValuesKernel", "InvertLengthComplexKernel");
            m_inversionKernel.SetupExecution(inputSize);

            m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(owner, owner.GPU, ProductMode.f_DotProduct_f);

            m_normalKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\TransformKernels", "PolynomialFunctionKernel");
            m_normalKernel.SetupExecution(inputSize);

            m_firstFFTOffset = 0;
            m_secondFFTOffset = (inputSize + 1) * 2;
            m_tempOffset = (inputSize + 1) * 4;

            Denominator = inputSize;
        }
コード例 #2
0
        /// <summary>
        /// Sets property of given task. Support Enums
        /// </summary>
        /// <param name="nodeId">Node ID</param>
        /// <param name="taskType">Task type</param>
        /// <param name="propName">Property name</param>
        /// <param name="value">New property value</param>
        public void Set(int nodeId, Type taskType, string propName, object value)
        {
            MyWorkingNode node = (Project.GetNodeById(nodeId) as MyWorkingNode);
            MyTask        task = GetTaskByType(node, taskType);

            SetProperty(task, propName, value);
        }
コード例 #3
0
        // Check the dashboard for expected properties.
        private static void CheckDashboard(MyProject project)
        {
            Dashboard dashboard = project.Dashboard;

            var property1 = CheckDashboardProperty(project, dashboard, 338, "PerformTask", "SimilarityOperator");

            var property2 = CheckDashboardProperty(project, dashboard, 331, "PerformTask", "SimilarityOperator");

            CheckDashboardProperty(project, dashboard, 451, "ShareWeightsTask", "SourceNodeName");

            MyWorkingNode nodeGroup = project.Network.GetChildNodeById(359) as MyWorkingNode;
            var           property4 = dashboard.Get(nodeGroup, "InputBranches");

            Assert.NotNull(property4);

            // Check the grouped dashboard for expected properties.
            GroupDashboard groupedDashboard = project.GroupedDashboard;

            var group = groupedDashboard.Get("f6af17f3-82b0-42b6-89b0-a4eaf6432316");

            Assert.NotNull(@group);

            Assert.True(@group.GroupedProperties.Contains(property1));
            Assert.True(@group.GroupedProperties.Contains(property2));
        }
コード例 #4
0
        private void RefreshNode(MyWorkingNode node)
        {
            node.Updated();

            propertyGrid.Refresh();
            m_mainForm.InvalidateGraphLayouts();
        }
コード例 #5
0
        public MyFourierBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock <float> tempBlock)
            : base(owner, inputSize, tempBlock)
        {
            m_fft  = new CudaFFTPlan1D(inputSize, cufftType.R2C, 1);
            m_ifft = new CudaFFTPlan1D(inputSize, cufftType.C2R, 1);

            m_mulkernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "MulComplexElementWise");
            m_mulkernel.SetupExecution(inputSize + 1);

            m_involutionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "InvolveVector");
            m_involutionKernel.SetupExecution(inputSize - 1);

            m_inversionKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\InvertValuesKernel", "InvertLengthComplexKernel");
            m_inversionKernel.SetupExecution(inputSize);

            m_dotKernel = MyReductionFactory.Kernel(owner.GPU, MyReductionFactory.Mode.f_DotProduct_f);

            m_normalKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Transforms\TransformKernels", "PolynomialFunctionKernel");
            m_normalKernel.SetupExecution(inputSize);

            m_firstFFTOffset  = 0;
            m_secondFFTOffset = (inputSize + 1) * 2;
            m_tempOffset      = (inputSize + 1) * 4;

            Denominator = inputSize;
        }
コード例 #6
0
        /// <summary>
        /// Merge tasks directly below the Target node into the nodes in this level of the execution tree.
        /// This adds the signal values but mostly is used for custom execution plans.
        /// </summary>
        /// <param name="profilingInfo">The target's </param>
        /// <returns></returns>
        private static Dictionary <IMyExecutable, TimeSpan> GetProfilingInfoWithTasks(IDictionary <IMyExecutable, TimeSpan> profilingInfo)
        {
            var profilingInfoWithTasks = new Dictionary <IMyExecutable, TimeSpan>();

            foreach (KeyValuePair <IMyExecutable, TimeSpan> profiling in profilingInfo)
            {
                var task = profiling.Key as MyTask;
                if (task != null)
                {
                    // Tasks belong to a node, their time should be added to the node's.
                    MyWorkingNode node = task.GenericOwner;
                    if (profilingInfoWithTasks.ContainsKey(node.ExecutionBlock))
                    {
                        profilingInfoWithTasks[node.ExecutionBlock] =
                            profilingInfoWithTasks[node.ExecutionBlock].Add(profiling.Value);
                    }
                    else
                    {
                        profilingInfoWithTasks[node.ExecutionBlock] = profiling.Value;
                    }
                }
                else
                {
                    profilingInfoWithTasks[profiling.Key] = profiling.Value;
                }
            }
            return(profilingInfoWithTasks);
        }
コード例 #7
0
        private List <IMyExecutable> GetTasks(MyWorkingNode node)
        {
            List <IMyExecutable> tasks = new List <IMyExecutable>();

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);
                tasks.Add(task);
            }

            MyNodeGroup nodeGroup = node as MyNodeGroup;

            if (nodeGroup != null)
            {
                foreach (MyNode childNode in nodeGroup.Children)
                {
                    MyWorkingNode childWorkingNode = childNode as MyWorkingNode;
                    if (childWorkingNode != null)
                    {
                        tasks.AddRange(GetTasks(childWorkingNode));
                    }
                }
            }

            return(tasks);
        }
コード例 #8
0
ファイル: VectorOps.cs プロジェクト: sschocke/BrainSimulator
        public VectorOps(MyWorkingNode caller, VectorOperation operations, MyMemoryBlock<float> tempBlock)
        {
            m_caller = caller;
            m_operations = operations;
            m_temp = tempBlock;

            MatOperation mat_ops = MatOperation.None;

            if (m_operations.HasFlag(VectorOperation.Rotate))
            {
                Debug.Assert(tempBlock.Count >= 4, "Temporary memory block has to be large at least 4 items when using Rotate operation");
                mat_ops |= MatOperation.Multiplication;
            }

            if (m_operations.HasFlag(VectorOperation.Angle))
                mat_ops |= MatOperation.DotProd;

            if (m_operations.HasFlag(VectorOperation.DirectedAngle))
            {
                mat_ops |= MatOperation.Multiplication | MatOperation.DotProd;
                m_operations |= VectorOperation.Angle | VectorOperation.Rotate;
            }

            m_matOperation = new MyMatrixAutoOps(caller, mat_ops);
        }
コード例 #9
0
        private static string ResolveFilePath(MyAbstractMemoryBlock memoryBlock, string globalDataFolder)
        {
            string fileName = GetTempStorage(memoryBlock.Owner.Owner) + "\\" + GetNodeFolder(memoryBlock.Owner) + "\\" + GetFileName(memoryBlock);

            if (!File.Exists(fileName))
            {
                MyWorkingNode node = memoryBlock.Owner as MyWorkingNode;

                if (!string.IsNullOrEmpty(node.DataFolder))
                {
                    fileName = node.DataFolder;
                }
                else if (!string.IsNullOrEmpty(globalDataFolder))
                {
                    fileName = globalDataFolder + "\\" + GetNodeFolder(memoryBlock.Owner);
                }
                else
                {
                    throw new FileNotFoundException(
                              "File not found in temporal folder and no data folder defined: " + fileName);
                }

                fileName += "\\" + GetFileName(memoryBlock);
            }

            if (!File.Exists(fileName))
            {
                throw new FileNotFoundException("Memory block file not found: " + fileName);
            }

            return(fileName);
        }
コード例 #10
0
ファイル: VectorOps.cs プロジェクト: xeronith/BrainSimulator
        public VectorOps(MyWorkingNode caller, VectorOperation operations, MyMemoryBlock <float> tempBlock)
        {
            m_caller     = caller;
            m_operations = operations;
            m_temp       = tempBlock;

            MatOperation mat_ops = MatOperation.None;

            if (m_operations.HasFlag(VectorOperation.Rotate))
            {
                Debug.Assert(tempBlock.Count >= 4, "Temporary memory block has to be large at least 4 items when using Rotate operation");
                mat_ops |= MatOperation.Multiplication;
            }

            if (m_operations.HasFlag(VectorOperation.Angle))
            {
                mat_ops |= MatOperation.DotProd;
            }

            if (m_operations.HasFlag(VectorOperation.DirectedAngle))
            {
                mat_ops      |= MatOperation.Multiplication | MatOperation.DotProd;
                m_operations |= VectorOperation.Angle | VectorOperation.Rotate;
            }


            m_matOperation = new MyMatrixAutoOps(caller, mat_ops);
        }
コード例 #11
0
 public MyPermutationBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
     : base(owner, inputSize, tempBlock)
 {
     m_PermKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineVectorsKernel");
     m_PermKernel.SetupExecution(inputSize);
     m_binaryPermKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
     m_binaryPermKernel.SetupExecution(inputSize);
 }
コード例 #12
0
        public MyPermutationBinder(MyWorkingNode owner, int inputSize, MyMemoryBlock <float> tempBlock)
            : base(owner, inputSize, tempBlock)
        {
            m_stream = new CudaStream();

            m_binaryPermKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
            m_binaryPermKernel.SetupExecution(inputSize);
        }
コード例 #13
0
        private void CollectNodeAndTaskIdentifiers()
        {
            CSharpCodeProvider codeProvider = new CSharpCodeProvider();

            m_nodeVariables = new Dictionary <string, int>();
            m_taskVariables = new Dictionary <string, Tuple <int, string> >();

            m_codeGenerationLog = new List <string>();
            m_codeGenerationLog.Add("Script generator:");

            Iterate(true, false, node =>
            {
                string nodeIdentifier = node.Name;
                nodeIdentifier        = nodeIdentifier.Replace(' ', '_');

                if (!codeProvider.IsValidIdentifier(nodeIdentifier) || m_nodeVariables.ContainsKey(nodeIdentifier))
                {
                    string newIdentifier = "Node_" + node.Id;
                    m_codeGenerationLog.Add("\"" + nodeIdentifier + "\" is invalid name for identifier (or it exists already). \"" + newIdentifier + "\" generated instead.");
                    nodeIdentifier = newIdentifier;
                }
                m_nodeVariables[nodeIdentifier] = node.Id;

                MyWorkingNode wNode = node as MyWorkingNode;

                if (wNode != null)
                {
                    foreach (string taskName in node.GetInfo().KnownTasks.Keys)
                    {
                        string taskIdentifier = nodeIdentifier + "_" + taskName;

                        if (!codeProvider.IsValidIdentifier(taskIdentifier) || m_nodeVariables.ContainsKey(taskIdentifier))
                        {
                            m_codeGenerationLog.Add("\"" + nodeIdentifier + "\" is invalid name for identifier (or it exists already). No task variable generated.");
                        }
                        else
                        {
                            m_taskVariables[taskIdentifier] = new Tuple <int, string>(wNode.Id, taskName);
                        }
                    }
                }
            });

            m_nameExpressions = String.Empty;

            if (m_nodeVariables.Any())
            {
                m_nameExpressions = m_nodeVariables.Keys.Aggregate((a, b) => a + " " + b);
            }

            if (m_taskVariables.Any())
            {
                m_nameExpressions += " " + m_taskVariables.Keys.Aggregate((a, b) => a + " " + b);
            }
        }
コード例 #14
0
        public MyMatrixKernelOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock <float> A, MyMemoryBlock <float> B = null)
        {
            OpersKerlsDictionary = new Dictionary <MatOperation, MyCudaKernel>();
            this.callee          = callee;

            if ((operations & MatOperation.Log) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Log, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "LogKernel_naive"));
            }
            if ((operations & MatOperation.Exp) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Exp, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "ExpKernel_naive"));
            }
            if ((operations & MatOperation.Round) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Round, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "RoundKernel_naive"));
            }
            if ((operations & MatOperation.Floor) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Floor, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "FloorKernel_naive"));
            }
            if ((operations & MatOperation.Ceil) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Ceil, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "CeilKernel_naive"));
            }
            if ((operations & MatOperation.Abs) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Abs, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "AbsKernel_naive"));
            }
            if ((operations & MatOperation.GetCol) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetCol, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getCol_FloatId_naive"));
            }
            if ((operations & MatOperation.GetRow) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetRow, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getRow_FloatId_naive"));
            }
            if ((operations & MatOperation.MultiplElemntWise) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.MultiplElemntWise, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_MultiplElementWise_naive"));
            }
            if ((operations & MatOperation.Addition) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Addition, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Addition_naive"));
            }
            if ((operations & MatOperation.Substraction) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Substraction, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Substraction_naive"));
            }
            if (operations > 0 && OpersKerlsDictionary.Count == 0)
            {
                MyLog.Writer.WriteLine(MyLogLevel.ERROR, "Trying to init kernel MatrixOps for undefined MatOperation");
            }
        }
コード例 #15
0
        public MyMatrixKernelOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock<float> A, MyMemoryBlock<float> B = null)
        {
            OpersKerlsDictionary = new Dictionary<MatOperation, MyCudaKernel>();
            this.callee = callee;

            if ((operations & MatOperation.Log) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Log, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "LogKernel_naive"));
            }
            if ((operations & MatOperation.Exp) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Exp, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "ExpKernel_naive"));
            }
            if ((operations & MatOperation.Round) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Round, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "RoundKernel_naive"));
            }
            if ((operations & MatOperation.Floor) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Floor, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "FloorKernel_naive"));
            }
            if ((operations & MatOperation.Ceil) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Ceil, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "CeilKernel_naive"));
            }
            if ((operations & MatOperation.Abs) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Abs, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "AbsKernel_naive"));
            }
            if ((operations & MatOperation.GetCol) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetCol, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getCol_FloatId_naive"));
            }
            if ((operations & MatOperation.GetRow) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.GetRow, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_getRow_FloatId_naive"));
            }
            if ((operations & MatOperation.MultiplElemntWise) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.MultiplElemntWise, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_MultiplElementWise_naive"));
            }
            if ((operations & MatOperation.Addition) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Addition, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Addition_naive"));
            }
            if ((operations & MatOperation.Substraction) > 0)
            {
                OpersKerlsDictionary.Add(MatOperation.Substraction, MyKernelFactory.Instance.Kernel(callee.GPU, @"Vision\Matrix", "Matrix_Substraction_naive"));
            }
            if (operations > 0 && OpersKerlsDictionary.Count == 0)
            {
                MyLog.Writer.WriteLine(MyLogLevel.ERROR, "Trying to init kernel MatrixOps for undefined MatOperation");
            }
        }
コード例 #16
0
 /// <summary>
 /// Return task of given type from given node
 /// </summary>
 /// <param name="node">Node</param>
 /// <param name="type">Type of task</param>
 /// <returns>Task</returns>
 protected MyTask GetTaskByType(MyWorkingNode node, Type type)
 {
     foreach (PropertyInfo taskPropInfo in node.GetInfo().TaskOrder)
     {
         MyTask task = node.GetTaskByPropertyName(taskPropInfo.Name);
         if (task.GetType().ToString() == type.ToString())
         {
             return(task);
         }
     }
     return(null);
 }
コード例 #17
0
        private void loadNodeDataButton_Click(object sender, EventArgs e)
        {
            MyWorkingNode node = Target as MyWorkingNode;

            if (node == null)
            {
                return;
            }

            node.LoadOnStart = loadNodeDataButton.Checked;

            RefreshNode(node);
        }
コード例 #18
0
 public MyMatrixAutoOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock <float> A = null)
 {
     if ((MyMatrixKernelOps.AvailableOperations() & operations) > 0)
     {
         MatKerlOps = new MyMatrixKernelOps(callee, operations);
     }
     if ((MyMatrixCublasOps.AvailableOperations() & operations) > 0)
     {
         MatCublOps = new MyMatrixCublasOps(callee);
     }
     if ((MyMatrixCPUOps.AvailableOperations() & operations) > 0)
     {
         MatCPUOps = new MyMatrixCPUOps(callee);
     }
 }
コード例 #19
0
 public MyMatrixAutoOps(MyWorkingNode callee, MatOperation operations, MyMemoryBlock<float> A = null)
 {
     if ((MyMatrixKernelOps.AvailableOperations() & operations) > 0)
     {
         MatKerlOps = new MyMatrixKernelOps(callee, operations);
     }
     if ((MyMatrixCublasOps.AvailableOperations() & operations) > 0)
     {
         MatCublOps = new MyMatrixCublasOps(callee);
     }
     if ((MyMatrixCPUOps.AvailableOperations() & operations) > 0)
     {
         MatCPUOps = new MyMatrixCPUOps(callee);
     }
 }
コード例 #20
0
        public override void RestoreTargetFromIdentifier(MyProject project)
        {
            if (TargetIdentifier != null)
            {
                string[] split = TargetIdentifier.Split('#');
                if (split.Length == 2)
                {
                    MyWorkingNode node = (MyWorkingNode)project.GetNodeById(int.Parse(split[0]));

                    if (node != null)
                    {
                        Target = MyMemoryManager.Instance.GetMemoryBlockByName(node, split[1]);
                    }
                }
            }
        }
コード例 #21
0
        public void CreateAndShowObserverView(MyWorkingNode node, Type observerType)
        {
            try
            {
                MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType);
                observer.GenericTarget = node;

                ObserverForm newView = new ObserverForm(this, observer, node);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
コード例 #22
0
        private void SaveBlocks(List <MyWorkingNode> nodeList)
        {
            MyMemoryBlockSerializer serializer = new MyMemoryBlockSerializer();

            for (int j = 0; j < nodeList.Count; j++)
            {
                MyWorkingNode node = nodeList[j];

                if (SaveAllNodesData || node.SaveOnStop)
                {
                    foreach (MyAbstractMemoryBlock mb in MyMemoryManager.Instance.GetBlocks(node))
                    {
                        if (mb.Persistable)
                        {
                            serializer.SaveBlock(mb);
                        }
                    }
                }
            }
        }
コード例 #23
0
        private void LoadBlocks(List <MyWorkingNode> nodeList)
        {
            MyMemoryBlockSerializer serializer = new MyMemoryBlockSerializer();

            for (int j = 0; j < nodeList.Count; j++)
            {
                MyWorkingNode node = nodeList[j];

                if (LoadAllNodesData || node.LoadOnStart)
                {
                    foreach (MyAbstractMemoryBlock mb in MyMemoryManager.Instance.GetBlocks(node))
                    {
                        if (mb.Persistable)
                        {
                            serializer.LoadBlock(mb, GlobalDataFolder);
                        }
                    }
                }
            }
        }
コード例 #24
0
        private void saveDataNodeButton_Click(object sender, EventArgs e)
        {
            /*
             * if (folderBrowserDialog.ShowDialog(this) == DialogResult.OK)
             * {
             *  MyMemoryManager.Instance.LoadBlocks(Target as MyNode, true, folderBrowserDialog.SelectedPath, false);
             *  MyLog.INFO.WriteLine("Memory blocks of '" + (Target as MyNode).Name + "' were loaded from '" + folderBrowserDialog.SelectedPath + "'.");
             * }
             */

            MyWorkingNode node = Target as MyWorkingNode;

            if (node == null)
            {
                return;
            }

            node.SaveOnStop = saveNodeDataButton.Checked;

            RefreshNode(node);
        }
コード例 #25
0
        private string GenerateVariablesCode()
        {
            StringBuilder defs = new StringBuilder();
            StringBuilder init = new StringBuilder();

            init.AppendLine("public static void __InitGeneratedVariables(MyCSharpNodeGroup owner) { ");

            if (GenerateVariables)
            {
                foreach (string nodeIdentifier in m_nodeVariables.Keys)
                {
                    MyNode node         = GetChildNodeById(m_nodeVariables[nodeIdentifier]);
                    string nodeTypeName = node.GetType().FullName.Replace('+', '.');

                    if (node != null)
                    {
                        defs.AppendLine("static " + nodeTypeName + " " + nodeIdentifier + ";");
                        init.AppendLine(nodeIdentifier + " = (" + nodeTypeName + ")owner.GetChildNodeById(" + node.Id + ");");
                    }
                }

                foreach (string taskIdentifier in m_taskVariables.Keys)
                {
                    MyWorkingNode wNode = (MyWorkingNode)GetChildNodeById(m_taskVariables[taskIdentifier].Item1);

                    MyTask task = wNode.GetTaskByPropertyName(m_taskVariables[taskIdentifier].Item2);

                    if (task != null)
                    {
                        string taskTypeName = task.GetType().FullName.Replace('+', '.');
                        defs.AppendLine("static " + taskTypeName + " " + taskIdentifier + ";");
                        init.AppendLine(taskIdentifier + " = (" + taskTypeName + ")((MyWorkingNode)owner.GetChildNodeById(" + wNode.Id + ")).GetTaskByPropertyName(\"" + m_taskVariables[taskIdentifier].Item2 + "\");");
                    }
                }
            }

            init.AppendLine("}");

            return(defs.ToString() + init.ToString());
        }
コード例 #26
0
        public MyDistanceOps(MyWorkingNode caller, DistanceOperation operations, MyMemoryBlock <float> tempBlock = null)
        {
            m_caller     = caller;
            m_operations = operations;
            m_temp       = tempBlock;


            if (operations.HasFlag(DistanceOperation.DotProd))
            {
                m_dotKernel = MyKernelFactory.Instance.KernelProduct <float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.CosDist))
            {
                m_cosKernel = MyKernelFactory.Instance.KernelProduct <float>(caller, caller.GPU, ProductMode.f_Cosine_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared))
            {
                // EuclidDist computes EuclidDistSquared first, so keep them together:
                m_operations |= DistanceOperation.EuclidDist | DistanceOperation.EuclidDistSquared;
                m_dotKernel   = MyKernelFactory.Instance.KernelProduct <float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.HammingDist))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction <float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }
            if (operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction <float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared) ||
                operations.HasFlag(DistanceOperation.HammingDist) || operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_combineVecsKernel = MyKernelFactory.Instance.Kernel(m_caller.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
            }
        }
コード例 #27
0
        public MyDistanceOps(MyWorkingNode caller, DistanceOperation operations, MyMemoryBlock<float> tempBlock = null)
        {
            m_caller = caller;
            m_operations = operations;
            m_temp = tempBlock;

            if (operations.HasFlag(DistanceOperation.DotProd))
            {
                m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.CosDist))
            {
                m_cosKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_Cosine_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared))
            {
                // EuclidDist computes EuclidDistSquared first, so keep them together:
                m_operations |= DistanceOperation.EuclidDist | DistanceOperation.EuclidDistSquared;
                m_dotKernel = MyKernelFactory.Instance.KernelProduct<float>(caller, caller.GPU, ProductMode.f_DotProduct_f);
            }

            if (operations.HasFlag(DistanceOperation.HammingDist))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction<float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }
            if (operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_reduceSumKernel = MyKernelFactory.Instance.KernelReduction<float>(caller, caller.GPU, ReductionMode.f_Sum_f);
            }

            if (operations.HasFlag(DistanceOperation.EuclidDist) || operations.HasFlag(DistanceOperation.EuclidDistSquared) ||
                operations.HasFlag(DistanceOperation.HammingDist) || operations.HasFlag(DistanceOperation.HammingSim))
            {
                m_combineVecsKernel = MyKernelFactory.Instance.Kernel(m_caller.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
            }
        }
コード例 #28
0
        private void ExtractPartitioningFromExecutionPlan()
        {
            HashSet <MyWorkingNode>[] indexTable = new HashSet <MyWorkingNode> [ExecutionPlan.Length];
            NodePartitioning = new List <MyWorkingNode> [ExecutionPlan.Length];

            MyExecutionBlock.IteratorAction extractNodesAction = delegate(IMyExecutable executable)
            {
                if (executable is MyTask)
                {
                    MyWorkingNode taskOwner = (executable as MyTask).GenericOwner;
                    indexTable[taskOwner.GPU].Add(taskOwner);
                }
            };

            for (int i = 0; i < ExecutionPlan.Length; i++)
            {
                indexTable[i] = new HashSet <MyWorkingNode>();

                ExecutionPlan[i].InitStepPlan.Iterate(true, extractNodesAction);
                ExecutionPlan[i].StandardStepPlan.Iterate(true, extractNodesAction);

                NodePartitioning[i] = new List <MyWorkingNode>(indexTable[i]);
            }
        }
コード例 #29
0
        public void CreateAndShowObserverView(MyWorkingNode node, Type observerType)
        {
            try
            {
                MyAbstractObserver observer = (MyAbstractObserver)Activator.CreateInstance(observerType);
                observer.GenericTarget = node;

                ObserverForm newView = new ObserverForm(this, observer, node);
                ObserverViews.Add(newView);

                newView.Show(dockPanel, DockState.Float);

                ProjectStateChanged("Node observer added");
            }
            catch (Exception e)
            {
                MyLog.ERROR.WriteLine("Error creating observer: " + e.Message);
            }
        }
コード例 #30
0
 public MySymbolBinderBase(MyWorkingNode owner, int inputSize, MyMemoryBlock<float> tempBlock)
 {
     m_inputSize = inputSize;
     m_tempBlock = tempBlock;
     m_owner = owner;
 }
コード例 #31
0
 /// <summary>
 /// Return task of given type from given node
 /// </summary>
 /// <param name="node">Node</param>
 /// <param name="type">Type of task</param>
 /// <returns>Task</returns>
 protected MyTask GetTaskByType(MyWorkingNode node, Type type)
 {
     foreach (PropertyInfo taskPropInfo in node.GetInfo().TaskOrder)
     {
         MyTask task = node.GetTaskByPropertyName(taskPropInfo.Name);
         if (task.GetType().ToString() == type.ToString())
             return task;
     }
     return null;
 }
コード例 #32
0
 public void RemoveNode(MyWorkingNode node)
 {
     m_removedNodes.Add(node);
 }
コード例 #33
0
        //private CudaBlas cublas = null;


        public MyMatrixCublasOps(MyWorkingNode callee, MatOperation operation = 0, MyMemoryBlock <float> A = null, MyMemoryBlock <float> tmp = null)
        {
            //  cublas = new CudaBlas();
            this.callee = callee;
        }
コード例 #34
0
        private MyExecutionBlock CreateNodeExecutionPlan(MyWorkingNode node, bool initPhase)
        {
            List<IMyExecutable> defaultPlanContent = new List<IMyExecutable>();

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyIncomingSignalTask(node));
            }

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);

                if (task != null && initPhase && task.OneShot || !initPhase && !task.OneShot)
                {
                    defaultPlanContent.Add(task);
                }
            }

            if (node is MyNodeGroup)
            {
                IEnumerable<MyNode> children = (node as MyNodeGroup).Children.OrderBy(x => x.TopologicalOrder);

                foreach (MyNode childNode in children)
                {
                    if (childNode is MyWorkingNode)
                    {
                        defaultPlanContent.Add(CreateNodeExecutionPlan(childNode as MyWorkingNode, initPhase));
                    }
                }
            }

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyOutgoingSignalTask(node));
            }

            MyExecutionBlock defaultPlan = new MyExecutionBlock(defaultPlanContent.ToArray());
            defaultPlan.Name = node.Name;

            MyExecutionBlock resultPlan = defaultPlan;

            if (node is IMyCustomExecutionPlanner)
            {
                if (initPhase)
                {
                    resultPlan = (node as IMyCustomExecutionPlanner).CreateCustomInitPhasePlan(defaultPlan);
                }
                else
                {
                    resultPlan = (node as IMyCustomExecutionPlanner).CreateCustomExecutionPlan(defaultPlan);
                }
                resultPlan.Name = defaultPlan.Name;
            }

            if (node is MyNodeGroup)
            {
                resultPlan.Name += " (group)";
            }

            return resultPlan;
        }
コード例 #35
0
 private MyTask GetCurrentTask(MyWorkingNode node) => node.GetTaskByPropertyName(m_taskPropInfo.Name);
コード例 #36
0
 public MyXORBinder(MyWorkingNode owner, int inputSize)
     : base(owner, inputSize, null)
 {
     m_XORKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
     m_XORKernel.SetupExecution(inputSize);
 }
コード例 #37
0
 public override CUdeviceptr GetDevicePtr(MyWorkingNode callee, int offset)
 {
     return(GetDevicePtr(callee.GPU, offset));
 }
コード例 #38
0
ファイル: MyXORBinder.cs プロジェクト: Jlaird/BrainSimulator
 public MyXORBinder(MyWorkingNode owner, int inputSize)
     : base(owner, inputSize, null)
 {
     m_XORKernel = MyKernelFactory.Instance.Kernel(owner.GPU, @"Common\CombineVectorsKernel", "CombineTwoVectorsKernel");
     m_XORKernel.SetupExecution(inputSize);
 }
コード例 #39
0
        private void RefreshNode(MyWorkingNode node)
        {
            node.Updated();

            propertyGrid.Refresh();
            m_mainForm.InvalidateGraphLayouts();
        }
コード例 #40
0
 //private CudaBlas cublas = null;
 public MyMatrixCublasOps(MyWorkingNode callee, MatOperation operation = 0, MyMemoryBlock<float> A = null, MyMemoryBlock<float> tmp = null)
 {
     //  cublas = new CudaBlas();
     this.callee = callee;
 }
コード例 #41
0
        public MyExecutionBlock CreateNodeExecutionPlan(MyWorkingNode node, bool initPhase)
        {
            List<IMyExecutable> defaultPlanContent = new List<IMyExecutable>();

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyIncomingSignalTask(node));
            }

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);

                if (task != null && !task.DesignTime && (initPhase && task.OneShot || !initPhase && !task.OneShot))
                {
                    defaultPlanContent.Add(task);
                }
            }

            MyNodeGroup nodeGroup = node as MyNodeGroup;
            if (nodeGroup != null)
            {
                IEnumerable<MyNode> children = nodeGroup.Children.OrderBy(x => x.TopologicalOrder);

                foreach (MyNode childNode in children)
                {
                    MyWorkingNode childWorkingNode = childNode as MyWorkingNode;
                    if (childWorkingNode != null)
                    {
                        defaultPlanContent.Add(CreateNodeExecutionPlan(childWorkingNode, initPhase));
                    }
                }
            }

            if (!initPhase && PlanSignalTasks)
            {
                defaultPlanContent.Add(new MyOutgoingSignalTask(node));
            }

            MyExecutionBlock defaultPlan = new MyExecutionBlock(defaultPlanContent.ToArray());
            defaultPlan.Name = node.Name;

            MyExecutionBlock resultPlan = defaultPlan;

            IMyCustomExecutionPlanner executionPlannerNode = node as IMyCustomExecutionPlanner;
            if (executionPlannerNode != null)
            {
                if (initPhase)
                {
                    resultPlan = executionPlannerNode.CreateCustomInitPhasePlan(defaultPlan);
                }
                else
                {
                    resultPlan = executionPlannerNode.CreateCustomExecutionPlan(defaultPlan);
                }
                resultPlan.Name = defaultPlan.Name;
            }

            if (resultPlan.Name == null)
                resultPlan.Name = node.GetType().Name;

            if (node is MyNodeGroup)
            {
                resultPlan.Name += " (group)";
            }

            // TODO(HonzaS): Rethink this. It's only used in profiling results.
            node.ExecutionBlock = resultPlan;

            return resultPlan;
        }
コード例 #42
0
 public void AddNode(MyWorkingNode node)
 {
     m_addedNodes.Add(node);
 }
コード例 #43
0
 public void RemoveNode(MyWorkingNode node)
 {
     m_removedNodes.Add(node);
 }
コード例 #44
0
        private List<IMyExecutable> GetTasks(MyWorkingNode node)
        {
            List<IMyExecutable> tasks = new List<IMyExecutable>();

            foreach (string taskName in node.GetInfo().KnownTasks.Keys)
            {
                MyTask task = node.GetTaskByPropertyName(taskName);
                tasks.Add(task);
            }

            MyNodeGroup nodeGroup = node as MyNodeGroup;
            if (nodeGroup != null)
            {
                foreach (MyNode childNode in nodeGroup.Children)
                {
                    MyWorkingNode childWorkingNode = childNode as MyWorkingNode;
                    if (childWorkingNode != null)
                    {
                        tasks.AddRange(GetTasks(childWorkingNode));
                    }
                }
            }

            return tasks;
        }
コード例 #45
0
        public override void Restore(MyProject project)
        {
            string[] idSplit = PropertyId.Split(new[] { SerializationIdSeparator }, StringSplitOptions.RemoveEmptyEntries);

            MyNode node = FindNode(project, idSplit[0]);
            WorkingNode = node as MyWorkingNode;
            if (Node == null)
                throw new SerializationException(string.Format("Node id {0} was found but doesn't contain tasks", node.Id));

            string taskGroupName = idSplit[1];
            TaskGroup taskGroup;
            if (!WorkingNode.TaskGroups.TryGetValue(taskGroupName, out taskGroup))
                throw new SerializationException(string.Format("Task group {0} not found", taskGroupName));

            TaskGroup = taskGroup;
        }
コード例 #46
0
 public MyStackingOps(MyWorkingNode caller, MyStackingOperation operations, bool forceInputChecking = false)
 {
     m_caller = caller;
     m_operations = operations;
     m_forceInputChecking = forceInputChecking;
 }
コード例 #47
0
 public void AddNode(MyWorkingNode node)
 {
     m_addedNodes.Add(node);
 }
コード例 #48
0
 public override CudaDeviceVariable <T> GetDevice(MyWorkingNode callee)
 {
     return(GetDevice(callee.GPU));
 }
コード例 #49
0
        public static void CheckControlSize(MyValidator validator, MyAbstractMemoryBlock controls, MyWorkingNode sender)
        {
            validator.AssertError(controls != null, sender, "Controls are not connected");

            if (controls != null)
            {
                int neededControls = NrOfControls;
                int providedControls = controls.Count;
                validator.AssertError(providedControls >= neededControls, sender, String.Format("Wrong number of actions. With current control mode ({0}) you have to provide at least {1} controls. Provide the correct number of controls or change the control mode.", Mode, neededControls));
                validator.AssertWarning(providedControls != neededControls, sender, String.Format("With current control mode ({0}) you should provide {1} controls but you provided {2} controls. Make sure that this is what you want and you have correct control mode chosen.", Mode, neededControls, providedControls));
            }
        }
コード例 #50
0
 public MyMatrixCPUOps(MyWorkingNode callee = null, MatOperation operation = 0, MyMemoryBlock <float> A = null, MyMemoryBlock <float> tmp = null)
 {
 }
コード例 #51
0
 public MyMatrixCPUOps(MyWorkingNode callee=null, MatOperation operation = 0, MyMemoryBlock<float> A = null, MyMemoryBlock<float> tmp = null)
 {
 }